Reputation: 1
I have collected 1000 positive(50*50) images and 1000 negative(50*50) images and trained Haar Cascade in OpenCV. I am trying to detect mobile phones. code for training :
opencv_traincascade -data data -vec crop1.vec -bg mob_neg.txt -numPos 900 -numNeg 900 -numStages 15 -w 50 -h 50 bgcolor 255 -bgthresh 100
cascade is unable to detect mobile accurately (it is detecting mobile as well as many other objects like mouse, key, wallet,hand etc.) can you help me fixing this problem I took images of phone through camera using burst mode. captured positive images through different angles and different rotations Negative images are taken from internet.
what should I do to increase cascade accuracy??
should I change size of positive or negative images? Thanks in advance
Upvotes: 0
Views: 8655
Reputation: 1
I think you need to squeeze your criteria a bit while training your haar cascade:
-miniHitRate
-maxFalseAlarmRate
are set to 1 by default, squeeze them to 0.5 or even further down to get a more accurate cascade. try:
opencv_traincascade -data data -vec crop1.vec -bg mob_neg.txt -numPos 850 -numNeg 900 -numStages 15 -miniHitRate 0.5 -maxFalseAlarmRate 0.5 -w 50 -h 50 bgcolor 255 -bgthresh 100
Upvotes: 0
Reputation: 1237
I'm very much a novice but found this article helpful:
https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/
In it the author mentions a rule of thumb of using twice as many positives as negatives. He also discusses a method for generating the positive images by overlaying the positive image(s) over the negative images using opencv_createsamples
(which also rotates the positive image for you).
He is also scaling the negatives and converting them to grayscale prior to positive image sample generation and training.
I hope this is helpful.
Upvotes: 1