Ask Your Question

negative images used for training

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

omerjerk gravatar image

updated 2014-07-09 07:46:52 -0500

I'm pretty new to OpenCv. I'm using this method : 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

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

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


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 -0500 )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 -0500 )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 -0500 )edit
Login/Signup to Answer

Question Tools


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

Seen: 1,849 times

Last updated: Jul 09 '14