how to detect only one face.

asked 2014-08-18 05:19:12 -0600

Punith K gravatar image

updated 2014-08-19 04:48:15 -0600

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.

edit retag flag offensive close merge delete

Comments

you only want to draw one of many detected face-rects ?

berak gravatar imageberak ( 2014-08-18 05:28:25 -0600 )edit

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 gravatar imagePunith K ( 2014-08-18 05:41:30 -0600 )edit
  • if there are several faces in the image, which ones do you want to remove ?
  • your code only shows the drawing part. sure, you could filter by size or similar, but the actual detection happens in detectMultiScale()
  • you could try to increase the neighbours param in detectMultiScale(), at the cost of possibly missing faces.
berak gravatar imageberak ( 2014-08-18 05:49:23 -0600 )edit
1

@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 gravatar imageStevenPuttemans ( 2014-08-19 04:49:43 -0600 )edit

@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

Punith K gravatar imagePunith K ( 2014-08-19 05:20:53 -0600 )edit

MatOfRect faces = new MatOfRect(); . . . . .

    Rect[] facesArray = faces.toArray();
    for (int i = 0; i &lt; facesArray.length; i++)
        Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3);

above code draws rectangle over the detected area. So I want above loop only works once, I tried removing for, but it shows error.

Punith K gravatar imagePunith K ( 2014-08-19 05:29:32 -0600 )edit

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.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-08-19 05:50:10 -0600 )edit

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 gravatar imageVishal Chhatwani ( 2015-04-11 14:45:43 -0600 )edit
1

@Vishal Chhatwani , please, just dare to ask a new question in this case.

(imho, the original question was somehow badly worded/sloppy)

berak gravatar imageberak ( 2015-04-11 14:49:38 -0600 )edit