Number of haar features

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Number of haar features

sabatier_sabrika-2
Hi,

In the original Viola Jones paper on face detection, they say there are more than 180,000 haar features in a 24x24 subwindow.

Anyone know how this is calculated?

Reply | Threaded
Open this post in threaded view
|

Re: Number of haar features

zhangzhonginuta
--- In [hidden email], "sabatier_sabrika" <sabatier.sabrika@...> wrote:
>
> Hi,
>
> In the original Viola Jones paper on face detection, they say there are more than 180,000 haar features in a 24x24 subwindow.
>
> Anyone know how this is calculated?
>
Hi,
According to my understanding, the calcaulating process is as follows:
As for a 24*24 window, there are twenty-three types of subwindow.(2*2, 3*3, 4*4, 5*5, ..., 24*24).
Let's pick up 4*4(A) for example. In the 24*24 subwindow, the number of A(4*4) is 21*21(441). Every A has four haar features. So we can get 441*4(1764) haar features for 4*4.  
So, (22*22 + 21*21 + 20*20 +...+ 1*1)*4 + (23*23)*3 + (24*24)*1
     3*3     4*4     5*5         24*24     2*2          1*1
The above is my understanding.
However, I found that the result is less than 180,000.
Can some one tell me what's wrong with my calculation?

Reply | Threaded
Open this post in threaded view
|

Re: Re: Number of haar features

xiaoc10
My first reply is not right. Let's consider every haar feature.
1) As for the first haar feature.
The least size of this feature is 1*2. So, the number of this size in
24*24 is 24*23. And then we consider the size 1*4, the number of this size
is 24*21. Next, the
size can be 1*6, 1*8, ..., 1*24. And their corresponding number of haar
feature is 24*19, 24*17, ...
,24*1. The total is 24*(1+3+..+23) = 3456.//1+3+...+23 = 12^2
If we add size along vertical orientation, we can have size 2*2, the number
of this type is 23*23. And next,
2*4->23*21, 2*6->23*19, ..., 2*24->23*1. The total is 23*(1+3+...+23) =
 3312.
We still add size along vertical orientation, we can have size 3*2, the
number of this type is 22*23, And next,
3*4->22*21, 3*6->22*19, ..., 3*24->22*1. The total is 22*(1+3+...+23) =
3168.
...
...
...
The total number of first haar feature is 24*12^2 + 23*12^2 + ... + 1*12^2 =
12^2*(1+...+24) = 43200.

2) since the first haar feature and the second haar feature is symmetrical
and the windown(24*24) is square,
so the total number of second haar feature is also 43200.

3) the third rectangle feature
The least size is 1*3->24*22, and then 1*4->24*21, 1*5->24*20, ...,
1*24->24*1. The total is 24*(1+2+...+22) = 6072
We add the size along vertical orientation, so we can have size 2*3->23*22,
..., 2*24->23*1. The total is 23*(1+2+...+22) = 5819
...
...
The total is (24+23+...+1)*(1+2+3+...+22) = 75900.

4) the fourth rectangle feature
The least size is 2*2->23*23, and then 2*4->23*21, 2*6->23*19, ...,
2*24->23*1. The total is 23*(1+3+...+23)
...
...
...
The total is (1+3+...+23)*(1+3+...+23) = 20736.

All in All, 75900+20736+43200*2 = 183036.

The above is my understanding. It's so long. :)..




2009/8/23 zhangzhonginuta <[hidden email]>

>
>
> --- In [hidden email] <OpenCV%40yahoogroups.com>,
> "sabatier_sabrika" <sabatier.sabrika@...> wrote:
> >
> > Hi,
> >
> > In the original Viola Jones paper on face detection, they say there are
> more than 180,000 haar features in a 24x24 subwindow.
> >
> > Anyone know how this is calculated?
> >
> Hi,
> According to my understanding, the calcaulating process is as follows:
> As for a 24*24 window, there are twenty-three types of subwindow.(2*2, 3*3,
> 4*4, 5*5, ..., 24*24).
> Let's pick up 4*4(A) for example. In the 24*24 subwindow, the number of
> A(4*4) is 21*21(441). Every A has four haar features. So we can get
> 441*4(1764) haar features for 4*4.
> So, (22*22 + 21*21 + 20*20 +...+ 1*1)*4 + (23*23)*3 + (24*24)*1
> 3*3 4*4 5*5 24*24 2*2 1*1
> The above is my understanding.
> However, I found that the result is less than 180,000.
> Can some one tell me what's wrong with my calculation?
>
>  
>


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|

Re: Re: Number of haar features

James Yan
hey,

i think your reply is not correct ( so i think Paul Viola's 180,000 not
correct niether :D )
yes, your counting on haar feature #1, #2, #4 is correct, but it looks
something wrong with #3:

" The least size is 1*3->24*22, and then 1*4->24*21, 1*5->24*20, ...,1*24->
24*1. The total is 24*(1+2+...+22) = 6072 "

