Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Its really awesome that you made your own tool. Let me clear the air about opencv_createsamples. See if it helps.

You need to use the opencv_createsamples utility on each of the positive images (you have to pass image and not info.dat) and create 5 new images with different (random) distortions (perspective and intensity). You can skip bg file (A black background will be used if you do). This will create a vec file for each of the image with the distortions. Then you should use the mergevec.cpp to merge these vecs into one. Kindly look at the tutorial for more info about this merging of vec files. (You will have 109 vec files and 109*5 positive samples if you use -num 5)

Note : These images created are not a perfect substitute for the lack of original images. They seem to work but they cant capture all of the "variance" in the positive class. It will work the best when you have 600 natural positive images.


  • Use createsamples utility to generate the vec file for each image with random distortions
  • Merge these vec files using mergevec.cpp provided here along with instructions.
  • Put the path of negative images (relative to bg.txt) in bg.txt
  • Pass the final (merged) vec file, bg.txt, and the rest of the parameters (like feature type, stages, falseAlarm Rate, HitRate, etc.) to traincascade to train.

But once again, It was really nice that you put time into it and solved it in a different way.

If you need any more clarifications, comment below. Glad to help.


Prasanna S

PS : We need that guide soon, @Steve. People are losing hope on opencv_createsamples utility :( . Hope the developers' feelings aren't hurt.