Ask Your Question
0

cascade training... help!

asked 2019-11-24 11:12:51 -0600

Hello, I am trying to train a cascade to recognize a traffic cone.

I am trying to use these parameters:

perl bin/createsamples.pl positives.txt negatives.txt samples 500 \
    "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 \
    -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 30 -h 45 "

 

opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt \
    -numStages 16 -minHitRate 0.990 -maxFalseAlarmRate 0.2 -numPos 18 \
    -numNeg 4640 -w 30 -h 45 -mode ALL -precalcValBufSize 2048 \
    -precalcIdxBufSize 2048

    I used bgcolor 0 and the positive images backgroud is black.

The negative images are where I need to identify the cones.

I have many false positives. Can you help me adjust the parameters I need to use?

All positive images have been converted to grayscale and are the same size and black background.

image description image description image description

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2019-11-24 11:44:47 -0600

berak gravatar image

updated 2019-11-24 12:12:33 -0600

imho, 3 problems here:

  1. please use official tutorials, not outdated blog posts
  2. why the black bg ? it's probably not what your detection scenario looks like. the training has to learn to discriminate object and background features, you're defeating it
  3. this needs a ton of REAL images, you can't train with 18 positives only, and also you can't successfully synthesize 5000 images from 5 (so, drop the perl script, and acquire as many images with real bg as you can.)
edit flag offensive delete link more

Comments

Hello @imho

Thanks for the help. I had understood that "-bgcolor 0" was about the background of the positive images. Can you tell me what it means and how should I use it?

Thank you very much.

Rogerlucas gravatar imageRogerlucas ( 2019-11-25 05:59:53 -0600 )edit

again, please follow official instructions

berak gravatar imageberak ( 2019-11-25 06:13:55 -0600 )edit

The main task of the software is to differentiate your object (the thing you want to detect - in your example the cone) from the the rest of the image (called background /negative )

The -bgcolor parameter lets you specify a color for the background(aka negative). If you only supply colors - and in your case exactly one(black) - the cone will be only detectable on black background.Even when you supply more colors as bg - then it will most likely only detect on these colours as background. This is not realistic for a real life scenario (like a cone on a street - a street is not only black - there are many things on and around it)

And if you only supply 16 Images of cones, Only these cones will be detected. There's just not enough variation.

holger gravatar imageholger ( 2019-11-26 20:05:41 -0600 )edit

So you have two problems

  1. Not enough variations on the positives
  2. Not enough variation on the negatives (background)

So the most intuitive thing to do is (in my opinion) Search for real live images - crop the cone(s) from it - these will be your positives. The rest of the image will become your negative.The negatives should be realistic background for your object. So in your case i guess cones are mostly seen on and next to streets. So supply streets without cones as negatives. I think you got the point by now.

I think the third problem is using cascade classifiers at all ^^ But its good for starting - in the end you maybe want to use a cnn -for example i use this one https://docs.opencv.org/master/da/d9d..., but this another layer of complexitiy...

holger gravatar imageholger ( 2019-11-26 20:12:32 -0600 )edit
1

When working with ai - dont think about it in human way. Its a statistics machine for detecting patterns. To be fair - during our live we had a lot of time to collect a lot of data in our brains - so we became clever. Give the same amount of time and data - a machine could maybe reach the same or better level of intelligence?

Last thing to add- calling these things autistic is a compliment for the nets but an insult for autistic people.

holger gravatar imageholger ( 2019-11-26 20:15:36 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-24 11:11:25 -0600

Seen: 316 times

Last updated: Nov 24 '19