Iteration 4

Since my last post I feel that i’ve made progress with my idea and it’s starting to come together to what I want. Now that the video will stop and jump to the beginning when a face isn’t seen and play when a face is seen, I have cleaned up the code a bit.

//create image in folder i save it in, in data folder.

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

Movie react;
Capture video;
OpenCV opencv;

void setup() {
size(640, 480);
//scale video down, so it runs smoother
video = new Capture(this, 640/2, 480/2);
//loading open cv, and face tracking
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

video.start();

//loading my video
react = new Movie(this, “movie.mp4”);
//looping video
react.loop();
}

void draw() {

//scaling video back up to fit the canvas
scale(2);
opencv.loadImage(video);

//displaying the camera video, will be removed
image(video, 0, 0 );

//adjusting the reaction video
pushMatrix();
//scaling video down to fit canvas
scale(0.5);
//tint to make transparent
//tint(255, 185);
//display my reaction video
image(react, 0, 0);
popMatrix();

//styling for the face tracking rectangle
noFill();
stroke(0, 255, 0);
strokeWeight(3);
Rectangle[] faces = opencv.detect();
println(faces.length);

//draw rectangle around the face
//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);
// }

//if one or more faces are seen, reaction video will play, else it is paused.
if (faces.length >= 1) {
react.play();
} else {
//when theres no face, reaction video jumps to beginning
react.jump(0);
react.pause();
}
saveFrame(“###.jpg”);
}

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

void movieEvent(Movie m) {
m.read();
}

This code above stops the green rectangle from displaying and removes the tint so now its only the video playing that shows. Now that i have the correct code that works, I am going to find someone to be in my video that will make the facial expressions once a face is seen. I have removed the tint from this video and future videos because I want to work with it how it will be seen when presented. So every time the video stops and starts again, its just me covering and un-covering my face to make it work.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s