Ask Your Question
0

TrainCascade image positive problem

asked 2015-09-30 05:30:05 -0600

Corto gravatar image

I've create a classifier using Haartraining_Stuff, i have to create a road signal detection, i create a file info, negative.txt, positive.txt and .vec file. Then i use command traincascade write like this:

C:\OpenCV\opencv\build\x86\vc11\bin\opencv_traincascade.exe -data classifier\ -vec "C:\OpenCV\sample.vec" -bg "C:\OpenCV\negativeNew.txt" -numStages 2 -minHitRate 0.01 -maxFalseAllarmRate 0.5 -numPos 2 -numNeg 250 -w 20 -h 20 -mode ALL -precalcvalBuffSize 256 -precalcdxBufSize 256

But when i run it, give me this:

C:\OpenCV>C:\OpenCV\opencv\build\x86\vc11\bin\opencv_traincascade.exe -data classifier\ -vec "C:\OpenCV\sample.vec" -bg "C:\OpenCV\negativeNew.txt" -numStages 2 -minHitRate 0.01 -maxFalseAllarmRate 0.5 -numPos 2 -numNeg 250 -w 20 -h 20 -mode ALL -precalcvalBuffSize 256 -precalcdxBufSize 256 PARAMETERS: cascadeDirName: classifier\ vecFileName: C:\OpenCV\sample.vec bgFileName: C:\OpenCV\negativeNew.txt numPos: 2 numNeg: 250 numStages: 2 precalcValBufSize[Mb] : 1024 precalcIdxBufSize[Mb] : 1024 acceptanceRatioBreakValue : -1 stageType: BOOST featureType: HAAR sampleWidth: 20 sampleHeight: 20 boostType: GAB minHitRate: 0.01 maxFalseAlarmRate: 0.5 weightTrimRate: 0.95 maxDepth: 1 maxWeakCount: 100 mode: ALL

===== TRAINING 0-stage ===== < BEGIN POS count : consumed 2 : 2 NEG count : acceptanceRatio 250 : 1 Precalculation time: 0.594 +----+---------+---------+

| N | HR | FA |

+----+---------+---------+

| 1| 1| 0|

+----+---------+---------+ END> Training until now has taken 0 days 0 hours 0 minutes 1 seconds.

===== TRAINING 1-stage ===== BEGIN POS count : consumed 2 : 2 NEG count : acceptanceRatio 250 : 0.0423155

Required leaf false alarm rate achieved. Branch training terminated.

I think the problem is the low positive image no?

There is a command for use distorsion or something like this for create more file positive without take photo around? Thanks for help.

edit retag flag offensive close merge delete

Comments

1

Are you sure for:

-numStages 2 -minHitRate 0.01

Also there is a typo error: -maxFalseAllarmRate.

Both values seem pretty low for me but people with better understanding on Cascade Classifier would be able to answer you.

Eduardo gravatar imageEduardo ( 2015-09-30 06:44:10 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2015-10-01 04:34:41 -0600

Okay some basic comments

  • I've create a classifier using Haartraining_Stuff --> first bad start. OpenCV moved to a better and more stable C++ interface of the cascade classification algorithm, called train_cascade, which can be found in the apps folder, right here. Use that one and not the old, deprecated and not mainted haartraining interface. You will even notice that the latest version doesn't even have it anymore.
  • Despite the name has changed to a more universal name, it still supports the HAAR wavelets, just lost a tons of bugs that were in the algorithm.
  • A cascade with only 2 stages will never work, it basically defeats the purpose of building a cascade of weak classifiers to get a strong classifier. If you do not grasp this remark, read the official paper by Viola and Jones.
  • A minimum hit rate of 0.01 means that you can misclassify up to 99 percent of your positive samples on a weak stage? This seems plain wrong. Default it is 0.995 so that you only misclassify 0.5 percent of your positive samples. You could lower it a bit, but not to much, because else you will make a too generic model. Making it to high like 0.999 will make sure that you will soon have a setup that is not achievable, because there are always positives that cannot be matched into the current weak classifier structure.
  • -maxFalseAllarmRate typo like pointed out by @Eduardo, thank you for that!
  • -numPos 2 will never work. The principle of cascades is that you learn a model from a lot of data. In this case you will soon run out of positive samples that are correctly classified by each weak classifier, since your minHitRate is not at 1 (which will never work as explained before) and thus those 2 samples will get discarded quite soon. On the other hand you will completely overfit your model to this 2 object instances.
  • Increase your precalculation buffers. With 256MB you will not train a decent model, since to much memory is needed for storing all the features from the AdaBoost process. There is a reason why it is on 1GB by default for the moment.

Try adapting all this and see where it gets you!

edit flag offensive delete link more

Comments

Thanks, i've increase all the negative and positive element,

opencv_traincascade -data classifier/ -vec positive.vec -bg Stop/negative.txt -numPos 1700 -numNeg 3035 -numStages 20 -h 24 -w 24

But at the stages 9 it stop with Required leaf false alarm rate achieved. Branch training terminated.

Corto gravatar imageCorto ( 2015-10-28 09:37:38 -0600 )edit

That means that you have reached the maximum required accuracy on your training data given your training settings. So your model cannot improve anymore or does not need to. Either supply more diverse training data or try adapting parameters to be more strict!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-29 03:35:05 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-09-30 05:22:18 -0600

Seen: 605 times

Last updated: Oct 28 '15