Ask Your Question
0

traincascade - Train dataset for temp stage can not ...

asked 2015-03-23 18:45:59 -0600

Barry gravatar image

updated 2015-03-26 23:06:15 -0600

Hello, I'm going nuts trying to get opencv_traincascade to work. It always stops with the error:

Train dataset for temp stage can not be filled. Branch training terminated

I'm using OpenCV 2.4.11 on a Windows 7 64-bit machine. I've used the distribution exe from the x64 VC12 directory. I've also recompiled from source code using Visual Studio 2012. I get the same results either way.

The command line I'm using is below. Test1 is my compiled version of traincascade.

test1 -data cscd -vec out/samples.vec -bg bgt.txt -numPos 5 -numNeg 1200 -numStages 10
  -featureType HAAR -minHitRate 0.999 -maxFalseAlarmRate 0.5 -w 24 -h 24
  -precalcValBufSize 2048 -precalcIdxBufSize 2048

The output I receive is:

PARAMETERS:
cascadeDirName: cscd
vecFileName: out/samples.vec
bgFileName: bgt.txt
numPos: 5
numNeg: 1200
numStages: 10
precalcValBufSize[Mb] : 2048
precalcIdxBufSize[Mb] : 2048
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: BASIC

Stages 0-2 are loaded

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   5 : 21
310: numNeg 1200, posCount 5, numPos 5, proNumNeg 1200, negConsumed 1024, negCount 0
Train dataset for temp stage can not be filled. Branch training terminated

Note that I added a printf statement that begins with "310:" corresponding to line 310 in the cascadeclassifier.cpp file. Line 310 falls within the following subroutine:

bool CvCascadeClassifier::updateTrainingSet( double minimumAcceptanceRatio, double& acceptanceRatio)

Can anyone see what I'm doing wrong?

Is there an example available – a zip file that contains positive images, negative images, the descriptor files, the command line to run, basically all the stuff just to verify that it works?

Thanks, Barry.

-- UPDATE --

I found a great example at:

http://abhishek4273.com/2014/03/16/tr...

TRAINCASCADE AND CAR DETECTION USING OPENCV by ABHISHEK KUMAR ANNAMRAJU

He works through a simple problem from start to finish providing the sample images, createsamples and traincascade command lines, and the info files.

He seems to be using Linux/UNIX. I use Windows 7. The "find" command is not available on Windows. I entered dir /B > cars.info from a command window and then and edited the output file to add the directory prefix and a 1 0 0 100 40 suffix to each line.

Everything worked and I got the output XML file.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
2

answered 2015-03-27 04:28:12 -0600

You problem is pretty simple, basically your training says that it can no longer improve your cascade with the current training samples and settings beyond stage 3. (0 , 1 and 2). This is not an error, rather the algorithm not being able to continue. If you now run your algorithm again with -numStages 3 your model for detection will be generated.

-minHitRate 0.999 -maxFalseAlarmRate 0.5 combined with only 5 positive samples will never work decently. Why putting your minHitRate so high? Start with increasing the amount of positive samples to 50 or 100. Also the ratio positives/negatives is very strange in this case. I would suspect it to be more balanced, like 500 pos and 1200 neg.

edit flag offensive delete link more

Comments

Hi Steven, I am also facing the same problem. However, I get the error at training stage 2. Even after trying your solution, if I set the -numStages to 3, my training stops at 1. I am using below command to train my classifier: opencv_traincascade -data HOG -vec Final_Positives/pos-samples.vec -bg data.txt -numPos 627 -numNeg 1500 -numStages 3 -w 80 -h 140 -featureType HOG -precalcValBufSize 4048 -precalcIdxBufSize 4048 -numThreads 8 -minHitRate 0.999 -maxFalseAlarmRate 0.5 I would be highly grateful if you could provide some guidance. Thanks!

denoza gravatar imagedenoza ( 2016-12-19 03:23:55 -0600 )edit

if I set the -numStages to 3, my training stops at 1 --> you should open up your own issue, because it can be completely unrelated. If it halts at stage 1 there must be a reason, and thus this can only be checked with a complete new analysis/debug session, which I prefer to do in a clean topic.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-12-20 04:27:14 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2015-03-23 18:45:59 -0600

Seen: 5,426 times

Last updated: Mar 27 '15