Negative samples for training cascade object detector
3 次查看(过去 30 天)
显示 更早的评论
Currently I am experimenting with training a cascade object detector (2017a version) and I am wondering about how the negative samples are generated from the negative images. I want to detect different types of push buttons on i.e. automotive steering wheels, so for the negative images i am using the positive images with the buttons cropped out (basically drawing a mono colored rectangle on top).
Both my original image and the negative image currently have a size of 4034x3024 pixel, and the size of positive instances is set to 30x32 automatically. What would a negative sample look like in this case? Does it randomly extract a 30x32 region as a negative sample from the negative images or would it also pick a larger area (possibly the entire image) and resize it to 30x32 pixel? If it was the latter case, I would prefer using blockproc to cut the image into smaller tiles and feed as negative data so I can easily omit the areas where buttons are located. Another benefit is that I can easily integrate negative samples I do not want the detector to confuse with buttons like automotive brand symbols.
I would appreciate any information on how it works.
Jimmy
1 个评论
Rummy18
2018-7-12
编辑:Rummy18
2018-7-12
Facing the same question...do we have a clear answer now? According to the documentation "training a cascade object detector", "the function runs the detector consisting of the stages already trained on the negative images. Any objects detected from these image are false positives...". Let's assume we have the large image mentioned in your question above (4034x3024 pixel). The detector is 30x32 pixel. The "trainCascadeObjectDetector" includes the input argument "ObjectTraningSize". It says, "before training, the function resizes the positive and negative samples to ObjectTrainingSize in pixels", i.e. to 30x32 pixels. The negative image and the detector now have the same size, they perfectly fit on top of each other, right? Hence, the detector checks only once whether it can find the desired object or not. This would mean that large images should be cut into smaller tiles to improve the negative samples, as the detector does not slide over the whole large image. Is this correct?
And a second question: If we have 100 negative images in our negative database and the training says "using at most 50 negative samples per stage". Does it mean, that 50 negative images are randomly selected from the database, giving the chance to use the images 51-100, or does it just use the images 1-50 for the whole training?
Thank you!
回答(1 个)
Nachiket Katakkar
2017-6-1
Hi Jimmy,
I think that your understanding is accurate in that it seems to randomly select 30x32 sized regions from negative samples. The example shown here contains 42 positive images and only 5 negative images:
https://www.mathworks.com/help/vision/ref/traincascadeobjectdetector.html?s_tid=srchtitle#responsive_offcanvas
However, while training, since the "NegativeSamplesFactor" is set to 2 by default, it creates 84 negative samples from the 5 negative images.
You should be able to create further negative samples by omitting the buttons and place them in the negativeImages folder so that it does not obtain false positives. You have further control over the size of the trained object using the "ObjectTrainingSize" Name-Value pair.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!