Closed SFR75 closed 8 years ago
Can you create and upload an example with a sample image that I can use to reproduce this?
Thanks.
import gab.opencv.; import processing.video.; import java.awt.*;
Capture video; OpenCV opencv; PImage loaded;
void setup() { size(800, 600); video = new Capture(this, 640, 480); opencv = new OpenCV(this, 640, 480); opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
video.start(); }
void draw() { //scale(2); opencv.loadImage(video); image(video, 0, 0 );
noFill(); stroke(0, 255, 0); strokeWeight(3);
Rectangle[] faces = opencv.detect(1.1, 3, 0, 20, 20); //Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) { println(faces[i].x + "," + faces[i].y); rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height); } }
void captureEvent(Capture c) { c.read(); }
Sorry I meant an example image that causes this detection problem. If you're doing this in video, can you take a screenshot and reproduce it with the non-video face detection example?
Ok. This is just a problem with the values you're passing into detect. The last two arguments are minSize and maxSize. So passing 20 for both of those means you only want to find faces that are exactly 20px on a size. When I use:
faces = opencv.detect( 1.1, 3, 0, 10, 500);
It detects that face no problem.
I bet you got those "default" values from the older ubaa opencv wrapper yeah? Those default values aren't present anywhere in OpenCV for Processing (or in OpenCV). They probably have to do with an ancient (~Opencv 1.0) version of this function call. So who knows what they mean relative to the current parameters?
Got it !... Thanks! Well, yeah.. I found these defaults parameters somewhere in OpenCV docs. Didn't find any other defaults anywhere else. Anyway - thanks again.
When calling detect method ( OpenCV. java, line 585)
public Rectangle[] detect(double scaleFactor , int minNeighbors , int flags, int minSize , int maxSize)
with "default" parameters i.e.
detect(1.1, 3, 0, 20,20);
the return is value is always an empty array (no face are detected). However when calling a simpler version detect() with no parameters, then it works.
Thanks M