Is OpenCV supposed to train on positives or samples images?
In one of my questions discussed here here there's the problem that OpenCV recognizes the object to detect only in training images. Up to today I have listened to discordant points of view: how does the .vec file have to be created? Does it need to contain only positive images (cropped images showing ONLY the interested object) or samples images (interested object with random background)?
If it needs to contain only the cropped interested object, on which images does opencv_traincascade
have to train?
I read and read this tutorial over and over but I still don't understand which is the correct way to proceed...would anyone explain me?
In my opinion (for what it worth), the general (safe) method should be:
opencv_createsamples
only to create the vec file foropencv_traincascade
(no warping, no backrgound combination)Warping is not good as it is only a mean to create artificially a lot more images that could be different from reality.
In the question you linked, you generated too much warped images (-num 210) from only 60 real cropped images of coins.
You should start to train with only the 60 cropped images and see what happens (test, retry until satisfactory results).
Yes, yesterday night I launched
opencv_createsamples -vec i.vec -w 48 -h 48 -num 210 -img ./positives/i.jpg -maxidev 100 -maxxangle 0 -maxyangle 0 -maxzangle 0.9 -bgcolor 0 -bgthresh 0
(for i from 0 to 60)So, as you can see I did not generate any warped image and I launched
opencv_traincascade
with LBP mode. But this does not work too...nothing is detected@Eduardo: can I write you by email? Only if I don't annoy you...
@Lory, if we put effort into helping you and providing your with guidelines, then please keep the discussion to this forum and not on a 1 by 1 basis with one of the people helping out. The ultimate goal for this forum is people that tend to find solutions on the base of already existing questions ...
Your command generates 209 new artificially images (what I called a warped image) with rotations around the Z-axis (documentation). And at the end you have 12000 positive images with only 60 images that are real that is not good at all in my opinion.
Try the easiest first by using only your real cropped images. Test and retry by adding / removing positive or negative images until you have satisfactory result.
PS: you should follow the advice of StevenPuttemans as he mostly works on this subject for his research.