Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using opencv_traincascase and speed up the processing

hello there,

I'm using OpenCV to create a "training" file for dog head recognition. I collected positive images (more than 250) and stored them in a directory. The file pointing to the images (positives.dat) looks like follows:

positive_images/314x382xfrench-bulldog.jpg.pagespeed.ic.9df2ynqdWL.jpg 1 0 0 243 243
positive_images/275x480xbeauceron.jpg.pagespeed.ic.VaRD4-_XQX.jpg 1 0 0 200 200
positive_images/shetland-sheepdog12.jpg 1 0 0 185 185
positive_images/7014-doberman-pinscher7.jpg 1 0 0 286 286

...

Every positive image has a good quality and white background (I thought this is better for OpenCV because the image contains the positive content exclusively).

Afterwards I collected negative images too. The file poiting to them looks like this (negatives.dat):

negative_images/neg-4179.jpg
negative_images/neg-0811.jpg
negative_images/neg-3761.jpg
negative_images/neg-4281.jpg

In the next step the vector file has been created by executing this command:

opencv_createsamples -vec samples.vec -bg negatives.dat -info positives.dat -w 80 -h 80 -show

That means that samples.vec contains all the images from positives.dat. Each and every image is scaled to 80x80 pixel.

Finally, I started the training by issuing this command:

opencv_traincascade -data training -vec samples.vec -bg negatives.dat -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 200 -numNeg 600 -w 80 -h 80 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

By now, opencv_traincascade has been running for approx. 52 hours!! Currently, the stage 19. is processed.

The console output looks like this:

~/OpenCVProjects/DogFaceRecognition$ ./_training.sh 
PARAMETERS:
cascadeDirName: training
vecFileName: samples.vec
bgFileName: negatives.dat
numPos: 200
numNeg: 600
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: HAAR
sampleWidth: 80
sampleHeight: 80
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.298333|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.226757
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|      0.7|
+----+---------+---------+
|   4|        1| 0.328333|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0837638
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|     0.67|
+----+---------+---------+
|   3|        1| 0.308333|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0256663
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.556667|
+----+---------+---------+
|   3|        1| 0.311667|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00866226
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.535|
+----+---------+---------+
|   4|        1| 0.276667|
+----+---------+---------+
END>

===== TRAINING 5-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00343436
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|    0.685|
+----+---------+---------+
|   3|        1| 0.438333|
+----+---------+---------+
END>

===== TRAINING 6-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00155508
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.733333|
+----+---------+---------+
|   4|        1|    0.555|
+----+---------+---------+
|   5|        1|      0.4|
+----+---------+---------+
END>

===== TRAINING 7-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000642857
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.851667|
+----+---------+---------+
|   5|        1| 0.651667|
+----+---------+---------+
|   6|        1|    0.505|
+----+---------+---------+
|   7|        1| 0.538333|
+----+---------+---------+
|   8|        1| 0.356667|
+----+---------+---------+
END>

===== TRAINING 8-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000269752
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.738333|
+----+---------+---------+
|   4|        1|     0.56|
+----+---------+---------+
|   5|        1|     0.61|
+----+---------+---------+
|   6|        1| 0.463333|
+----+---------+---------+
END>

===== TRAINING 9-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000120068
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.808333|
+----+---------+---------+
|   5|        1| 0.621667|
+----+---------+---------+
|   6|        1| 0.586667|
+----+---------+---------+
|   7|        1|    0.375|
+----+---------+---------+
END>

===== TRAINING 10-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 6.45317e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1|    0.635|
+----+---------+---------+
|   6|        1| 0.401667|
+----+---------+---------+
END>

===== TRAINING 11-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.25571e-05
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1| 0.846667|
+----+---------+---------+
|   6|        1|     0.66|
+----+---------+---------+
|   7|        1| 0.433333|
+----+---------+---------+
END>

