OpenCV 3.1: Train dataset for temp stage can not be filled. on 1-Stage

1.4k Views Asked by At

it's a common error, but i have searched for an answer and try many suggestions, but nothing works. I use opencv 3.1 on my windows (10) system want to train a system for recognition of playmobil figures. i have a bunch of 118 positive images of different playmo figures and i have nearly 3000 negative images. All converted into pgm format. Positive images are 64x128, negative images are sized max. 256x256. (I have he original files, too) I started training with this parameters:

opencv_traincascade.exe -data classifier -vec playmobil.vec -bg negative.txt -numPos 110 -numNeg 1000 -numStages 3 -w 24 -h 48 -minHitRate 0.999 -maxFalseAlarmRate 0.5

0-Stage works like charm, got this as output:

E:\temp\train>..\opencv3\build\x64\vc14\bin\opencv_traincascade.exe -data classifier -vec playmobil.vec -bg negative.txt -numPos 110 -numNeg 1000 -numStages 3 -w 24 -h 48 -minHitRate 0.999 -maxFalseAlarmRate 0.5
PARAMETERS:
cascadeDirName: classifier
vecFileName: playmobil.vec
bgFileName: negative.txt
numPos: 110
numNeg: 1000
numStages: 3
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 48
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

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

But at 1-stage training stops with the message:

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

I have tried many different parameter. With more or less negative images. Nothing works. Any other ideas?

1

There are 1 best solutions below

0
On

Your problem seems to be related to your training parameters.

When training a cascade it might happen that a positive sample is dropped for further processing (as well as negatives). The problem now is that you specified numPos to be 110, i.e. all of your positive samples.

When said thing happens and a positive sample can't be used for further processing, the cascade classifier tries to replace the dropped sample by a new one. Since you already fed all your positive samples into the pipeline, it can't replace the dropped ones and exits.

So you should try to re-run the training with a lower value for numPos.

For a more detailed explaination, check this link