Archive for July, 2011

Face-Detection with OpenCv

Image manipulation of image stills taken from live camera has always fascinated me. For the beginners, it is  best to use the library ‘OpenCV’ . In my earlier post about OpenCV ,I was able to get image frames from the webcam  at a rate of about 30 images per second and then displayed it onto a window.
Object detection with OpenCV

         The task of Object Detection from a still image can be made simpler with the help of this library. Here for an object to be detected a cascade of boosted classifiers has to be trained and then used. A large set of over-complete haar-like features provide the basis for the simple individual classifiers.
A cascade of classifiers is degenerated decision tree where at each stage a classifier is trained to detect almost all objects of interest while rejecting a certain fraction of the non-object patterns.  Each stage was trained using the Discrete Adaboost algorithm .Discrete Adaboost is a powerful machine learning algorithm. It can learn a strong classifier based on a large set of weak classifiers by re-weighting the training samples.
For this (haar training procedure)  a large set of positive samples and negative samples are needed. Positive samples are those image set containing the object of interest and negative samples don’t have features of object of interest. For example if object of interest is face, then about 5000 image samples containing (the frontal face) and about 5000 negative image set(not having face) is needed.  OpenCV provide utilities to train the haar classifiers from the image samples collected (both positive and negative) .Finally , when a haar-classifies is trained, a xml file is created containing the features of object of interest. This ‘xml’ file can be used as per our needs for detecting the object from an image.I tried to detect faces from the images taken from the webcam and drew a circle on them.The haarcascade xml file was available with OpenCV documentation which is available in the standard linux distribution.So finally ,when the piece of code is executed, a window appears which displays the video taken from the webcam and draw a circle on the faces present in it.    Some images are

Some links which can be usefull
My program for the above can downloaded from my git hub id
 git@github.com:rohitnjan88/Face-detection.git
Advertisements

Leave a comment