Ask Your Question
1

Error during training with opencv_traincascade

asked 2013-05-07 22:11:55 -0600

SuYo gravatar image

updated 2013-05-08 01:24:30 -0600

I want to create a cascaded classifier to detect my simple pen. So, I took about 15 photo of my pen all of width = 476 & height between 43 to 65. Then I took 83 background images all having width 1280 and height 960. I created successfully vec file with 14 samples: opencv_createsamples -info positives.txt -vec vecfile -bg bg.txt -num 15 -w 120 -h 16

and checked for it using: opencv_createsample -vec vec_file -w 120 -h 16

so far I get that these command created all the vec files. opencv_traincascade -data classifier -vec vecfile -bg bg.txt -numPos 15 -numNeg 83 -numStages 18 -precalcValBufSize 384 -precalcIdxBufSize 256 -w 120 -h 16

but the training stoped at STAGE 4 generating error

Required leaf false alarm rate achieved. Branch training terminated

Can you please help, what was wrong? What is false alarm rate??

Thanking You in Advance.

Please Help

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-05-08 06:17:17 -0600

Ok some basic comments on traincascade algorithm and your application problems:

  1. Do not use to large images for model training. A hand rule that I am using is never to let the largest dimension go over 80 pixels. It will take ages in larger stages for training and basically you will run out of processing memory rather soon. I would suggest reducing your dimensions to the half of the original images when creating the vector file.
  2. You only specified standard options, however, hidden from you are the parameters -maxHitRate 0.995 and -maxFalseAlarmRate 0.5. The last one means that if a false alarm rate of 0.5^(number of stages) is reached, training is stopped, because that is exactly what you asked from the algorithm. If you want, you can decrease the number, but keep in mind that training will possible increase exponential.
  3. Actually all parameters could be seen here.

But even before that, it could be that your detector has enough at 4 stages to make a difference between positive and negative images. For this you will need to test your model. Possibly you will need way more negatives, to train for a varying and cluttered background, but it can give an idea about the accuracy of your detector.

edit flag offensive delete link more

Comments

Thank you very much, but do I need to make negative images also lesser than 80 pixels. I have read paper from Viola and Jones paper referred in your link. But what does that -maxHitRate and -maxFalseAlarmRate means. Is it detection rate and false positive rate?

SuYo gravatar imageSuYo ( 2013-05-08 12:12:21 -0600 )edit
1

No for negatives the rule doesn't hold. The processing will select random areas from your negative images, using the width and heigth parameter. maxHitRate is the hit rate you need to keep in order to have a good weak clasifier. This is the detection rate on the positive samples. maxFalseAlarmRate is the rate of false positives for each step. It also creates a stopping criteria for training being (maxFalseAlarmRate)^(number of stages)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-05-11 12:42:26 -0600 )edit

Thanks for StevenPuttemans's advice. Now I moved my question to http://answers.opencv.org/question/14165/required-leaf-false-alarm-rate-achieved-branch/.

FredJiang gravatar imageFredJiang ( 2013-05-28 21:30:02 -0600 )edit

Question Tools

Stats

Asked: 2013-05-07 22:11:55 -0600

Seen: 5,172 times

Last updated: May 28 '13