Hello!
I need help with something i'm doing...
First of all I want to do this:
https://vimeo.com/18499643
That is an interactive display and I want to use the face tracking to know the position on "x" of the face of the person that is walking in front of the "Interactive Display". With the position of the face, I will know the time in that the video is.
I already have the face recognition using the
OpenCV library and I´m using the
GSVideo library to manipulate the time of a video with the mouse pointer, but i don't know how to replace the mouse pointer with the face tracking, I don´t know how to combine that codes. Could someone help me how to do this please. :D
------------------------------------------------
This is the face recgnition code:
-
import hypermedia.video.*;import java.awt.Rectangle;
OpenCV opencv;
// contrast/brightness valuesint contrast_value = 0;int brightness_value = 0;
void setup() {
size( 320, 240 );
opencv = new OpenCV( this );opencv.capture( width, height ); // open video streamopencv.cascade( OpenCV.CASCADE_PROFILEFACE ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
// print usageprintln( "Drag mouse on X-axis inside this sketch window to change contrast" );println( "Drag mouse on Y-axis inside this sketch window to change brightness" );
}
public void stop() {opencv.stop();super.stop();}
void draw() {
// grab a new frame// and convert to grayopencv.read();opencv.convert( GRAY );opencv.contrast( contrast_value );opencv.brightness( brightness_value );
// proceed detectionRectangle[] faces = opencv.detect( 1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );
// display the imageimage( opencv.image(), 0, 0 );
// draw face area(s)noFill();stroke(255,0,0);for( int i=0; i<faces.length; i++ ) {rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );}}
/** Changes contrast/brigthness values*/void mouseDragged() {contrast_value = (int) map( mouseX, 0, width, -128, 128 );brightness_value = (int) map( mouseY, 0, width, -128, 128 );}
And this is the code to manipulate the video with the mouse:
-
import codeanticode.gsvideo.*;
GSMovie movie;
void setup() {size(640, 480);background(0);
movie = new GSMovie(this, "video1.mov");
// Pausing the video at the first frame.movie.play();movie.goToBeginning();movie.pause();}
void movieEvent(GSMovie movie) {movie.read();}
void draw() {// A new time position is calculated using the current mouse location:float f = constrain((float)mouseX / width, 0, 1);float t = movie.duration() * f;if (movie.ready()) {movie.play();movie.jump(t);movie.pause();}image(movie, 0, 0, width, height);}
1