Reputation: 587
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?
Upvotes: 2
Views: 569
Reputation: 708
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)
.
Upvotes: 3