Problem with Cascade Classifier
I've problems with the Cascade Classifer. I created 5000 positive samples like this:
with this command:
C:\OpenCV31\opencv\build\x64\vc14\bin\opencv_createsamples.exe -img C:\CreateSamples\test\image6.jpg -vec gew.vec -bg neg.txt -num 5000 -w 80 -h 80 -show -maxyangle 0.0 -maxzangle 0.0 -maxxangle 0.5 -bgcolor 0
then i trained a classifier like this:
C:\OpenCV31\opencv\build\x64\vc14\bin\opencv_traincascade.exe -data NEWclassifier -vec gew.vec -bg neg.txt -numStages 15 -numPos 2500 -numNeg 1500 -w 80 -h 80 -precalcValBufSize 4048 -precalcIdxBufSize 4048 -featureType LBP
and get this result:
The Problem is: it detects nearly everything as an object:
I used this image:
and get this:
I'm new with Cascade Classifier and read a lot of tutorials and samples, but i don't get my mistake. Can you help me?
I call detectMultiscale like this: face_cascade.detectMultiScale(frame_gray, faces, 1.1, 0, 0, cv::Size(10, 10));
It seems like you generate your positive image samples (5000) from only one image. In general, it is not good. It is better to use real positive images. Also, your negative image samples should be various.
Training a cascade of classifiers is a try and retry process to get a good training set.
How you call detectMultiscale() when get such results? Paste a code here! Maybe you have set min neighbours to zero?
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 0, 0, cv::Size(10, 10));
setting a higher value for min_neighbours will remove a lot of your false positives
so, if minNeighbours is equal to zero opencv returns all the rects that was found on detection, try to increase this value to 5 / 7 / 11 /...
Thank you very much! I've now taken samples from a video and optimized minNeighbours and min Size. It works very well.
Still, it shouldn't detect everything on the screen right? Why would that happen?