Вы находитесь на странице: 1из 8

Computing Rectangular Haar Features for Cascade Detection Training

Pi19404
July 8, 2013

Contents

Contents
Computing Rectangular Haar Features for Cascade Detection Training
0.1 Introduction . . . . . . . . . . . . 0.2 Haar Like Features . . . . . . . 0.3 Integral Image Representation 0.4 Implementation Details . . . . . 0.5 Code . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
3 3 5 6 7 7

2 | 8

Computing Rectangular Haar Features for Cascade Detection Training

Computing Rectangular Haar Features for Cascade Detection Training


0.1 Introduction
In the article we will look at Haar feature extraction which is used for cascade object detection. And provide a generic method of feature extraction .

0.2 Haar Like Features


Haar like Features are simple rectangular features which are based on Haar Wavelets. The set of rectangular features used for visual recognition task are not acutally haar wavelet but bear some resemblence to Haar wavelet basis function. The Haar features are evaluated at all possible translation and dydactic scales. Thus a very large number of features are extracted from images. Consider the following Haar features. Figure 1a resembles a first

(a) Haar Feature 1

(b) Haar Feature 2

(c) Haar Feature 3

order derivative along the x direction.All possible translation and dydactic scales need to be considered

3 | 8

Computing Rectangular Haar Features for Cascade Detection Training The number translations along y direction at successive scales are (24,23,. . . ,3,2,1) ,which is total of 300. The number of translations along the x direction at successive scales are (23,21,19,. . . ,5,3,1),which is total of 144 The total number of features are 43200. Figure 1b resembles first order derivative along the y direction. The calculate of features is same as Haar feature 1 and total number of features are 43200. Figure 1c resembles second order derivative along the x direction. Considering all the possible translation and scales . The number translations along y direction at successive scales are (24,23,. . . ,3,2,1) ,which is total of 300. The number of translations along the x direction at successive scales are (22,19,16,. . . ,7,4,1),which is total of 92 The total number of features are 27600.

(d) Haar Feature 4

(e) Haar Feature 5

Figure 1d resembles second order derivative along the y direction. The calculate of features is same as Haar feature 3 and total number of features are 27600. Figure 1e resembles second order partial derivative along the x y direction or derivative along the diagonal . Considering all the possible translation and scales . The number translations along y direction at successive scales are (23,21,. . . ,5,3,1) ,which is total of 144.

4 | 8

Computing Rectangular Haar Features for Cascade Detection Training The number of translations along the x direction at successive scales are (23,21,. . . ,5,3,1),which is total of 144. The total number of features are 20736. These are the 5 basic haar features proposed in the original paper of Viola and Jones. The total number of features for a simple 25x25 image comes out to be 162336. Most of these features are redundant and only a small set of features are required to represent the object of interest.

0.3 Integral Image Representation


Thus Viola and Jones uses a total of about 162336 rectangular features. Integral image representation is used for fast computation of sum/difference of rectangular areas.We will not be looking at integral image representation but rather use it as a blackbox which takes as input the co-ordinates of rectangular are outputs the mean or weighted mean value of pixels that fall in rectangular area. It can be noticed that haar features can be computed as sum and different of mean pixels intesities in rectangular areas. Let us assume that we have the integral image representation of image in Figure 1f. Sum of pixels in the rectangulare area is simply given by where

I (C ) + I (A) I (B ) I (D)

in integral image corresponding to original image.

Let us

(f) Integral Image

consider the first Haar Features 1a. This haar feature is made up

5 | 8

Computing Rectangular Haar Features for Cascade Detection Training of 2 rectangular areas. The pixels in black area are weighted by -1 while pixels in the white area are weighted by 1.The aim is to compute the sum over all the pixels of Haar features. This can be done by computing the sum using integral image over the black and white rectangular area them simply weighing the results by +1 or -1 and adding it to get the complete sum. The basic steps are :-

  

Compute sum of pixels for all rectangles that make up Haar Feature Weight the results of integral sum computation of individual rectangles Add the results of all individual rectangles to get the final result.

0.4 Implementation Details


The Rectangles Class is a basic unit. It is characterized by rectangle and weight . The Haar Feature class consists of vector of Rectangle Classes. To compute the Haar feature loop over the vector or Rectangle objects compute the integral sum,multiply by the rectangle weight,and calculate the cumulative sum over all the rectangles. The Harr Feature Set class consists of vector of objects of type Haar Features. Given a input image we compute the integral image representation of the image.For This we use the built-in OpenCV function. The compute method in Harr Feature Set class accepts as input a image and compute the harr rectangular features over the image. To minimize the effect of lighting conditions all the subwindows were variance normalized. Variance of a subwindow can be quikly computed using

2 N

m2 N

6 | 8

Computing Rectangular Haar Features for Cascade Detection Training where x is the pixel within the subwindow,m is the mean and  is the standard deviation. Thus we need to compute the mean and squared sum over the sub window over the image. Like the sum ,squared sum also can be computed efficiently using integral image representation. To compute mean and squared sum we compute the sum of pixels over the subwindow for integral images and square integral image. The we add the results over all the sub rectangles in the Haar feature to compute the mean and square sum of pixels. Using these results we can compute the variance over the subwindows. The result of weighted sum of pixels is divided by the variance to perform variance normalization. The time take to compute all the haar features for a 25x25 image is 0.3 sec.

0.5 Code
The code for the testing and training utility can be found at https: //github.com/pi19404/m19404/tree/master/objdetect/HaarFeatures

7 | 8

Bibliography

Bibliography
[1] P. Viola and M. Jones.  Rapid object detection using a boosted cascade of simple features. In: Computer Vision and Pattern Recognition, 2001. CVPR 2001.
Proceedings of the 2001 IEEE Computer Society Conference on.

I511I518 vol.1. [2]

doi: 10.1109/CVPR.2001.990517.

Vol. 1. 2001,

Jianxin Wu et al.  Fast Asymmetric Learning for Cascade Face Detection. In:
IEEE Trans. Pattern Anal. Mach. Intell.

0162-8828.

doi: 10.1109/TPAMI.2007.1181. 1109/TPAMI.2007.1181.

30.3 (Mar. 2008), pp. 369382.

url: http://dx.doi.org/10.

issn:

8 | 8

Вам также может понравиться