Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved cat face cascades (lower false positive rate) #7097

Merged
merged 2 commits into from
Aug 18, 2016

Conversation

JoeHowse
Copy link
Contributor

This pullrequest changes

Re-trained the cat face cascades with more negative samples and more stages. False positives are much rarer now. If you tailored your code for the previous version of one of the cat face cascades, now you should re-adjust the arguments of CascadeClassifier::detectMultiScale. For example, decrease the value of the minNeighbors argument. You do not need to use a human face detector to cross-check the positives anymore.

haarcascade_frontalcatface_extended.xml has the lowest false positive rate but you should set its scaleFactor and minNeighbors relatively low to enhance its sensitivity. If you tweak the parameters carefully, you can probably get the most accurate results from this cascade but it is computationally relatively expensive.

haarcascade_frontalcatface.xml and lbpcascade_frontalcatface.xml are more sensitive but they need higher scaleFactor and minNeighbors values to keep the false positive rate low. lbpcascade_frontalcatface.xml is computationally cheapest.

@StevenPuttemans
Copy link

👍 nice update!

@JoeHowse
Copy link
Contributor Author

@StevenPuttemans Thanks! I used your tips from OpenCV 3 Blueprints!

@StevenPuttemans
Copy link

Could you expand on what you did exactly? Is it an example of the hard negative mining? Would be nice to have an actual sample that proves it works decently!

@JoeHowse
Copy link
Contributor Author

I haven't used hard negative mining (though I will keep it in mind for the next version). I used your advice about choosing the number of stages based on a reported acceptance ratio of close to 10^(-5). I also saw that you recommended a higher proportion of negative samples than I was using, so I added a lot more negative samples of generic indoor and outdoor scenes. Finally, on your advice, I lowered the minHitRate from 0.999 to 0.995.

I ended up with the following inputs and parameters:

  • 9997 positive samples (same as the previous version). I used 90% of them per stage.
  • 8089 negative samples (including 3019 new samples). I used 90% of them per stage.
  • numStages=20
  • minHitRate=0.995
  • maxFalseAlarmRate=0.5

I will release the code for data acquisition, pre-processing, and training in another repo after the cascades are merged into OpenCV.

@StevenPuttemans
Copy link

Great work! Thanks for the explanation!

@vpisarev vpisarev self-assigned this Aug 18, 2016
@vpisarev
Copy link
Contributor

thanks! 👍

@opencv-pushbot opencv-pushbot merged commit 00045bb into opencv:master Aug 18, 2016
opencv-pushbot pushed a commit that referenced this pull request Aug 18, 2016
@KangolHsu
Copy link

excellent work!i want to know what is your training data?

@JoeHowse
Copy link
Contributor Author

JoeHowse commented Apr 8, 2019

excellent work!i want to know what is your training data?

Thank you! The following script shows where I obtained the training data: https://github.com/JoeHowse/PRIVATE-OpenCV-4-for-Secret-Agents-Second-Edition/blob/master/Chapter003/cascade_training/download_datasets.sh

For more information about the training, please refer to the rest of that repository, and to my upcoming book OpenCV 4 for Secret Agents, which will be available from Packt Publishing very soon.

@KangolHsu
Copy link

@JoeHowse Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants