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! :-)