Ask Your Question

Revision history [back]

Unable to train an usable cascade

I'm trying to detect a pattern using opencv_createsamples and opencv_traincascade, but i cant get it to work..And i dont know what i am doing wrong. The pattern to detect could be just anything, as it'll be printed and sheets of paper containing the pattern is what the final application should detect. So, i just create a sample pattern with gimp (some coloured circles), and save it (w:400, h:400) Then, from than single image, i use the following command line to create positives:

opencv_createsamples -img pos/1.png -bg newNeg.txt -maxxangle .15 -maxyangle .15 -maxzangle .15 -num 1000 -vec positives.vec -w 40 -h 40

As background, i use random photos (with random sizes), and run the trainer with:

opencv_traincascade -precalcValBufSize 2048 -precalcIdxBufSize 2048 -data data -vec positives.vec -bg newNeg.txt -numStages 7 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 400 -numNeg 800 -w 40 -h 40 -featureType LBP

The problems are: - The train process takes just 10 seconds.It ends at Stage two (max, stage three, depending on if i use LBP or HAAR) - Looks like just 1 feature is being used. - The cascade file is about 2K

Maybe, being such a simple object, that is right...But then, testing the cascade with an image containing the pattern (200x200) and trying to detect it with

detectMultiScale(frame, results, 1.1, 3, 0, Size(100, 100));

the results collection contains 50 matches!

What am i doing wrong?