===== TRAINING 12-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 2.01803e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.608333|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.656667|
+----+---------+---------+
|   7|        1|    0.565|
+----+---------+---------+
|   8|        1| 0.533333|
+----+---------+---------+
|   9|        1| 0.378333|
+----+---------+---------+
END>

===== TRAINING 13-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 9.5744e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.838333|
+----+---------+---------+
|   4|        1| 0.813333|
+----+---------+---------+
|   5|        1| 0.638333|
+----+---------+---------+
|   6|        1| 0.708333|
+----+---------+---------+
|   7|        1| 0.573333|
+----+---------+---------+
|   8|        1| 0.418333|
+----+---------+---------+
END>

===== TRAINING 14-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 5.48561e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|    0.735|
+----+---------+---------+
|   5|        1| 0.926667|
+----+---------+---------+
|   6|        1| 0.616667|
+----+---------+---------+
|   7|        1| 0.491667|
+----+---------+---------+
END>

===== TRAINING 15-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.60541e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.868333|
+----+---------+---------+
|   5|        1| 0.693333|
+----+---------+---------+
|   6|        1|     0.61|
+----+---------+---------+
|   7|        1| 0.473333|
+----+---------+---------+
END>

===== TRAINING 16-stage =====
<BEGIN
POS count : consumed   200 : 200

NEG count : acceptanceRatio    600 : 2.5227e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+

|   3|        1|     0.64|
+----+---------+---------+
|   4|        1| 0.423333|
+----+---------+---------+
END>

===== TRAINING 17-stage =====
<BEGIN
POS count : consumed   200 : 200


NEG count : acceptanceRatio    600 : 1.12264e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|     0.83|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.393333|
+----+---------+---------+
END>

===== TRAINING 18-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1.25536e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.825|
+----+---------+---------+
|   4|        1| 0.753333|
+----+---------+---------+
|   5|        1| 0.493333|
+----+---------+---------+
END>

===== TRAINING 19-stage =====
<BEGIN
POS count : consumed   200 : 200

Am I doing something wrong? Are my parameters wrong or too "exhausting"? Can I expect good results? Is there any way to speed up the processing? Which width/height fits best for training? Should I have used 20x20 rather than 80x80 (I decided to used 80x80 because the 20x20 images stored in vector file had poor quality)? Can you give me some advices? Every feedback will be appreciated.

Thank you golbie.

Using opencv_traincascase and speed up the processing

hello there,

I'm using OpenCV to create a "training" file for dog head recognition. I collected positive images (more than 250) and stored them in a directory. The file pointing to the images (positives.dat) looks like follows:

positive_images/314x382xfrench-bulldog.jpg.pagespeed.ic.9df2ynqdWL.jpg 1 0 0 243 243
positive_images/275x480xbeauceron.jpg.pagespeed.ic.VaRD4-_XQX.jpg 1 0 0 200 200
positive_images/shetland-sheepdog12.jpg 1 0 0 185 185
positive_images/7014-doberman-pinscher7.jpg 1 0 0 286 286

...

Every positive image has a good quality and white background (I thought this is better for OpenCV because the image contains the positive content exclusively).

Afterwards I collected negative images too. The file poiting to them looks like this (negatives.dat):

negative_images/neg-4179.jpg
negative_images/neg-0811.jpg
negative_images/neg-3761.jpg
negative_images/neg-4281.jpg

In the next step the vector file has been created by executing this command:

opencv_createsamples -vec samples.vec -bg negatives.dat -info positives.dat -w 80 -h 80 -show

That means that samples.vec contains all the images from positives.dat. Each and every image is scaled to 80x80 pixel.

Finally, I started the training by issuing this command:

 opencv_traincascade -data training -vec samples.vec -bg negatives.dat \
   -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 200 \
   -numNeg 600 -w 80 -h 80 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

By now, opencv_traincascade has been running for approx. 52 hours!! Currently, the stage 19. is processed.

The console output looks like this:

