Cascade Training Error OpenCV 2.4.4 - Train dataset for temp stage can not filled. Branch training terminated. Cascade Classifier can't be trained. check the used training parameters
Hi there! I used createsamples.exe to create my .vec file then I tried to use cascade training according to the OpenCV doc. But I came to this error:
PARAMETERS:
cascadeDirName: CassCade
vecFileName: Positive\ResistorP1.vec
bgFileName: Negative\NegSamples.txt
numPos: 150
numNeg: 150
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: LBP
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
===== TRAINING 0-stage =====
<BEGIN
POS count : consumed 150 : 150
Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.
I use this command for cascade training:
opencv_traincascaded.exe -data CassCade -vec Positive\ResistorP1.vec -bg N
egative\NegSamples.txt -numPos 150 -numNeg 150 -numStage 30 -featureType LBP -pr
ecalcValBufSize 1024 -precalcIdxBufSize 1024
my .vec size 2.25MB and number of positive samples created by opencv_createsamples.exe is 2000 and number of negative samples is mor than 600 .jpg files.I don't know what's wrong with it ! Thanks in advance! :)
Hi, Constantin I am having same error. I changed my bg.txt as you told in the solution but still having the error. can you please help me with it?
Hi Constantin, Did you get out of the problem .If yes ,can you please tell the solution to resolve the issue. Even i am facing the same Thanks
Hi, I added an answer. my mistake was the one I mentioned. It worked for me!
I was also struggle with this problem a lot. I test run opencv_traincascade for linux on a raspberry pi 3 and thanks for the tip that the problem seem's to be in the bg.txt file I test lot of things in the bg.txt file and suddenly it start to work when I was add ./ before each file name so my bg.txt file look like this (when the background files are in same directory as opencv_tranicascade file is)
./0.JPG
./1.JPG
./2.JPG
./3.JPG
./4.JPG
./5.JPG
./6.JPG
and so on.... I also notice that there was important to have Not have any "invisible" obscure ASCII character in the bg.txt (when I export a colum from Excel it was add some invisible obscure ASCII ho mess up, then I generate a bg.txt from a C code ten it work fine)
//bg.txt generator
//Olle Welin [email protected]
include <stdio.h>
main() {
FILE *fp;
fp = fopen("bg.txt", "w+");
for(int i=0;i < 1000; i++) { fprintf(fp, "./%d",i);
} fclose(fp);
}
Thanks. I also got similar problem and solved. It was path problem with negative samples. Easiest way to solve path problem was to give full path in info file for negative images.