Face classification using Haar-like feature descriptor
Haar-like feature descriptors were successfully used to implement the first
real-time face detector [1]. Inspired by this application, we propose an
example illustrating the extraction, selection, and classification of Haar-like
features to detect faces vs. non-faces.
Notes
This example relies on scikit-learn for feature
selection and classification.
The procedure to extract the Haar-like features from an image is relatively
simple. Firstly, a region of interest (ROI) is defined. Secondly, the
integral image within this ROI is computed. Finally, the integral image is
used to extract the features.
We use a subset of CBCL dataset which is composed of 100 face images and
100 non-face images. Each image has been resized to a ROI of 19 by 19
pixels. We select 75 images from each group to train a classifier and
determine the most salient features. The remaining 25 images from each
class are used to assess the performance of the classifier.
A random forest classifier can be trained in order to select the most
salient features, specifically for face classification. The idea is to
determine which features are most often used by the ensemble of trees.
By using only the most salient features in subsequent steps, we can
drastically speed up the computation while retaining accuracy.
We can select the most important features by checking the cumulative sum
of the feature importance. In this example, we keep the features
representing 70% of the cumulative value (which corresponds to using only 3%
of the total number of features).
Computing the full feature set took 18.733s, plus 1.660s training, for an AUC of 1.00. Computing the restricted feature set took 0.097s, plus 1.466s training, for an AUC of 1.00.
Total running time of the script: (0 minutes 24.525 seconds)