Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

markers detection

Greetings everyone!

I'm working on the solution that will detect graphical markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings and tests, however the results were unsatisfying.

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results?

Thank you in advance for :)

markers detection

Greetings everyone!everyone! :)

I'm working on the solution that will detect graphical markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings and tests, however the results were unsatisfying.trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

and tests, however the results were unsatisfying.

I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results?

Thank you in advance for :)your help.

markers detection

Greetings everyone! :)

I'm working on the solution that will detect graphical markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

and tests, however the results were unsatisfying.

I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results?results? Or maybe some other detecting method suits such case better?

Thank you in advance for your help.

markers detection

Greetings everyone! :)

I'm working on the solution that will detect graphical markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

and tests, however the results were unsatisfying.

not satisfying. Below is the log of training:

./opencv_haartraining \
-data cascade \
-vec positive_samples/vec/positive_images.vec \
-bg negative_samples/negative_images.dat \
-npos 1000 \
-nneg 1000 \
-nstages 10 \
-nsplits 2 \
-maxtreesplits 10 \
-mem 15000 \
-nonsym \
-minhitrate 0.999 \
-maxfalsealarm 0.5 \
-mode ALL \
-minpos 200 \
-w 24 -h 24


Data dir name: cascade
Vec file name: positive_samples/vec/positive_images.vec
BG  file name: negative_samples/negative_images.dat, is a vecfile: no
Num pos: 1000
Num neg: 1000
Num stages: 10
Num splits: 2 (tree as weak classifier)
Mem: 15000 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 10
Min number of positive samples per cluster: 200
Required leaf false alarm rate: 8.87784e-05

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 261600

