How to detect biggest face in Java [closed]
Hi,
I have a question to ask, how do I find the biggest face in an image? When I did this program in C + + code was as follows:
cascade.detectMultiScale (Img, objects, 1.1f, 4, CASCADE_FIND_BIGGEST_OBJECT, Size (20, 20));
Where, exactly, I used the tag: CASCADE_FIND_BIGGEST_OBJECT
to identify the largest face.
But in Java as I do? In the documentation http://docs.opencv.org/java/org/opencv/objdetect/CascadeClassifier.html#detectMultiScale(org.opencv.core.Mat, org.opencv.core.MatOfRect, double, int, int, org.opencv.core.Size, org.opencv.core.Size))
I read this:
flags - Parameters with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
So how do I?
Thank you.
[Edit.]
Solved:
I solved it this way:
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale (image, faceDetections);
Rect biggestFace=new Rect();
for (Rect rect: faceDetections.toArray ())
{
if (rect.area ()> biggestFace.area ())
{
biggestFace = rect;
}
}
http://docs.opencv.org/java/org/opencv/objdetect/Objdetect.html
bit hard to find, but it's
Objectdetect.CASCADE_FIND_BIGGEST_OBJECT
Thanks for the reply. However it does not work. In the documentation it says that: flags - Parameters with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
So that means that tag does not work with the new version 2.4.9, right?
So how can I do?
You should loop over detections like you do indeed and check for the largest size of rectangle. The parameter is kind of obsolete afaik.