~/OpenCVProjects/DogFaceRecognition$ ./_training.sh 
PARAMETERS:
cascadeDirName: training
vecFileName: samples.vec
bgFileName: negatives.dat
numPos: 200
numNeg: 600
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: HAAR
sampleWidth: 80
sampleHeight: 80
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.298333|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.226757
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|      0.7|
+----+---------+---------+
|   4|        1| 0.328333|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0837638
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|     0.67|
+----+---------+---------+
|   3|        1| 0.308333|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0256663
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.556667|
+----+---------+---------+
|   3|        1| 0.311667|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00866226
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.535|
+----+---------+---------+
|   4|        1| 0.276667|
+----+---------+---------+
END>

===== TRAINING 5-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00343436
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|    0.685|
+----+---------+---------+
|   3|        1| 0.438333|
+----+---------+---------+
END>

===== TRAINING 6-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00155508
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.733333|
+----+---------+---------+
|   4|        1|    0.555|
+----+---------+---------+
|   5|        1|      0.4|
+----+---------+---------+
END>

===== TRAINING 7-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000642857
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.851667|
+----+---------+---------+
|   5|        1| 0.651667|
+----+---------+---------+
|   6|        1|    0.505|
+----+---------+---------+
|   7|        1| 0.538333|
+----+---------+---------+
|   8|        1| 0.356667|
+----+---------+---------+
END>

===== TRAINING 8-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000269752
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.738333|
+----+---------+---------+
|   4|        1|     0.56|
+----+---------+---------+
|   5|        1|     0.61|
+----+---------+---------+
|   6|        1| 0.463333|
+----+---------+---------+
END>

===== TRAINING 9-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000120068
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.808333|
+----+---------+---------+
|   5|        1| 0.621667|
+----+---------+---------+
|   6|        1| 0.586667|
+----+---------+---------+
|   7|        1|    0.375|
+----+---------+---------+
END>

===== TRAINING 10-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 6.45317e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1|    0.635|
+----+---------+---------+
|   6|        1| 0.401667|
+----+---------+---------+
END>

===== TRAINING 11-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.25571e-05
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1| 0.846667|
+----+---------+---------+
|   6|        1|     0.66|
+----+---------+---------+
|   7|        1| 0.433333|
+----+---------+---------+
END>

===== TRAINING 12-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 2.01803e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.608333|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.656667|
+----+---------+---------+
|   7|        1|    0.565|
+----+---------+---------+
|   8|        1| 0.533333|
+----+---------+---------+
|   9|        1| 0.378333|
+----+---------+---------+
END>

===== TRAINING 13-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 9.5744e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.838333|
+----+---------+---------+
|   4|        1| 0.813333|
+----+---------+---------+
|   5|        1| 0.638333|
+----+---------+---------+
|   6|        1| 0.708333|
+----+---------+---------+
|   7|        1| 0.573333|
+----+---------+---------+
|   8|        1| 0.418333|
+----+---------+---------+
END>

===== TRAINING 14-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 5.48561e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|    0.735|
+----+---------+---------+
|   5|        1| 0.926667|
+----+---------+---------+
|   6|        1| 0.616667|
+----+---------+---------+
|   7|        1| 0.491667|
+----+---------+---------+
END>

===== TRAINING 15-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.60541e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.868333|
+----+---------+---------+
|   5|        1| 0.693333|
+----+---------+---------+
|   6|        1|     0.61|
+----+---------+---------+
|   7|        1| 0.473333|
+----+---------+---------+
END>

===== TRAINING 16-stage =====
<BEGIN
POS count : consumed   200 : 200

NEG count : acceptanceRatio    600 : 2.5227e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+

|   3|        1|     0.64|
+----+---------+---------+
|   4|        1| 0.423333|
+----+---------+---------+
END>

===== TRAINING 17-stage =====
<BEGIN
POS count : consumed   200 : 200


NEG count : acceptanceRatio    600 : 1.12264e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|     0.83|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.393333|
+----+---------+---------+
END>

