Quantcast
Channel: Kinect - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 530

Create an Image Mask On Top of a Live Feed

$
0
0

Hey all!

So for this code I'm trying to create a code that will use a live webcam feed and face tracking to put an image on top of the tracked face. After this point, I want to press a key ('n' in the code I posted below) and have it switch to a different picture. Right now as a base code I have processing's "LiveFaceTracking" example in my code. Any help you guys could give me would be greatly appreciated!

    import gab.opencv.*;
    import processing.video.*;
    import java.awt.*;
    PImage WD;
    PImage GJ;

    Capture video;
    OpenCV opencv;

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

      loadImage("WD");
      loadImage("GJ");
    }

    void draw() {
      scale(2);
      opencv.loadImage(video);

      image(video, 0, 0 );

      noFill();
      stroke(0, 255, 0);
      strokeWeight(3);
      Rectangle[] faces = opencv.detect();
      println(faces.length);

      for (int i = 0; i < faces.length; i++) {
        println(faces[i].x + "," + faces[i].y);
        rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
      }
    }

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

    void keyPressed(){
      if(key = 'n'){
        loadImage = WD;

Viewing all articles
Browse latest Browse all 530

Trending Articles