Viola-Jones Method
This method is used for frontal face detection and is used in opencv library. Haar Cascade is a classifier which is used for detection of human frontal face.
- The function "cvHaarDetectObjects" in OpenCV performs the actual face detection
- This approach to detecting objects in images combines four key concepts: - Simple rectangular features, called Haar features
- Features used are based on Haar wavelets (Haar wavelets are single wavelength square waves (one high interval and one low interval)).
- In two dimensions, a square wave is a pair of adjacent rectangles one light and another dark.
- Haar Features are determined by the subtracting the average dark region pixel from the average white region pixel.
- If difference is above threshold, the feature is said to be present else not.
- For hundreds of haar feature detection method of integration is used.
- Small units of image, pixels, are added in such a manner that the integral value for each pixel is the sum of all the pixels above it and to its left.
- Figure below shows, after integration, the value at each pixel location, (x,y), contains the sum of all pixel values within a rectangular region that has one corner at the top left of the image and the other at location (x,y). To find the average pixel value in this rectangle, you'd only need to divide the value at (x,y) by the rectangle's area. But what if you want to know the summed values for some other rectangle, one that doesn't have one corner at the upper left of the image? Figure (b) shows the solution to that problem. Suppose you want the summed values in D. You can think of that as being the sum of pixel values in the combined rectangle, A+B+C+D, minus the sums in rectangles A+B and A+C, plus the sum of pixel values in A. In other words,
D = A+B+C+D - (A+B) - (A+C) + A.
- An Integral Image for rapid feature detection
- The AdaBoost machine-learning method
- A cascaded classifier to combine many features efficiently
- A+B+C+D is the Integral Image's value at location 4, A+B is the value at location 2, A+C is the value at location 3, and A is the value at location 1. So, with an Integral Image, you can find the sum of pixel values for any rectangle in the original image with just three integer operations: (x4, y4) - (x2, y2) - (x3, y3) + (x1, y1).
- For selecting specific haar features and to set threshold level AdaBoost machine learning method is used.
- AdaBoost selects a set of weak classifiers to combine and assigns a weight to each. This weighted combination is the strong classifier.
- The acceptance threshold at each level is set low enough to pass all, or nearly all, face examples in the training set (The training set is a large database of faces, maybe a thousand or so). Viola and Jones combined a series of AdaBoost classifiers as a filter chain. During use, if any one of these filters fails to pass an image region, that region is immediately classified as "Not Face."
- If a filter passes an image region, it goes to the next filter in the chain. Image regions that pass through all filters in the chain are classified as "Face."