===== TRAINING 18-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1.25536e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.825|
+----+---------+---------+
|   4|        1| 0.753333|
+----+---------+---------+
|   5|        1| 0.493333|
+----+---------+---------+
END>

===== TRAINING 19-stage =====
<BEGIN
POS count : consumed   200 : 200

Am I doing something wrong? Are my parameters wrong or too "exhausting"? Can I expect good results? Is there any way to speed up the processing? Which width/height fits best for training? Should I have used 20x20 rather than 80x80 (I decided to used 80x80 because the 20x20 images stored in vector file had poor quality)? Can you give me some advices? Every feedback will be appreciated.

Thank you golbie.

click to hide/show revision 3
Training done. Recognition successful when background is white.

Using opencv_traincascase and speed up the processing

hello there,

I'm using OpenCV to create a "training" file for dog head recognition. I collected positive images (more than 250) and stored them in a directory. The file pointing to the images (positives.dat) looks like follows:

positive_images/314x382xfrench-bulldog.jpg.pagespeed.ic.9df2ynqdWL.jpg 1 0 0 243 243
positive_images/275x480xbeauceron.jpg.pagespeed.ic.VaRD4-_XQX.jpg 1 0 0 200 200
positive_images/shetland-sheepdog12.jpg 1 0 0 185 185
positive_images/7014-doberman-pinscher7.jpg 1 0 0 286 286

...

Every positive image has a good quality and white background (I thought this is better for OpenCV because the image contains the positive content exclusively).

Afterwards I collected negative images too. The file poiting to them looks like this (negatives.dat):

negative_images/neg-4179.jpg
negative_images/neg-0811.jpg
negative_images/neg-3761.jpg
negative_images/neg-4281.jpg

In the next step the vector file has been created by executing this command:

opencv_createsamples -vec samples.vec -bg negatives.dat -info positives.dat -w 80 -h 80 -show

That means that samples.vec contains all the images from positives.dat. Each and every image is scaled to 80x80 pixel.

Finally, I started the training by issuing this command:

    opencv_traincascade -data training -vec samples.vec -bg negatives.dat \
   -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 200 \
   -numNeg 600 -w 80 -h 80 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

By now, opencv_traincascade has been running for approx. 52 hours!! Currently, the stage 19. is processed.

The console output looks like this:

~/OpenCVProjects/DogFaceRecognition$ ./_training.sh 
PARAMETERS:
cascadeDirName: training
vecFileName: samples.vec
bgFileName: negatives.dat
numPos: 200
numNeg: 600
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: HAAR
sampleWidth: 80
sampleHeight: 80
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.298333|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.226757
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|      0.7|
+----+---------+---------+
|   4|        1| 0.328333|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0837638
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|     0.67|
+----+---------+---------+
|   3|        1| 0.308333|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0256663
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.556667|
+----+---------+---------+
|   3|        1| 0.311667|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00866226
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.535|
+----+---------+---------+
|   4|        1| 0.276667|
+----+---------+---------+
END>

===== TRAINING 5-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00343436
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|    0.685|
+----+---------+---------+
|   3|        1| 0.438333|
+----+---------+---------+
END>

===== TRAINING 6-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00155508
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.733333|
+----+---------+---------+
|   4|        1|    0.555|
+----+---------+---------+
|   5|        1|      0.4|
+----+---------+---------+
END>

===== TRAINING 7-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000642857
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.851667|
+----+---------+---------+
|   5|        1| 0.651667|
+----+---------+---------+
|   6|        1|    0.505|
+----+---------+---------+
|   7|        1| 0.538333|
+----+---------+---------+
|   8|        1| 0.356667|
+----+---------+---------+
END>

===== TRAINING 8-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000269752
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.738333|
+----+---------+---------+
|   4|        1|     0.56|
+----+---------+---------+
|   5|        1|     0.61|
+----+---------+---------+
|   6|        1| 0.463333|
+----+---------+---------+
END>

