# opencv traincascade haar and lbp my training parameters

> Opencv train cascade haar and lbp training Opencv train cascade script parameter examples for Windows.

- Canonical URL: https://www.funvisiontutorials.com/blog/opencv-traincascade-haar-lbp-training-parameters/
- Author: Vladimir Kucera
- Published: 2016-12-13
- Updated: 2023-09-13
- Topics: Object detection, Installing & building OpenCV

Opencv train cascade haar and lbp training Opencv train cascade script parameter examples for Windows. Traincascade utility is easy to use for training HAAR-like and LBP-like cascade for opencv detect multiscale by CascadeClassifier. On this blog, you can find several examples of how to detect something by the HAAR and LBP cascade.

##

[Image: Opencv LBP detection]

### Opencv traincascade examples

I am using this parameter. You can start where you just ended before. This makes sense. Train for 5 stages and test. If the results with a higher threshold make sense. Train again with the same script and increase numStages. After some time training is much and much slower and test before you run the training for a long time.

This is my script.. If you have any

opencv\_traincascade.exe -data v -vec vec.vec -bg bg.dat -numPos 300 -numNeg 300 -numStages 10  -numThreads 2 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.995 -maxFalseAlarmRate 0.42 -maxDepth 1 -maxWeakCount 100

opencv\_traincascade.exe -data vv -vec vec.vec -bg bg.dat -numPos 540 -numNeg 800 -numStages 8  -numThreads 4 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.9995 -maxFalseAlarmRate 0.32 -maxDepth 5 -maxWeakCount 120

opencv\_traincascade.exe -data cascade -vec vec.vec -bg bg.dat -numPos 680 -numNeg 800 -numStages 10 numThreads 4 -stageType BOOST -featureType LBP -w 32 -h 64 -minHitRate 0.999995 -maxFalseAlarmRate 0.42 -maxDepth 10 -maxWeakCount 120 -mode ALL

### opencv traincascade documentation description

Later abou this.. Complex staff. Just try example if you have some datasets prepared or know the how to prepare vector\_file and background file for training.

Usage: opencv\_traincascade.exe
  -data &lt;cascade\_dir\_name>
  -vec &lt;vec\_file\_name>
  -bg &lt;background\_file\_name>
\[-numPos &lt;number\_of\_positive\_samples = 2000>\]
\[-numNeg &lt;number\_of\_negative\_samples = 1000>\]
\[-numStages &lt;number\_of\_stages = 20>\]
\[-precalcValBufSize &lt;precalculated\_vals\_buffer\_size\_in\_Mb = 1024>\]
\[-precalcIdxBufSize &lt;precalculated\_idxs\_buffer\_size\_in\_Mb = 1024>\]
\[-baseFormatSave\]
\[-numThreads &lt;max\_number\_of\_threads = 9>\]
\[-acceptanceRatioBreakValue &lt;value> = -1>\]
\--cascadeParams--
\[-stageType &lt;BOOST(default)>\]
\[-featureType &lt;{HAAR(default), LBP, HOG}>\]
\[-w &lt;sampleWidth = 24>\]
\[-h &lt;sampleHeight = 24>\]
\--boostParams--
\[-bt &lt;{DAB, RAB, LB, GAB(default)}>\]
\[-minHitRate &lt;min\_hit\_rate> = 0.995>\]
\[-maxFalseAlarmRate &lt;max\_false\_alarm\_rate = 0.5>\]
\[-weightTrimRate &lt;weight\_trim\_rate = 0.95>\]
\[-maxDepth &lt;max\_depth\_of\_weak\_tree = 1>\]
\[-maxWeakCount &lt;max\_weak\_tree\_count = 100>\]
\--haarFeatureParams--
\[-mode &lt;BASIC(default) | CORE | ALL
\--lbpFeatureParams--
\--HOGFeatureParams--
