How to do HAAR training?

asked 2016-11-08 13:30:52 -0600

updated 2016-11-09 04:22:33 -0600

I've been trying to achieve object detection of random objects using HAAR training. To create samples i used the parameters:

C:\opencv\build\x64\vc12\bin\opencv_createsamples.exe -info positivesBottle.txt -vec samplesBottle.vec -num 444 -w 50 -h 80

And then i trained the cascade using the parameters:

C:\opencv\build\x64\vc12\bin\opencv_traincascade.exe -data testclassifier -vec samplesBottle.vec -bg negativeBottle.txt -numPos 300 -numNeg 1000 -featureType LBP -numStages 11 -w 50 -h 80

but i keep getting this at the end that the 'Train dataset for temp stage can not be filled. Branch training terminated.'

stageType: BOOST
featureType: HAAR
sampleWidth: 50
sampleHeight: 80
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   50 : 50
NEG count : acceptanceRatio    100 : 1
Precalculation time: 7.79
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>
Training until now has taken 0 days 0 hours 1 minutes 1 seconds.

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   50 : 50
Train dataset for temp stage can not be filled. Branch training terminated.

Is there any solution for this? i even increased decreased the number of positives and negatives, and even the minHitRate and changing any other parameter i could.

edit retag flag offensive close merge delete

Comments

That training output is impossible when using the train command above. While you state -numPos 300 and -numNeg 1000, it takes completely different values. So can you add the correct info please? Also make sure you copy the complete output. There is a part missing about the assigned memory to the process.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-11-09 04:24:43 -0600 )edit

sorry i might have mixed up with the folders. I tried again with a different data set, i took round about 4000 pos and neg samples. but on upon running the traincascade command.

opencv_traincascade.exe -data VaseClassifierNew -vec VaseVector.vec -bg vasenegativeNew.txt -numStages 10 -minHitRate 0.900 -numPos 800 -numNeg 400 -w 45 -h 80 -featureType LBP -precalcValBufSize 1024 -precalcIdxBufSize 1024

it loads stage 0 : POS count : consumed 800 : 800 NEG count : acceptanceRatio 400 : 1 Precalculation time: 23.72 +----+---------+---------+ | N | HR | FA | +----+---------+---------+ | 1| 1| 0|

but on stage 1 gives error: Train dataset for temp stage can not be filled. Branch training terminated.

Hashim Naveed gravatar imageHashim Naveed ( 2016-11-17 03:42:52 -0600 )edit

I viewed the pics on the .vec file, and they are correct. so i dont know where the problem is, maybe with the negatives, but i tried different negatives as well, still no luck

Hashim Naveed gravatar imageHashim Naveed ( 2016-11-17 03:45:01 -0600 )edit