===== TRAINING 9-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000120068
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.808333|
+----+---------+---------+
|   5|        1| 0.621667|
+----+---------+---------+
|   6|        1| 0.586667|
+----+---------+---------+
|   7|        1|    0.375|
+----+---------+---------+
END>

===== TRAINING 10-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 6.45317e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1|    0.635|
+----+---------+---------+
|   6|        1| 0.401667|
+----+---------+---------+
END>

===== TRAINING 11-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.25571e-05
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1| 0.846667|
+----+---------+---------+
|   6|        1|     0.66|
+----+---------+---------+
|   7|        1| 0.433333|
+----+---------+---------+
END>

===== TRAINING 12-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 2.01803e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.608333|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.656667|
+----+---------+---------+
|   7|        1|    0.565|
+----+---------+---------+
|   8|        1| 0.533333|
+----+---------+---------+
|   9|        1| 0.378333|
+----+---------+---------+
END>

===== TRAINING 13-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 9.5744e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.838333|
+----+---------+---------+
|   4|        1| 0.813333|
+----+---------+---------+
|   5|        1| 0.638333|
+----+---------+---------+
|   6|        1| 0.708333|
+----+---------+---------+
|   7|        1| 0.573333|
+----+---------+---------+
|   8|        1| 0.418333|
+----+---------+---------+
END>

===== TRAINING 14-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 5.48561e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|    0.735|
+----+---------+---------+
|   5|        1| 0.926667|
+----+---------+---------+
|   6|        1| 0.616667|
+----+---------+---------+
|   7|        1| 0.491667|
+----+---------+---------+
END>

===== TRAINING 15-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.60541e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.868333|
+----+---------+---------+
|   5|        1| 0.693333|
+----+---------+---------+
|   6|        1|     0.61|
+----+---------+---------+
|   7|        1| 0.473333|
+----+---------+---------+
END>

===== TRAINING 16-stage =====
<BEGIN
POS count : consumed   200 : 200

NEG count : acceptanceRatio    600 : 2.5227e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+

|   3|        1|     0.64|
+----+---------+---------+
|   4|        1| 0.423333|
+----+---------+---------+
END>

===== TRAINING 17-stage =====
<BEGIN
POS count : consumed   200 : 200


NEG count : acceptanceRatio    600 : 1.12264e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|     0.83|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.393333|
+----+---------+---------+
END>

===== TRAINING 18-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1.25536e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.825|
+----+---------+---------+
|   4|        1| 0.753333|
+----+---------+---------+
|   5|        1| 0.493333|
+----+---------+---------+
END>

===== TRAINING 19-stage =====
<BEGIN
POS count : consumed   200 : 200

Am I doing something wrong? Are my parameters wrong or too "exhausting"? Can I expect good results? Is there any way to speed up the processing? Which width/height fits best for training? Should I have used 20x20 rather than 80x80 (I decided to used 80x80 because the 20x20 images stored in vector file had poor quality)? Can you give me some advices? Every feedback will be appreciated.

Thank you golbie.


Hi, after more than 50 hours OpenCV created 18 stages files and terminated at the 19th with this message:

Now, it's training time! My classifier is working well but there is one issue. My positive_images folder contains images with white background only. Obviously this is error-prone because facedetect utility is not able to recognize regular images with some background (meadow etc.). Should I have used positive images with some "noise" in the background? Should I have used -bgcolor or -bgthresh parameters to tell OpenCV that the white color in the background must be treated as transparent?

Here are the two images: the first one is not recognized because of the background. The 2nd one is recognized because I changed to background color.

FAILURE (NOT recognized): image description

SUCCESS (recognized): image description

Any feedback? Thank you in advance. golbie.

click to hide/show revision 4
typo error in title

Using opencv_traincascase opencv_traincascade and speed up the processing

hello there,

I'm using OpenCV to create a "training" file for dog head recognition. I collected positive images (more than 250) and stored them in a directory. The file pointing to the images (positives.dat) looks like follows:

positive_images/314x382xfrench-bulldog.jpg.pagespeed.ic.9df2ynqdWL.jpg 1 0 0 243 243
positive_images/275x480xbeauceron.jpg.pagespeed.ic.VaRD4-_XQX.jpg 1 0 0 200 200
positive_images/shetland-sheepdog12.jpg 1 0 0 185 185
positive_images/7014-doberman-pinscher7.jpg 1 0 0 286 286

...

Every positive image has a good quality and white background (I thought this is better for OpenCV because the image contains the positive content exclusively).

Afterwards I collected negative images too. The file poiting to them looks like this (negatives.dat):

negative_images/neg-4179.jpg
negative_images/neg-0811.jpg
negative_images/neg-3761.jpg
negative_images/neg-4281.jpg

In the next step the vector file has been created by executing this command:

opencv_createsamples -vec samples.vec -bg negatives.dat -info positives.dat -w 80 -h 80 -show

That means that samples.vec contains all the images from positives.dat. Each and every image is scaled to 80x80 pixel.

Finally, I started the training by issuing this command:

    opencv_traincascade -data training -vec samples.vec -bg negatives.dat \
   -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 200 \
   -numNeg 600 -w 80 -h 80 -mode ALL -precalcValBufSize 1024 -precalcIdxBufSize 1024

By now, opencv_traincascade has been running for approx. 52 hours!! Currently, the stage 19. is processed.

The console output looks like this:

~/OpenCVProjects/DogFaceRecognition$ ./_training.sh 
PARAMETERS:
cascadeDirName: training
vecFileName: samples.vec
bgFileName: negatives.dat
numPos: 200
numNeg: 600
numStages: 20
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
stageType: BOOST
featureType: HAAR
sampleWidth: 80
sampleHeight: 80
boostType: GAB
minHitRate: 0.999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL

===== TRAINING 0-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.298333|
+----+---------+---------+
END>

===== TRAINING 1-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.226757
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|      0.7|
+----+---------+---------+
|   4|        1| 0.328333|
+----+---------+---------+
END>

===== TRAINING 2-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0837638
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|     0.67|
+----+---------+---------+
|   3|        1| 0.308333|
+----+---------+---------+
END>

===== TRAINING 3-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.0256663
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1| 0.556667|
+----+---------+---------+
|   3|        1| 0.311667|
+----+---------+---------+
END>

===== TRAINING 4-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00866226
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.535|
+----+---------+---------+
|   4|        1| 0.276667|
+----+---------+---------+
END>

===== TRAINING 5-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00343436
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|    0.685|
+----+---------+---------+
|   3|        1| 0.438333|
+----+---------+---------+
END>

===== TRAINING 6-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.00155508
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.733333|
+----+---------+---------+
|   4|        1|    0.555|
+----+---------+---------+
|   5|        1|      0.4|
+----+---------+---------+
END>

===== TRAINING 7-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000642857
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.851667|
+----+---------+---------+
|   5|        1| 0.651667|
+----+---------+---------+
|   6|        1|    0.505|
+----+---------+---------+
|   7|        1| 0.538333|
+----+---------+---------+
|   8|        1| 0.356667|
+----+---------+---------+
END>

===== TRAINING 8-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000269752
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.738333|
+----+---------+---------+
|   4|        1|     0.56|
+----+---------+---------+
|   5|        1|     0.61|
+----+---------+---------+
|   6|        1| 0.463333|
+----+---------+---------+
END>

===== TRAINING 9-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 0.000120068
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.808333|
+----+---------+---------+
|   5|        1| 0.621667|
+----+---------+---------+
|   6|        1| 0.586667|
+----+---------+---------+
|   7|        1|    0.375|
+----+---------+---------+
END>

===== TRAINING 10-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 6.45317e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1|    0.635|
+----+---------+---------+
|   6|        1| 0.401667|
+----+---------+---------+
END>

