Ask Your Question
1

negative images used for training

asked 2014-07-09 07:45:30 -0600

omerjerk gravatar image

updated 2020-10-27 05:26:44 -0600

I'm pretty new to OpenCv. I'm using this method : https://github.com/mrnugget/opencv-haar-classifier-training to train my classifier. Right now I'm just testing if everything works so I'm using 18 positive samples and only 1 negative sample. Since I'm just testing if everything works, I just want to detect my TV remote (I used the images of my TV remote as positive samples). And the 1 negative image which I used was the image of my mattress on which the TV remote is lying. I want to ask am I heading in the right direction using only 1 negative sample i.e. image of my mattress on which TV remote is lying ? If not, what should we actually use as negative samples.

Please consider me having no knowledge of algorithms being used here. I'm just reading over the internet.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-07-09 07:58:52 -0600

Basically you need to destinguish how OpenCV handles positive and negative image samples.

For the positive image samples OpenCV uses a file format like this: filename number_detections x1 y1 w1 h1 ... This means that you need to make an annotation file, in which you have defined which regions of your large image can be taken as positives. For each picture you make a new entry in that text file.

For the negative image samples OpenCV just wants a text file that sums op negative background images. The big difference is that resolution is not important here. At training time, the algorithm will grab your width and height parameter and use a sliding window approach over the negative images until it can grab as much negative samples (windows in this case) as you requested with the numNeg parameter. It does some sort of matching between samples to ensure that they are different enough so that training actual results in good models.

So YES 1 negative image can help, but use for model size w and h, for example 40 x 80 and supply a negative image of 400 x 800 resolution giving your algorithm the change to grab more than 1000 negative samples from that single image.

edit flag offensive delete link more

Comments

Thanks a lot. It cleared my doubts. Another question is can I just take the cropped image of my TV remote and using "image_name.jpg 1 0 0 <width> <height>" as the entry in my file or is it better to have an image in which the TV remote takes only part of the image ?

omerjerk gravatar imageomerjerk ( 2014-07-09 08:05:37 -0600 )edit

well the idea is that this should do the trick but as already reported there is a bug in the software, so from the moment that fix gets merged you will be able to do that! Now the sample will be ignored....

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-09 11:39:18 -0600 )edit

Second guess is that the patch is actually at detection phase so for training it should actually work!

StevenPuttemans gravatar imageStevenPuttemans ( 2014-07-09 11:40:28 -0600 )edit

Question Tools

Stats

Asked: 2014-07-09 07:45:30 -0600

Seen: 2,506 times

Last updated: Jul 09 '14