where, 1*4 seems not a reasonable rect for haar feature #3, the reasonable
rect should be 1*3, 1*6, 1*9, 1*12 ... (think about only symmetrical
features, the blocks in the feature should have same size.)

so, the number for haar feature #3 = 27600, not 75900, and total is :
134736, not >180000.

in fact it's easy to counting those features with a computer:

       #define feature_type_num 4
       int i,x,y,w,h,det_size = 24;
       int v_block_num[feature_type_num ] = {1,2,1,2}; // blocks num on
vertical
       int h_block_num[feature_type_num ] = {2,1,3,2}; // blocks num on
horizatonal

        int k = 0;
for(i=0;i<feature_type_num;i++)

{

for(y=0;y<=det_size - v_block_num[i];y++)

{

for(x=0;x<=det_size - h_block_num[i];x++)

{

for(h=v_block_num[i] - 1;y+h<det_size;h+=v_block_num[i])

{

for(w=h_block_num[i] - 1;x+w<det_size;w+=h_block_num[i])

{

k++;

}

}

}

}

}

On Mon, Aug 24, 2009 at 12:43 PM, 重张 <[hidden email]> wrote:

>
>
> My first reply is not right. Let's consider every haar feature.
> 1) As for the first haar feature.
> The least size of this feature is 1*2. So, the number of this size in
> 24*24 is 24*23. And then we consider the size 1*4, the number of this size
> is 24*21. Next, the
> size can be 1*6, 1*8, ..., 1*24. And their corresponding number of haar
> feature is 24*19, 24*17, ...
> ,24*1. The total is 24*(1+3+..+23) = 3456.//1+3+...+23 = 12^2
> If we add size along vertical orientation, we can have size 2*2, the number
> of this type is 23*23. And next,
> 2*4->23*21, 2*6->23*19, ..., 2*24->23*1. The total is 23*(1+3+...+23) =
> 3312.
> We still add size along vertical orientation, we can have size 3*2, the
> number of this type is 22*23, And next,
> 3*4->22*21, 3*6->22*19, ..., 3*24->22*1. The total is 22*(1+3+...+23) =
> 3168.
> ...
> ...
> ...
> The total number of first haar feature is 24*12^2 + 23*12^2 + ... + 1*12^2
> =
> 12^2*(1+...+24) = 43200.
>
> 2) since the first haar feature and the second haar feature is symmetrical
> and the windown(24*24) is square,
> so the total number of second haar feature is also 43200.
>
> 3) the third rectangle feature
> The least size is 1*3->24*22, and then 1*4->24*21, 1*5->24*20, ...,
> 1*24->24*1. The total is 24*(1+2+...+22) = 6072
> We add the size along vertical orientation, so we can have size 2*3->23*22,
> ..., 2*24->23*1. The total is 23*(1+2+...+22) = 5819
> ...
> ...
> The total is (24+23+...+1)*(1+2+3+...+22) = 75900.
>
> 4) the fourth rectangle feature
> The least size is 2*2->23*23, and then 2*4->23*21, 2*6->23*19, ...,
> 2*24->23*1. The total is 23*(1+3+...+23)
> ...
> ...
> ...
> The total is (1+3+...+23)*(1+3+...+23) = 20736.
>
> All in All, 75900+20736+43200*2 = 183036.
>
> The above is my understanding. It's so long. :)..
>
> 2009/8/23 zhangzhonginuta <[hidden email]<zhangzhonginuta%40yahoo.com>
> >
>
> >
> >
> > --- In [hidden email] <OpenCV%40yahoogroups.com> <OpenCV%
> 40yahoogroups.com>,
>
> > "sabatier_sabrika" <sabatier.sabrika@...> wrote:
> > >
> > > Hi,
> > >
> > > In the original Viola Jones paper on face detection, they say there are
> > more than 180,000 haar features in a 24x24 subwindow.
> > >
> > > Anyone know how this is calculated?
> > >
> > Hi,
> > According to my understanding, the calcaulating process is as follows:
> > As for a 24*24 window, there are twenty-three types of subwindow.(2*2,
> 3*3,
> > 4*4, 5*5, ..., 24*24).
> > Let's pick up 4*4(A) for example. In the 24*24 subwindow, the number of
> > A(4*4) is 21*21(441). Every A has four haar features. So we can get
> > 441*4(1764) haar features for 4*4.
> > So, (22*22 + 21*21 + 20*20 +...+ 1*1)*4 + (23*23)*3 + (24*24)*1
> > 3*3 4*4 5*5 24*24 2*2 1*1
> > The above is my understanding.
> > However, I found that the result is less than 180,000.
> > Can some one tell me what's wrong with my calculation?
> >
> >
> >
>
> [Non-text portions of this message have been removed]
>
>  
>


[Non-text portions of this message have been removed]