Training cascade classifier- need some clarification [closed]

asked 2015-02-13 00:10:14 -0600

jamesnzt gravatar image

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).

  1. I put the positive and negative samples in separate folders.
  2. I created two txt files with path and name of file.
  3. 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"

image description

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 image description

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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by jamesnzt
close date 2015-02-13 04:32:52.394438

Comments

1

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?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-13 03:49:02 -0600 )edit
1

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

jamesnzt gravatar imagejamesnzt ( 2015-02-13 04:31:59 -0600 )edit
1

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 gravatar imageStevenPuttemans ( 2015-02-13 04:35:15 -0600 )edit

@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?

jamesnzt gravatar imagejamesnzt ( 2015-02-17 11:52:25 -0600 )edit

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.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-17 12:52:09 -0600 )edit