Ask Your Question

bluezap's profile - activity

2016-06-20 21:37:00 -0500 received badge  Student (source)
2016-06-04 14:22:36 -0500 received badge  Scholar (source)
2016-06-04 14:22:23 -0500 commented answer Cascade training failed OpenCV 2.4.9.1

Got it! What should I do to train the cascade with a lower number of stages? I don't want to go for 20 because it will take weeks. Should I reduce the number of samples I have? Thanks

2016-06-01 12:40:34 -0500 commented question Cascade training failed OpenCV 2.4.9.1

Thank you! this got me quite far. but I ran into another error. I have updated the question above.

2016-05-31 00:35:36 -0500 received badge  Editor (source)
2016-05-30 23:52:57 -0500 asked a question Cascade training failed OpenCV 2.4.9.1

I'm trying to train a cascade database with 41 positive images and 500 negative images (as a trail) Here are my steps

pos.info -

pos/pos-001.pgm 1 0 0 100 40
pos/pos-002.pgm 1 0 0 100 40
pos/pos-003.pgm 1 0 0 100 40

so on till 41

**neg.txt -**

neg/neg-001.pgm
neg/neg-002.pgm

so on till 500

All images are 100x40

all files are on my ubuntu Desktop (even the data folder with no data inside)

To create the vector file

opencv_createsamples -info pos.info -num 40 -w 48 -h 24 -vec pos.vec

To train the database -

opencv_traincascade -data data -vec pos.vec -bg bg.txt -numPos 30 -numNeg 500 -numStages 10 -w 48 -h 24 -featureType LBP

Version OpenCV - 2.4.9.1

Here is the copy from my terminal -

--Error--

example@example:~/Desktop$ opencv_createsamples -info pos.info -num 41 -w 48 -h 24 -vec pos.vec

Info file name: pos.info
Img file name: (NULL)
Vec file name: pos.vec
BG  file name: (NULL)
Num: 41
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 48
Height: 24
Create training samples from images collection...
Done. Created 41 samples


example@example:~/Desktop$ opencv_traincascade -data data -vec pos.vec -bg bg.txt -numPos 30 -numNeg 500 -numStages 10 -w 48 -h 24 -featureType LBP

PARAMETERS:
cascadeDirName: data
vecFileName: pos.vec
bgFileName: bg.txt
numPos: 30
numNeg: 500
numStages: 10
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: LBP
sampleWidth: 48
sampleHeight: 24
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100

===== TRAINING 0-stage =====

BEGIN
POS count : consumed   30 : 30
Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.

NEW ERROR AFTER NEG PATH CORRECTION

example@Example:~/Desktop$ opencv_createsamples -info balls.info -num 41 -w 48 -h 28 -vec balls.vec

Info file name: balls.info
Img file name: (NULL)
Vec file name: balls.vec
BG  file name: (NULL)
Num: 41
BG color: 0
BG threshold: 80
Invert: FALSE
Max intensity deviation: 40
Max x angle: 1.1
Max y angle: 1.1
Max z angle: 0.5
Show samples: FALSE
Width: 48
Height: 28
Create training samples from images collection...
Done. Created 41 samples

example@Example:~/Desktop$ opencv_traincascade -data data -vec balls.vec -bg bg.txt -numPos 35 -numNeg 500 -numStages 2 -w 48 -h 28 -featureType LBP

PARAMETERS:
cascadeDirName: data
vecFileName: balls.vec
bgFileName: bg.txt
numPos: 35
numNeg: 500
numStages: 2
precalcValBufSize[Mb] : 256
precalcIdxBufSize[Mb] : 256
stageType: BOOST
featureType: LBP
sampleWidth: 48
sampleHeight: 28
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   35 : 35
NEG count : acceptanceRatio    500 : 1
Precalculation time: 0
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>
Training until now ...
(more)