how to detect only one face.
I Dont want to deetct all the faces in the video, I tried removing the for, it doesn't identify anything. I use following code in Android,
Rect[] facesArray = faces.toArray();
for (int i = 0; i < facesArray.length; i++)
Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(),FACE_RECT_COLOR, 3);
But I want to detect only one, how can I convert facesArray so that I can use tl() and br() methods for rectangle() method.
you only want to draw one of many detected face-rects ?
No. I want to only one face to be detected, since my application requires yawning to be detected. It detects even the other parts as positive because of the size of the mouth specified as 24X24
@Punith K please put in some more effort in your posts. Pay attention to your language and start by adding example images of what you are experiencing as wrong. It is pretty hard to provide solutions this way.
@StevenPuttemans Thanks for your advice, My question goes like this,
I'm using, OpenCV sample - Face Detection for Android, (Actually I'm working on Android), The source code given shows all the faces in the video it captures. But, my project is to detect yawning and I have created an cascade classifier, and I'm using it for the same source code. It detects the yawning, when I take my camera very close to the mouth. If I try to identify from some distance it shows so many rectangles. Actually I want to detect only one person yawning,(This project mainly concentrates on single person).
My problem with detecting yawning is that, even it sometimes marks eyes and other objects as positive. So, I want to optimize it to show only yawning in the video
MatOfRect faces = new MatOfRect(); . . . . .
above code draws rectangle over the detected area. So I want above loop only works once, I tried removing for, but it shows error.
I guess your problem is quite straightforward. Start by using your yawn classifier to detect at greater distances and collect all the false positive detections. Then retrain your model using those 'hard negatives'. Take a deeper look in a process called bootstrapping of classifiers.
I know this is a very old post. But I was just searching around the internet for same issue. Would you please tell me how did you solve this? @Punith K
@Vishal Chhatwani , please, just dare to ask a new question in this case.
(imho, the original question was somehow badly worded/sloppy)