kosbr
kosbr

Reputation: 388

Cascade classifier can't be trained. Check the used training parameters

I need to detect special image (something like symbol +) in scanned document. I'm going to train cascade using opencv_traincascade program (opencv 3.0)

This is my file structure:

C:\imgs\learn1
    Bad
       1.bmp
       .... 
    Good
       1.bmp
       ....
    Bad.dat
    Good.dat

This my Bad.dat:

 Bad\1.bmp
 ...
 Bad\53.bmp
 Bad\img001.jpg
 ...
 Bad\img146.jpg 

This is my Good.dat (every good file fully contains the special image and nothing more)

Good\1.bmp 1 0 0 60 59
...
Good\100.bmp 1 0 0 27 28

I've successfuly created vec file.

C:\opencv\build\x64\vc12\bin>opencv_createsamples.exe 
-info C:\imgs\learn1\Good.dat 
-vec samples.vec
-w 10 -h 10

Info file name: C:\imgs\learn1\Good.dat
Img file name: (NULL)
Vec file name: samples.vec
BG  file name: (NULL)
Num: 1000
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: 10
Height: 10
Create training samples from images collection...
C:\imgs\learn1\Good.dat(101) : parse errorDone. Created 100 samples

This is call and result of opencv_traincascade

 C:\opencv\build\x64\vc12\bin>
-opencv_traincascade.exe 
-data haarcascade 
-vec C:\opencv\build\x64\vc12\bin\samples.vec 
-bg C:\imgs\learn1\Bad.dat 
-numStages 16 
-minhiteate 0.99
-maxFalseAlarmRate 0.5 
-numPos 80 
-numNeg 199 
-w 10 
-h 10 
-mode ALL 
-precalcValBufSize 1024 
-precalcIdxBufSize 1024

PARAMETERS:
cascadeDirName: haarcascade
vecFileName: C:\opencv\build\x64\vc12\bin\samples.vec
bgFileName: C:\imgs\learn1\Bad.dat
numPos: 80
numNeg: 199
numStages: 16
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 10
sampleHeight: 10
boostType: GAB
minHitRate: 0.995
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   80 : 80
Train dataset for temp stage can not be filled. Branch training terminated.
Cascade classifier can't be trained. Check the used training parameters.

As you can see, there is some error. Can you help me what is wrong exactly? "Check the used training parameters" is very general phrase.

(The folder C:\opencv\build\x64\vc12\bin\haarcascade exists)

Upvotes: 2

Views: 3572

Answers (1)

kosbr
kosbr

Reputation: 388

I don't know what was wrong, but I've done it.

1)I've increased number of positive examples to 400

2)I've increased number of negative examples to 398

3)I found that if an image size 61 x 60, I shoud write in Good.dat

Good\1.bmp 1 0 0 60 59

(Image coordinates begin from 0 and end at width-1 and height-1 values)

4)I found type error: minhiteate - > minHitRate

and nothing helps...

5)I try to train in openvc 2.4 and i've got my cascade.xml file

But now I can't use it because of other error, but it's offtopic. (now I,m googling)

Upvotes: 2

Related Questions