===== TRAINING 11-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.25571e-05
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.796667|
+----+---------+---------+
|   5|        1| 0.846667|
+----+---------+---------+
|   6|        1|     0.66|
+----+---------+---------+
|   7|        1| 0.433333|
+----+---------+---------+
END>

===== TRAINING 12-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 2.01803e-05
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.608333|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.656667|
+----+---------+---------+
|   7|        1|    0.565|
+----+---------+---------+
|   8|        1| 0.533333|
+----+---------+---------+
|   9|        1| 0.378333|
+----+---------+---------+
END>

===== TRAINING 13-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 9.5744e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1| 0.838333|
+----+---------+---------+
|   4|        1| 0.813333|
+----+---------+---------+
|   5|        1| 0.638333|
+----+---------+---------+
|   6|        1| 0.708333|
+----+---------+---------+
|   7|        1| 0.573333|
+----+---------+---------+
|   8|        1| 0.418333|
+----+---------+---------+
END>

===== TRAINING 14-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 5.48561e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|    0.735|
+----+---------+---------+
|   5|        1| 0.926667|
+----+---------+---------+
|   6|        1| 0.616667|
+----+---------+---------+
|   7|        1| 0.491667|
+----+---------+---------+
END>

===== TRAINING 15-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 3.60541e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1| 0.868333|
+----+---------+---------+
|   5|        1| 0.693333|
+----+---------+---------+
|   6|        1|     0.61|
+----+---------+---------+
|   7|        1| 0.473333|
+----+---------+---------+
END>

===== TRAINING 16-stage =====
<BEGIN
POS count : consumed   200 : 200

NEG count : acceptanceRatio    600 : 2.5227e-06
Precalculation time: 23
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+

|   3|        1|     0.64|
+----+---------+---------+
|   4|        1| 0.423333|
+----+---------+---------+
END>

===== TRAINING 17-stage =====
<BEGIN
POS count : consumed   200 : 200


NEG count : acceptanceRatio    600 : 1.12264e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|        1|
+----+---------+---------+
|   4|        1|     0.83|
+----+---------+---------+
|   5|        1|    0.505|
+----+---------+---------+
|   6|        1| 0.393333|
+----+---------+---------+
END>

===== TRAINING 18-stage =====
<BEGIN
POS count : consumed   200 : 200
NEG count : acceptanceRatio    600 : 1.25536e-06
Precalculation time: 22
+----+---------+---------+
|  N |    HR   |    FA   |
+----+---------+---------+
|   1|        1|        1|
+----+---------+---------+
|   2|        1|        1|
+----+---------+---------+
|   3|        1|    0.825|
+----+---------+---------+
|   4|        1| 0.753333|
+----+---------+---------+
|   5|        1| 0.493333|
+----+---------+---------+
END>

===== TRAINING 19-stage =====
<BEGIN
POS count : consumed   200 : 200

Am I doing something wrong? Are my parameters wrong or too "exhausting"? Can I expect good results? Is there any way to speed up the processing? Which width/height fits best for training? Should I have used 20x20 rather than 80x80 (I decided to used 80x80 because the 20x20 images stored in vector file had poor quality)? Can you give me some advices? Every feedback will be appreciated.

Thank you golbie.


Hi, after more than 50 hours OpenCV created 18 stages files and terminated at the 19th with this message:

Now, it's training time! My classifier is working well but there is one issue. My positive_images folder contains images with white background only. Obviously this is error-prone because facedetect utility is not able to recognize regular images with some background (meadow etc.). Should I have used positive images with some "noise" in the background? Should I have used -bgcolor or -bgthresh parameters to tell OpenCV that the white color in the background must be treated as transparent?

Here are the two images: the first one is not recognized because of the background. The 2nd one is recognized because I changed to background color.

FAILURE (NOT recognized): image description

SUCCESS (recognized): image description

Any feedback? Thank you in advance. golbie.