Haar Cascade Algorithm
Paul Viola and Michael Jones proposed Haar Cascade Algorithm, which is productively used for Object Detection. This Algorithm is based on a Machine Learning approach in which lots of images are used, whether positive or negative, to train the classifier.
The first real-time face detector also used the Haar classifiers, which we are introducing here. Finding objects in pictures and videos is done by a machine learning programme known as a Haar classifier or a Haar cascade classifier.
Haar Cascade Algorithm Explanation:
This involves Four Stages that include:
1. Haar Features Calculation: Gathering the Haar features is the first stage. Haar features are nothing but a calculation that happens on adjacent regions at a certain location in a separate detecting window. The calculation mainly includes adding the pixel intensities in every region and between the sum differences calculation.
This is arduous in the case of large images because these integral images are used in which operations are reduced.
2. Integral Image Creation: Creating Integral Images reduces the calculation. Instead of calculating at every pixel, it creates the sub-rectangles, and the array references those sub-rectangles and calculates the Haar Features.
The only important features are those of an object, and mostly all the remaining Haar features are irrelevant in the case of object detection. But how do we choose from among the hundreds of thousands of Haar features the ones that best reflect an object? Here Adaboost enters the picture.
3. Adaboost Training:
The "weak classifiers" are combined by Adaboost Training to produce a "strong classifier" that the object detection method can use. This essentially consists of selecting useful features and teaching classifiers how to use them.
By moving a window across the input image and computing the Haar characteristics for each part of the image, weak learners are created. This distinction stands in contrast to a threshold that can be trained to tell objects apart from non-objects. These are "weak classifiers," but an accurate strong classifier needs many Haar properties.
In the final step, weak learners might be combined with strong learners.
4. Cascading Classifiers Implementation:
Every sage at this point is actually a group of inexperienced students. Boosting trains weak learners, resulting in a highly accurate classifier from the average prediction of all weak learners.
It depends based upon the prediction. The classifier decides for indication of an object that was found positive or moved to the next region, i.e., negative. Because most windows do not contain anything of interest, stages are created to reject negative samples as quickly as feasible.
Because classifying an object as a non-object would significantly hurt your object detection system, having a low false negative rate is crucial.
Code: Eyes Detection
Code: Face and Eyes Detection
This Haar Cascade algorithm can detect all types of objects unless an object should have a similar XML file. We can create our files and detect the object type we want.
The Haar Cascade Algorithm is used in several varieties of fields. Some of the applications are:
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week