Sarang Rakkecha
Sarang Rakkecha

Reputation: 11

Haar- Cascade object detection OpenCV - .xml file classifier not detecting properly

I have used the same parameters used in this tutorial.

perl bin/createsamples.pl positives.txt negatives.txt samples 1500\ "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1\ -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"

BUT changed the numPos parameter as it gave me an error of insufficient positive images.

ALSO had decreased the stages as it was below the desired accuracy rate(should be less than 0.0004) and mine was 0.0002. Used these parameters.

opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt -numStages 16 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 880 -numNeg 600 -w 80 -h 40 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

Got my cascade.xml file, but still not detecting properly. cascade.xml file took 3 days for processing.(Image attached) Have used Opencv3.1.0 Please help!!!

IMAGE detected by classifier(Click to see)

Upvotes: 0

Views: 670

Answers (1)

D.U
D.U

Reputation: 126

What is the reason for using the parameter -bgthresh 0. From what I know the standard setting is 80, there is no reason to change parameters if you don't know what they do. Read up on that.

BUT changed the numPos parameter as it gave me an error of insufficient positive images.

Have you checked that you really have 1500 positives, verify this together with the lines in your positives.txt file.

-numPos 880 -numNeg 600

Different opinions here, I recommend amount of neg = positives*2.

but still not detecting properly

What do you mean? What do you define as "properly"? From the example you provide I can see a proper detection with a possible false positive (the rectangle in the middle). Increase minNeighbors (in your code) – Parameter specifying how many neighbors each candidate rectangle should have to retain it.

Upvotes: 1

Related Questions