Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between OpenCV's Haar Cascade Classifiers [duplicate]

I am a freshman for face detection. These days I try to compile the OpenCV2.1 code for face detection. I found that there are about 4 cascade files for front face detection, which are "haarcascade_frontalface_alt.xml","haarcascade_frontalface_alt_tree.xml","haarcascade_frontalface_alt2.xml" and "haarcascade_frontalface_default.xml"

I did not find any documents to describe the difference among them, which is prefer for face detection task?

like image 759
Dayong Wang Avatar asked Dec 14 '10 14:12

Dayong Wang


People also ask

What is better than Haar Cascade?

An LBP cascade can be trained to perform similarly (or better) than the Haar cascade, but out of the box, the Haar cascade is about 3x slower, and depending on your data, about 1-2% better at accurately detecting the location of a face.

What is the limitation in Haar cascade classifier?

The downside to Haar cascades is that they tend to be prone to false-positive detections, require parameter tuning when being applied for inference/detection, and just, in general, are not as accurate as the more “modern” algorithms we have today.

What is Haar feature based Cascade classifiers?

Haar feature-based cascade classifiers is an effectual machine learning based approach, in which a cascade function is trained using a sample that contains a lot of positive and negative images. The outcome of AdaBoost classifier is that the strong classifiers are divided into stages to form cascade classifiers.

Is hog better than Haar Cascade?

Note that HOG has higher accuracy for face detection than Haar cascade classifier. Haar cascade classifier do more False Positive prediction on faces than HOG based face detector.


2 Answers

To get an idea how successful each one is, how many false positives, and how much stuff in total it finds, I ran each XML file on 41,452 magazine covers and made a contact sheet and average of each.

Here are the results on Flickr. The titles show the input XML filename and how many features were detected.

Example result for haarcascade_frontalface_default.xml

haarcascade_frontalface_alt_tree.xml_-_4720_into_onehaarcascade_frontalface_alt2.xml_-_9563_into_onehaarcascade_frontalface_alt.xml_-_8970_into_one

For the files you mention, here's how many features were found:

  • 10,692 haarcascade_frontalface_default.xml
  • 9,563 haarcascade_frontalface_alt2.xml
  • 8,970 haarcascade_frontalface_alt.xml
  • 4,720 haarcascade_frontalface_alt_tree.xml

I didn't count the false positives, you have to check the images for that (for example, the smile file isn't very good, but the faces generally are). Of course, you'll get different results depending on your input data, and magazine covers are generally quite clean photos.

like image 178
Hugo Avatar answered Oct 13 '22 16:10

Hugo


It depends on your use case. If you prefer high precision or prefer high recall.

I did a comparison test of face detection for haarcascade_frontalface_default.xml and haarcascade_frontalface_alt_tree.xml, with the same parameters for detectMultiScale function, and only keep the max rectangle that detectMultiScale returns.

On my test data, I found haarcascade_frontalface_default.xml has higher recall (side effect is, more false positives), and haarcascade_frontalface_alt_tree.xml has higher precision (side effect is, detected less number of faces)

You many try with similar test on your data, and choose the one that best suits your purpose

like image 39
Ronggang Avatar answered Oct 13 '22 17:10

Ronggang