Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Need help! Mirroring text movement on x axis?

$
0
0

The text in the sketch needs to be on the face and following the face. On x axis but it is moving the opposite direction.

code:

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

String text2 = "";

Capture video;
OpenCV opencv;

void setup() {
  size(640*2, 480*2);
  video = new Capture(this, 640, 480);
  opencv = new OpenCV(this, 640, 480);
  opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);  

  textFont(createFont("Menlo",(5)));

  video.start();
}


void draw() {
  pushMatrix();
  opencv.loadImage(video);
  //background(0); //voor zwarte achtergrond onder tekst
     scale(-1,1);// spiegelen van beeld
     translate(-video.width, 0); //terug plaatsen in kader/
     image(video, 0, 0); // activeer of deactiveer code voor vieobeeld of niet
     scale(-1,1); // spiegel tekst nog een keer
    textSize(40);
//    text(text2, 30, 30);
    textAlign(CENTER);
    text2 = "Watching You";

//  noFill();
//  stroke(255, 0, 0);
//  strokeWeight(300);
  Rectangle[] faces = opencv.detect();
  println(faces.length); //deactiveer voor geen print output in beeld
//scale(-1,1); // spiegel tekst nog een keer  --- deze niet???

// I think the problem maybe somewhere??  V

    for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);  //deactiveer voor geen print output in beeld
//    rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
    text(text2,faces[i].x-width, faces[i].y,width,width);
  }  
      popMatrix();
}

void captureEvent(Capture c) {
  c.read();
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles