Play next video when face detected for number of frames
in
Contributed Library Questions
•
1 year ago
Hi Guys,
Here is the simple program I want to run.
I have 3 videos.
1) I want the first one to automatically play when the sketch starts and for that to loop.
2) I want the 2nd one to play if the program detects a face for 450 frames.
3) I want the 3rd one to play if the program detects a face for 450 frames into the second video.
As the sketch stands now, I can push to the next video using a mousePress, but I need that to happen with face detection.
Should I use frameCount or something? How should I set it up?
Code here:
Would love if you could give me a hand!
Thanks!
Here is the simple program I want to run.
I have 3 videos.
1) I want the first one to automatically play when the sketch starts and for that to loop.
2) I want the 2nd one to play if the program detects a face for 450 frames.
3) I want the 3rd one to play if the program detects a face for 450 frames into the second video.
As the sketch stands now, I can push to the next video using a mousePress, but I need that to happen with face detection.
Should I use frameCount or something? How should I set it up?
Code here:
- import hypermedia.video.*;
import java.awt.Rectangle;
import processing.video.*; // import video library
OpenCV opencv;
Movie myMovie; // var to hold movie
Movie myMovie2;
Movie myMovie3;
Movie[] myMovies = new Movie[3];
int counter = 0;
void setup() {
size(400, 680, P2D); // note call to renderer
opencv = new OpenCV( this );
opencv.capture( width, height ); // open video stream
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load detection description, here-> front face detection : "haarcascade_frontalface_alt.xml"
myMovies[0] = new Movie(this, "1_intimidating.m4v"); // load movie
myMovies[1] = new Movie(this, "2_faltering.m4v"); // load movie
myMovies[2] = new Movie(this, "3_defeated.m4v"); // load movie
myMovies[0].play();
myMovies[1].play();
myMovies[2].play();
myMovies[0].loop();
myMovies[1].loop();
myMovies[2].loop();
}
void draw() {
if (myMovies[counter].available()) {
myMovies[counter].read();
}
image(myMovies[counter], 0, 0, width, height);
Rectangle[] faces = opencv.detect();
}
// image(myMovie, 0, 0, width, height); // draws movie on the screen
// image(myMovie, 0, 0, width, height); // draws movie on the screen
// image(myMovie, 0, 0, width, height); // draws movie on the screen
// Called every time a new frame is available to read
void mousePressed() {
counter++; // pushes video forward
}
Would love if you could give me a hand!
Thanks!
1