1 | initial version |
let me try to explain usage of train_HOG.cpp
what we need to prepare
1. we need positive samples gathered in a directory (as much as we have positive samples we can train a better detector)
here is some good positive image samples from INRIA Person Dataset cropped for train a HOG detector which has 64x128 window size
2. we need Images don't include objects that we want to detect gathered in a directory ( for beginning i advise negative image count should not be less than positive images count)
like the image below ( also taken from INRIA Person Dataset (it has pedestrians but they are too small according to 64x128 window size ))
lets suppose you put positive samples in c:/pos
and negative images in c:/neg
here is some possible cmd line parameter usage
cpp-example-train_HOG -pd=c:/pos -nd=c:/neg
if all your positive samples have the same dimension you will get my_detector.yml
winSize is calculated according to your pos images size (96x160 for positive images above ) using the line below
pos_image_size = pos_image_size / 8 * 8;
lets add -dw -dh params like
cpp-example-train_HOG -dw=64 -dh=128 -pd=c:/pos -nd=c:/neg
now we specified winSize as 64x128 but our positive images are 96x160 so the program uses central 64x128 rect for training
Rect r = Rect(( img_lst[i].cols - wsize.width ) / 2,
( img_lst[i].rows - wsize.height ) / 2,
wsize.width,
wsize.height);