We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to do face detection on a video with opencv on bootcamp (windows 10) and processing 2.2.1
import processing.video.*;
Movie video; import gab.opencv.*; import java.awt.Rectangle;
OpenCV opencv; Rectangle[] faces;
void setup() { size(640,360);
video = new Movie(this, "people.mp4"); video.play(); video.loop();
opencv = new OpenCV(this, video.width, video.height); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); }void draw() { background(0); fill(255);
image(video,0,0);
opencv.loadImage(video); faces = opencv.detect();
}void movieEvent(Movie m) { m.read();
}
It crashes at the line: opencv.loadImage(video);
With the message: IndexOutOfBoundsException: Index 3: Size 0
Any ideas? This works fine on mac osx with the same version of processing.
Answers
https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
0
before calling OpenCV's loadImage() over the Movie instance.0
height: \m/Thanks for the response. That doesn't seem to help though.
The video is loading correctly. The problem seems to be inside opencv.
Well, .loadImage is encountering a size 0 array. I'm curious, why do you say it is loading correctly? Do you have separate evidence of that?
The video is playing correctly, if I comment out the openCV.loadImage line it plays correctly on the screen, I've tried several different videos and they produce the same result.
If I put a println just abouve opencv.loadImage to print the width/height of the video it gives the correct size of the video even on the first loop.
Even loading an image and passing that to opencv.loadImage produces the same result...
@jayson -- I don't work a lot with movies and opencv in Processing, but according to what I'm seeing in the opencv.loadImage source code, it takes either a filename string or a PImage. Is 'video' a PImage?
By "loading an image ... produces the same result" did you mean that you created a PImage from
video
first, then passed that toopencv.loadImage()
, and it still didn't work?Re: my suggestion to trying demo code first. There are a lot of opencv-processing examples that use loadImage. Do any of them work for you? If none of them work, perhaps you should report an issue. There may already be a related issue in the open issues list.