Ask Your Question

golbie's profile - activity

2017-11-05 10:23:56 -0600 received badge  Famous Question (source)
2016-03-02 15:29:53 -0600 received badge  Notable Question (source)
2015-03-22 05:15:27 -0600 received badge  Popular Question (source)
2013-08-20 10:00:13 -0600 received badge  Scholar (source)
2013-08-20 09:59:05 -0600 commented answer Using opencv_traincascade and speed up the processing

Thank you Steven.

ad 1) I will use LBP. Do I have to expect some quality issues or is there a HAAR-fallback? ad 2): that was my suspect. I intentionally picked images with white background. My mistake.

Now, I tried to generate some positive images with background by using this script but the white color is not treated as transparent.

<pre>

!/bin/sh

for f in ls ../positive_images; do opencv_createsamples -img ../positive_images/$f -num 10 -bg ../negatives.dat -maxxangle 0.6 -maxyangle 0 -maxzangle 0.3 -maxidev 100 -bgcolor 255 done </pre>

The result is an image composed of a negative image and the skewed positive image with white background. Do you know what I should pass as -bgcolor parameter to achieve the background transparency?

thx golbie

2013-08-19 12:02:20 -0600 received badge  Editor (source)
2013-08-19 09:09:35 -0600 asked a question Using 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 ...
(more)