2

I am implementing Viola-Jones face detector to detect faces in still images and it work preety for images having same size as of my training size. However I am not getting how the face detector work for multiple size faces?

If the training size of my images is 24*24 and if I want to detect faces in detector window of 30*30 how I need to rescale the haar-feature so that it will work for 30*30 size detector window working with the same threshold.

One more thing, do the position of Haar-feature also changes with different size detector window and if yes how?

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114
user2766019
  • 577
  • 4
  • 7
  • 20

1 Answers1

3

Say you're representing a rectangle found inside a Haar wavelet with x, y, w and h variables where x and y represent to top left corner of the rectangle relative to the detector's top left boundaries, w its width and h its height. You can rescale the whole detector by a factor s each Haar wavelet rectangle with the following pseudo-code:

for all rectangle i in the Haar wavelet do
    tempRectangle = rectangle[i];
    tempRectangle.x = tempRectangle.x * s
    tempRectangle.y = tempRectangle.y * s
    tempRectangle.h = tempRectangle.h * s
    tempRectangle.w = tempRectangle.w * s

    //Read the pixels contained in tempRectangle region and
    //calculate this rectangle's contribution to the feature value
    //considering the respective weight of rectangle[i].
end for

So, let's assume that a single Haar-lke feature has the base size of 24x24 pixels. Such feature is composed of 2 rectangles r1=(10,15,8,4) and r2=(4, 8, 8, 4), where r=(x,y,w,h). When you rescale your detector by a factor s=1.25, this feature rectangles should become r1=(12.5, 18.75, 10, 5) and r2=(5, 10, 10, 5).

Ramiro
  • 698
  • 6
  • 21
  • 1
    Hi, you mean, if for 24*24 detector window my haar-feature of (x,y,w,h)=(10,15,8,4) then if I increment detector window by 1.25 then haar feature value becomes (x,y,w,h)=(12.5,18.75,10,5). Is that so? – user2766019 Oct 02 '13 at 19:58
  • Can you please elaborate it by example. Thanks! – user2766019 Oct 02 '13 at 20:17
  • Can you please elaborate it by example. What does this mean 'calculate this rectangle's contribution to the feature value'? – user2766019 Oct 02 '13 at 20:48
  • I edited the answer to give a more detailed example. The comment about "calculate this rectangle's contribution..." is just a statement that normal Haar-like feature value calculation could happen where the comments were put if you are rescaling the detector at the same time as calculating the Haar-like feature value. If all you want is to rescale the detector window and its features, you may simply ignore those comments. – Ramiro Oct 02 '13 at 21:00