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 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);


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

void draw() {

//scaling video back up to fit the canvas

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

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

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

//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) {;
} else {
//when theres no face, reaction video jumps to beginning

void captureEvent(Capture c) {;

void movieEvent(Movie m) {;

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.


Leave a Reply

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

You are commenting using your 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