We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am using Processing with the OpenCV Lib and wanted to rewrite the example Code from the creators Git so that instead of doing Face Detection on a Camera Capture I'll load a video (.mp4).
Link to the Git and the example Code (which is working): Link
Here is my Sketch:
import processing.video.*;
import gab.opencv.*;
import java.awt.Rectangle;
OpenCV opencv;
Movie myMovie;
Rectangle[] faces;
void setup() {
size(480, 270);
myMovie = new Movie(this, "people3.mp4");
myMovie.loop();
opencv = new OpenCV(this, myMovie.width, myMovie.height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
}
void movieEvent(Movie myMovie) {
myMovie.read();
}
void draw() {
background(0);
if (myMovie.available()) {
opencv.loadImage(myMovie);
faces = opencv.detect();
image(myMovie, 0, 0);
if (faces != null) {
for (int i = 0; i < faces.length; i++) {
strokeWeight(2);
stroke(255, 0, 0);
noFill();
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
}
}
}
What I'm getting is an IndexOutOfBoundsException: Index: 3, Size: 0 at openCV.loadImage(myMovie) and I don't know why.
Appreciating any help! :-)
Answers
https://Forum.Processing.org/two/discussion/16435/how-to-make-the-webcam-capture-window-go-away-or-put-images-over-it
Sorry, but I don't really get how this should help me?
I have the same Problem as jayson had in this thread: https://forum.processing.org/two/discussion/18536/opencv-problem-with-bootcamp
As you can see here It totally should be possible to use the loadImage function with a movie argument:
Made it work. Don't ask me why, but it's necessary to call both the Movie.loop() and Movie.play() function.. Here you go:
I tried with either loop or play and both worked. There was no need to call both simultaneously. I prefer not to use a while inside draw. Instead, you could do something like:
Thxs for sharing.
Kf