Ask Your Question

How to get the best detection for an object

asked 2012-11-13 14:02:45 -0600

Oscanto gravatar image

updated 2012-11-13 14:18:17 -0600

Sorry if the title is not clear enough, I will try to explain it better. I have a picture and I know there is only one face inside, i would like to know the best way to find that face. For the moment, I'm doing this :

faceClassifier.detectMultiScale(img, faces, 1.2, 1, Objdetect.CASCADE_FIND_BIGGEST_OBJECT | Objdetect.CASCADE_DO_ROUGH_SEARCH, new Size(img.rows()/5, img.cols()/5), new Size(img.rows(), img.cols()));

But with this, I'm not getting the "best" face, but the bigger one, and I think it could result in an oversized rectangle around the face.
I could set minNeighbors to a high value, but sometimes, the face won't be good enough to be well detected, so i should not discard any candidate, because I should always find one !

Thanks for your help,

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-11-14 03:18:22 -0600

I am just throwing this out there without any real science behind it but... how about setting the number of minNeighbors to a high value and, if you don't find a face, iteratively reduce the number of minNeighbors until you find one?

edit flag offensive delete link more


Thanks, it could work of course, but performance will be a pain... I've simplified my problem, but i'm building a real-time application on Android, so it's not really possible to do that... I'm going to look around the grouping function, because I can get every rectangle by setting minNeighbors to 0, and maybe I can make my own grouping function, remembering how many rectangles were merged to build a rectangle...

Oscanto gravatar imageOscanto ( 2012-11-14 03:26:41 -0600 )edit

answered 2012-11-27 05:08:07 -0600

venky gravatar image

Hi, I think what the algorithm does is it finds the first response of the face and returns you the bounding box. So one approach to get a better localization would be to use the first returned bounding box, and then use this region of interest ROI to localize it better using a proper search. Hope this could reduce the time consumed to detect a face.

If the face is big in size that you want to detect then setting to 1.3 instead of 1.2 could also help a bit. I donot know for what application (Face recognition) that you are going to use it for, so it might depend on that finally, if you want to have better localization or just know that there is a face. Thanks

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2012-11-13 14:02:45 -0600

Seen: 768 times

Last updated: Nov 27 '12