control movie by facedetection
in
Contributed Library Questions
•
6 months ago
I am trying to control a video by face detection.
When face is detect movie will play other wise it will pause.
I tried to make perfect but getting error....
(java.exe:3680): GStreamer-CRITICAL **: gst_event_new_seek: assertion `rate != 0.0' failed
(java.exe:3680): GStreamer-CRITICAL **: gst_element_send_event: assertion `event != NULL' failed
Here is my code.......
import hypermedia.video.*;
import java.awt.Rectangle;
import processing.video.*;
int facecount = 0;
OpenCV opencv;
Movie myMovie;
final static float fps=24;
long t = 0L, drawt = 0L;
void setup() {
frameRate (fps);
size( 640, 480, P2D);
myMovie = new Movie(this, "childplay.mov");
myMovie.loop();
opencv = new OpenCV(this);
opencv.capture( width, height );
opencv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // load the FRONTALFACE description file
t = System.currentTimeMillis();
}
void draw() {
timelog("draw() : fps = "+(((double)1000)/((System.currentTimeMillis()-drawt))),drawt);
opencv.read();
image( opencv.image(), 0, 0 );
// detect anything ressembling a FRONTALFACE
Rectangle[] faces = opencv.detect();
facecount = faces.length;
if(facecount>0) {
image(myMovie, 0, 0);
myMovie.speed(1);
println("PLAY MOVIE");
}
else {
image(myMovie, 0, 0);
myMovie.speed(0);
println("PUASE MOVIE");
}
}
void movieEvent(Movie m) {
m.read();
}
void timelog(String s, long tmpt) {
// println(s+" : "+(System.currentTimeMillis()-tmpt)+"ms");
tmpt = System.currentTimeMillis();
}
void timelog(String s) {
// println(s+" : "+(System.currentTimeMillis()-t)+"ms");
t = System.currentTimeMillis();
}
Need your valuable suggestions.
Thanking you in anticipation.
1