Parent node: NULL

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 1
BACKGROUND PROCESSING TIME: 0.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 14.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 752 of 1000. (75%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000571|
+----+----+-+---------+---------+---------+---------+
Stage training time: 12.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: NULL
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+
|  0|
+---+

   0


Parent node: 0

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 0.00503175
BACKGROUND PROCESSING TIME: 1.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 13.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 269 of 1000. (26%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 8.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: 0
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Parent node: 1

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 3.80225e-06
BACKGROUND PROCESSING TIME: 1754.00
Required leaf false alarm rate achieved. Branch training terminated.
Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Cascade performance
POS: 1000 1000 1.000000
NEG: 1000 3.55268e-06
BACKGROUND PROCESSING TIME: 1994.00

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results? Or maybe some other detecting method suits is better for such case better?task?

Thank you in advance for your help.

markers detection

Greetings everyone! :)

I'm working on the solution that will detect graphical markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

and tests, however the results were not satisfying. Below satisfying (the log of the training is at the log of training:and of this post).

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results? Or maybe some other detecting method is better for such task?

Thank you in advance for your help.

./opencv_haartraining \
-data cascade \
-vec positive_samples/vec/positive_images.vec \
-bg negative_samples/negative_images.dat \
-npos 1000 \
-nneg 1000 \
-nstages 10 \
-nsplits 2 \
-maxtreesplits 10 \
-mem 15000 \
-nonsym \
-minhitrate 0.999 \
-maxfalsealarm 0.5 \
-mode ALL \
-minpos 200 \
-w 24 -h 24


Data dir name: cascade
Vec file name: positive_samples/vec/positive_images.vec
BG  file name: negative_samples/negative_images.dat, is a vecfile: no
Num pos: 1000
Num neg: 1000
Num stages: 10
Num splits: 2 (tree as weak classifier)
Mem: 15000 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 10
Min number of positive samples per cluster: 200
Required leaf false alarm rate: 8.87784e-05

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 261600

Parent node: NULL

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 1
BACKGROUND PROCESSING TIME: 0.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 14.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 752 of 1000. (75%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000571|
+----+----+-+---------+---------+---------+---------+
Stage training time: 12.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: NULL
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+
|  0|
+---+

   0


Parent node: 0

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 0.00503175
BACKGROUND PROCESSING TIME: 1.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 13.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 269 of 1000. (26%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 8.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: 0
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Parent node: 1

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 3.80225e-06
BACKGROUND PROCESSING TIME: 1754.00
Required leaf false alarm rate achieved. Branch training terminated.
Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Cascade performance
POS: 1000 1000 1.000000
NEG: 1000 3.55268e-06
BACKGROUND PROCESSING TIME: 1994.00

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its training parameters would give good detection results? Or maybe some other detecting method is better for such task?

Thank you in advance for your help.

markers detection

Greetings everyone! :)

I'm working on the solution that will detect markers in the image. After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 -w 24 -h 24

and tests, however the results were not satisfying (the log of the training is at the and of this post).

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? And if yes - what values of its the training parameters would give good detection results? Or maybe some other detecting method is better for such task?

Thank you in advance for your help.

./opencv_haartraining \
-data cascade \
-vec positive_samples/vec/positive_images.vec \
-bg negative_samples/negative_images.dat \
-npos 1000 \
-nneg 1000 \
-nstages 10 \
-nsplits 2 \
-maxtreesplits 10 \
-mem 15000 \
-nonsym \
-minhitrate 0.999 \
-maxfalsealarm 0.5 \
-mode ALL \
-minpos 200 \
-w 24 -h 24


Data dir name: cascade
Vec file name: positive_samples/vec/positive_images.vec
BG  file name: negative_samples/negative_images.dat, is a vecfile: no
Num pos: 1000
Num neg: 1000
Num stages: 10
Num splits: 2 (tree as weak classifier)
Mem: 15000 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 10
Min number of positive samples per cluster: 200
Required leaf false alarm rate: 8.87784e-05

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 261600

Parent node: NULL

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 1
BACKGROUND PROCESSING TIME: 0.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 14.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 752 of 1000. (75%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000571|
+----+----+-+---------+---------+---------+---------+
Stage training time: 12.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: NULL
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+
|  0|
+---+

   0


Parent node: 0

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 0.00503175
BACKGROUND PROCESSING TIME: 1.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 13.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 269 of 1000. (26%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 8.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: 0
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Parent node: 1

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 3.80225e-06
BACKGROUND PROCESSING TIME: 1754.00
Required leaf false alarm rate achieved. Branch training terminated.
Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Cascade performance
POS: 1000 1000 1.000000
NEG: 1000 3.55268e-06
BACKGROUND PROCESSING TIME: 1994.00

markers detection

Greetings everyone! :)

I'm working on the solution that will detect markers in the image. I'd like to ask which method available in OpenCV will be a good choice for this task. The detection should be fast enough to work in real time on a modern computer.

After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. Parameters "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives significant rotation and distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 500 200 -w 24 -h 24

24

and tests, however the results were not satisfying (the log of the training is at the and of this post).- in example: very low detection rate of markers seen in live camera image.

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple marker? markers? And if yes - what values of the training parameters would give good detection results? Or maybe some other detecting method is better for such task?

Thank you in advance for your help.

Below is the log from one of many cascade trainings I've done.

./opencv_haartraining \
-data cascade \
-vec positive_samples/vec/positive_images.vec \
-bg negative_samples/negative_images.dat \
-npos 1000 \
-nneg 1000 \
-nstages 10 \
-nsplits 2 \
-maxtreesplits 10 \
-mem 15000 \
-nonsym \
-minhitrate 0.999 \
-maxfalsealarm 0.5 \
-mode ALL \
-minpos 200 \
-w 24 -h 24


Data dir name: cascade
Vec file name: positive_samples/vec/positive_images.vec
BG  file name: negative_samples/negative_images.dat, is a vecfile: no
Num pos: 1000
Num neg: 1000
Num stages: 10
Num splits: 2 (tree as weak classifier)
Mem: 15000 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 10
Min number of positive samples per cluster: 200
Required leaf false alarm rate: 8.87784e-05

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 261600

Parent node: NULL

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 1
BACKGROUND PROCESSING TIME: 0.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 14.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 752 of 1000. (75%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000571|
+----+----+-+---------+---------+---------+---------+
Stage training time: 12.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: NULL
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+
|  0|
+---+

   0


Parent node: 0

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 0.00503175
BACKGROUND PROCESSING TIME: 1.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 13.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 269 of 1000. (26%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 8.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: 0
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Parent node: 1

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 3.80225e-06
BACKGROUND PROCESSING TIME: 1754.00
Required leaf false alarm rate achieved. Branch training terminated.
Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Cascade performance
POS: 1000 1000 1.000000
NEG: 1000 3.55268e-06
BACKGROUND PROCESSING TIME: 1994.00

markers detection

Greetings everyone! :)

I'm working on the solution that will detect markers in the image. I'd like to ask which method available in OpenCV will be a good choice for this task. The detection should be fast enough to work in real time on a modern computer.

After a quick research I've decided to use markers similar to those used in car crash-tests.

image description

The method should be able to detect multiple markers which are visible from a slight perspective and also with some rotation - just like in the following example:

image description

My first idea was to use the cascadeclassifier. I've started with creating positive samples .vec file using:

./opencv_createsamples -vec positive_samples/vec/positive_images.vec -img positive_samples/marker.png -bg negative_samples/negative_images.dat -num 1020 -bgcolor -1 -bgthresh 0 -maxidev 40 -maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2 -show -w 24 -h 24

I used "-bgcolor -1 -bgthresh 0" to avoid making any part of the image transparent. Parameters "-maxxangle 0.6 -maxyangle 0.6 -maxzangle 0.2" gives rotation and distortion variance that seems to be quite enough.

Negative images dataset was taken from the SUN2012 - I've chosen 1000 images from this set.

Then I've done some trainings:

./opencv_haartraining -data cascade -vec positive_samples/vec/positive_images.vec -bg negative_samples/negative_images.dat -npos 1000 -nneg 1000 -nstages 10 -nsplits 2 -mem 15000 -nonsym -minhitrate 0.999 -maxfalsealarm 0.5 -mode ALL -minpos 200 -w 24 -h 24

and tests, however the results were not satisfying - in example: very low detection rate of markers seen in live camera image.

After all, I've also tried training cascadeclassifier to detect my face and in this case results were much better.

So my question is whether cascadeclassifier is a good choice for recognizing simple markers? And if yes - what values of the training parameters would give good detection results? Or maybe some other detecting method is better for such task?

Thank you in advance for your help.

Below is the log from one of many cascade trainings I've done.

./opencv_haartraining \
-data cascade \
-vec positive_samples/vec/positive_images.vec \
-bg negative_samples/negative_images.dat \
-npos 1000 \
-nneg 1000 \
-nstages 10 \
-nsplits 2 \
-maxtreesplits 10 \
-mem 15000 \
-nonsym \
-minhitrate 0.999 \
-maxfalsealarm 0.5 \
-mode ALL \
-minpos 200 \
-w 24 -h 24


Data dir name: cascade
Vec file name: positive_samples/vec/positive_images.vec
BG  file name: negative_samples/negative_images.dat, is a vecfile: no
Num pos: 1000
Num neg: 1000
Num stages: 10
Num splits: 2 (tree as weak classifier)
Mem: 15000 MB
Symmetric: FALSE
Min hit rate: 0.999000
Max false alarm rate: 0.500000
Weight trimming: 0.950000
Equal weights: FALSE
Mode: ALL
Width: 24
Height: 24
Applied boosting algorithm: GAB
Error (valid only for Discrete and Real AdaBoost): misclass
Max number of splits in tree cascade: 10
Min number of positive samples per cluster: 200
Required leaf false alarm rate: 8.87784e-05

Tree Classifier
Stage
+---+
|  0|
+---+


Number of features used : 261600

Parent node: NULL

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 1
BACKGROUND PROCESSING TIME: 0.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 14.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 752 of 1000. (75%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000571|
+----+----+-+---------+---------+---------+---------+
Stage training time: 12.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: NULL
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+
|  0|
+---+

   0


Parent node: 0

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 0.00503175
BACKGROUND PROCESSING TIME: 1.00
Precalculation time: 3.00
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 13.00
Number of used features: 2
*** 2 clusters ***
Getting values for clustering time: 0.00
Value matirx size: 1000 x 2
Clustering time: 0.00
Cluster: 0
# pos: 269 of 1000. (26%)
+----+----+-+---------+---------+---------+---------+
|  N |%SMP|F|  ST.THR |    HR   |    FA   | EXP. ERR|
+----+----+-+---------+---------+---------+---------+
|   1|100%|-| 1.000000| 1.000000| 0.000000| 0.000000|
+----+----+-+---------+---------+---------+---------+
Stage training time: 8.00
Number of used features: 2
*** 3 clusters ***
Clustering time: 0.00
Clusters are too small. Clustering aborted.

Parent node: 0
Chosen number of splits: 0

Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Parent node: 1

*** 1 cluster ***
POS: 1000 1000 1.000000
NEG: 1000 3.80225e-06
BACKGROUND PROCESSING TIME: 1754.00
Required leaf false alarm rate achieved. Branch training terminated.
Total number of splits: 0

Tree Classifier
Stage
+---+---+
|  0|  1|
+---+---+

   0---1


Cascade performance
POS: 1000 1000 1.000000
NEG: 1000 3.55268e-06
BACKGROUND PROCESSING TIME: 1994.00