Opencv_traincascade always gets stuck

I am trying to use OpenCV opencv_traincascade to generate Haar cascade. So far, I have 87 distinctive positive samples and 39 negative samples for testing purposes. I generated a .vec file with opencv_createsamples which worked fine. When I run opencv_traincascade, it always gets stuck after multiple steps, no matter how I change the options. My call looks like this:

opencv_traincascade -data /opencvimgs/haarcascades/data/ -vec /opencvimgs/haarcascades/out.vec -bg /opencvimgs/haarcascades/neg.txt -numPos 87 -numNeg 39

      

I have tried increasing and decreasing minHitRate and maxFalseAlarmRate as well as numPos and numNeg without any success. It can run for a few more stages, but then it seems to hang again in an infinite loop. How can I solve this?

Below is the output that the program writes to the console:

opencv_traincascade -data /opencvimgs/haarcascades/data/ -vec 
/opencvimgs/haarcascades/out.vec -bg /opencvimgs/haarcascades/neg.txt -numPos 87 -numNeg 39
PARAMETERS:
cascadeDirName: /opencvimgs/haarcascades/data/
vecFileName: /opencvimgs/haarcascades/out.vec
bgFileName: /opencvimgs/haarcascades/neg.txt
numPos: 87
numNeg: 39
numStages: 20
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 1
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.0697674
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.00945455
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   87 : 87
NEG count : acceptanceRatio    39 : 0.000326907
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   87 : 87

      

+3


source to share


1 answer


A possible answer is that you are using too few negative samples. Read the instruction from the OpenCV docs and the reference article from Viola and Jones. They use a cascade classifier to achieve high accuracy and low false positives, eliminating a fraction of the negative samples every time. If you use too few negative samples, it primarily deprives the purpose of the cascading classifier. Note that for practical use, the system has many more images without faces than with faces.



+2


source







All Articles