Training cascade classifier- need some clarification [closed]
I followed the tutorial in the Link I new in working with cascade classifier. So i tried training with 10 positive and 6 negative images for first time ( I read that it is not enough and for robust detection we need to train minimum of 500 samples).
- I put the positive and negative samples in separate folders.
- I created two txt files with path and name of file.
I created the .vec file using
"C:\opencv\build\x86\vc10\bin\opencv_createsamples.exe -info positivenew.txt -vec samples.vec -w 50 -h 35 PAUSE"
4) I verified the samples using
C:\opencv\build\x64\vc10\bin\opencv_createsamples.exe -vec samples.vec -w 50 -h 35 PAUSE
all works well upto this stage.
5) when i train the classifier using
C:\opencv\build\x64\vc10\bin\opencv_haartraining.exe -data class -vec samples.vec -bg Negativenew.txt -npos 10 -nneg 6 -nstages 7 -nonsym -minhitrate 0.998 -maxfalsealarm 0.5 -mem 1024 -mode ALL -w 50 -h 35
the following process was done
The output in the class directory contains many folders with names from 0,1,2,3...6 with files "AdaBoostCARTHaarClassifier.txt " with the content like this
1
1
3
0 0 2 16 0 -1
0 0 1 8 0 2
1 8 1 8 0 2
haar_x2_y2
6.744434e-004 0 -1
1.000000e+000 -1.000000e+000
1.000000e+000
0
-1
but no *.xml file is found in output directory. Where did i do the mistake? Please help me in this.
Aaagh my eyes ... we should seriously consider removing that haartraining interface completely. Ok serious now ... start by skipping haartraining interface which is only there for legacy purposes and move the the newer, faster and better traincascade interface which can also use HAAR wavelet features. As to your problem, if there is no xml file yet than your training did not finish correctly. What was the last output generated?
Thanks @StevenPuttemans I tried the traincascade.exe it works . Due to less number of training data there are more than 20 false detection in the given image. Thanks again
Yeah low amounts of data will not yield good results. What you could do is use your classifier to mine for hard negatives now and use that to increase the detection rate. But that is only if your detector succeeds in finding positive objects. If not, then you also need more positive data.
@StevenPuttemans I tried with increased number of positive samples(i.e. i tried with 70 positive samples and 22 negative samples) I got the trained xml file. But it didn't work in the program. while again i tried training with equal number of samples(22 positive and 22 negative) now it works and false detection is reduced. Is there any ratio of positive and negative samples so that the classifier works?
The idea is that the ratio of positives to negatives is about 1 to 10 to have a robust classifier, but it all really depends on your background conditions of your application.