Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV createsamples and traincascade parameters (width and height)

Tags:

opencv

I'm trying to create training samples (and subsequently train a classifier). I'm confused about the -h and -w parameters used in createsamples and traincascade. The examples I'm seeing typically use small values for these but my training images (negative and positive) are significantly larger (480x640) with the object I'm training for typically occupying 75-100% of the image. It appears that these parameters are not asking about the size of the images (which it could simply pull from the images) but I suspect that it's also not asking for the size of the object in the image. If I have to guess (and I would rather not), larger sizes might result in better detection accuracy, but would increase computational load during training.

Can someone please describe what these parameters actually mean? Most examples I've seen use the defaults of 24x24 or upwards of 40x40, but never much higher as far as I can see.

like image 372
Cj S. Avatar asked Feb 28 '13 14:02

Cj S.


1 Answers

These small image values are the positives (the objects) that you want to train the classifier for. The object in your real frame might have an arbitrary size, because the cascade classifier works for various scales of the image.

Here is a good tutorial that helped me when I was training my own classifier. Your cropped images used for training might be bigger in size, but when you run createsamples you need to specify a size in which the positive textures are scaled. These new tiny samples are those that are used for the classifier. This also affects the speed of the cascade classifier, that's why they are tiny in size usually.

The background images can be bigger in size if I'm not mistaken, but I remember I was still cropping the background images I had in smaller pieces.

When your run your classifier with your real 640x480 data, you specify limits of the minimum size a positive can have (of course this value should be at least the size of the -w -h you specified before) and also the maximum expected size.

The haar detector will search for objects only in that range of windows in your test image that can be as big as you want.

like image 170
George Aprilis Avatar answered Sep 28 '22 10:09

George Aprilis