Ask Your Question

Revision history [back]

Cascade Training Error OpenCV 2.4.13 error @ stage 4! Train dataset for temp stage can not be filled

I've built opencv 2.4.13 for ubuntu 16.04 x64 from source zip file downloaded from opencv website.

I prepared the required libraries and packages according OpenCV Installation in Linux, then compiled the release version by :

cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local

then:

make -j4

and then:

make install

The installation was successful and I could use "opencv_createsamples" to generate the desired vector file.

The problem is the "opencv_traincascade". Let me show you some info:

mohammad@ThinkPad-Xenial:~$ ls /home/mohammad/Documents -all
total 3219104
drwxr-xr-x 10 mohammad mohammad       4096 Aug 23 12:11 .
drwxr-xr-x 26 mohammad mohammad       4096 Aug 23 10:30 ..
-rw-rw-r--  1 mohammad mohammad       2482 Aug 23 11:41 bg.txt
drwxrwxrwx  2 mohammad mohammad       4096 Aug 22 21:27 mohammadspic
drwxrwxrwx  2 mohammad mohammad      20480 Aug 22 15:01 negative_images
-rw-rw-r--  1 mohammad mohammad      10389 Aug 23 10:32 pos.vec
-rw-rw-r--  1 mohammad mohammad        341 Aug 23 10:30 ps.txt
drwxrwxr-x  2 mohammad mohammad       4096 Aug 23 11:44 xm

Here is my training command, but if look at the end of the training procedure, you will see a similar error. But this time, the negative images description file is correct and "opencv_traincascade" works properly until stage 4!!!!

mohammad@ThinkPad-Xenial:~$ opencv_traincascade -data /home/mohammad/Documents/xm -vec /home/mohammad/Documents/pos.vec -bg /home/mohammad/Documents/bg.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 9 -numNeg 50 -w 24 -h 24 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024
PARAMETERS:
cascadeDirName: /home/mohammad/Documents/xm
vecFileName: /home/mohammad/Documents/pos.vec
bgFileName: /home/mohammad/Documents/bg.txt
numPos: 9
numNeg: 50
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 24
sampleHeight: 24
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL
Number of unique features given windowSize [24,24] : 261600

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

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

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

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   9 : 9
NEG count : acceptanceRatio    50 : 0.00854701
Precalculation time: 1
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        0|
+----+---------+---------+
END>
Training until now has taken 0 days 0 hours 0 minutes 4 seconds.

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

Here is the "/home/mohammad/Documents/bg.txt" contents which includes address of 50 negative images:

/home/mohammad/Documents/negative_images/190.jpg
/home/mohammad/Documents/negative_images/_071.jpg
/home/mohammad/Documents/negative_images/277.jpg
/home/mohammad/Documents/negative_images/198.jpg
/home/mohammad/Documents/negative_images/_198.jpg
/home/mohammad/Documents/negative_images/_187.jpg
/home/mohammad/Documents/negative_images/296.jpg
/home/mohammad/Documents/negative_images/_061.jpg
/home/mohammad/Documents/negative_images/336.jpg
/home/mohammad/Documents/negative_images/151.jpg
/home/mohammad/Documents/negative_images/_006.jpg
/home/mohammad/Documents/negative_images/_091.jpg
/home/mohammad/Documents/negative_images/236.jpg
/home/mohammad/Documents/negative_images/BzEBn4pCYAAvj6f.jpg
/home/mohammad/Documents/negative_images/_151.jpg
/home/mohammad/Documents/negative_images/025.jpg
/home/mohammad/Documents/negative_images/102.jpg
/home/mohammad/Documents/negative_images/_095.jpg
/home/mohammad/Documents/negative_images/187.jpg
/home/mohammad/Documents/negative_images/315.jpg
/home/mohammad/Documents/negative_images/_089.jpg
/home/mohammad/Documents/negative_images/219.jpg
/home/mohammad/Documents/negative_images/258.jpg
/home/mohammad/Documents/negative_images/251.jpg
/home/mohammad/Documents/negative_images/_134.jpg
/home/mohammad/Documents/negative_images/_009.jpg
/home/mohammad/Documents/negative_images/_154.jpg
/home/mohammad/Documents/negative_images/011.jpg
/home/mohammad/Documents/negative_images/311.jpg
/home/mohammad/Documents/negative_images/_065.jpg
/home/mohammad/Documents/negative_images/_042.jpg
/home/mohammad/Documents/negative_images/316.jpg
/home/mohammad/Documents/negative_images/013.jpg
/home/mohammad/Documents/negative_images/089.jpg
/home/mohammad/Documents/negative_images/_186.jpg
/home/mohammad/Documents/negative_images/216.jpg
/home/mohammad/Documents/negative_images/095.jpg
/home/mohammad/Documents/negative_images/184.jpg
/home/mohammad/Documents/negative_images/169.jpg
/home/mohammad/Documents/negative_images/078.jpg
/home/mohammad/Documents/negative_images/_073.jpg
/home/mohammad/Documents/negative_images/271.jpg
/home/mohammad/Documents/negative_images/_098.jpg
/home/mohammad/Documents/negative_images/_040.jpg
/home/mohammad/Documents/negative_images/386.jpg
/home/mohammad/Documents/negative_images/058.jpg
/home/mohammad/Documents/negative_images/_017.jpg
/home/mohammad/Documents/negative_images/051.jpg
/home/mohammad/Documents/negative_images/380.jpg
/home/mohammad/Documents/negative_images/_190.jpg

Does anyone know where am I wrong or where is the problem?

Thank you