HAAR、LBP分类器训练
生活随笔
收集整理的這篇文章主要介紹了
HAAR、LBP分类器训练
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
【工作環(huán)境】是Windows XP或Linux上的Visual Studio + cygwin。cygwin是必需的,因為我使用了幾個UNIX命令。
【注解】在進行安裝cygwin過程中,要選擇安裝“python、perl等”幾個選項。
【代碼以及腳本準備】
github克隆:https://github.com/mrnugget/opencv-haar-classifier-training
百度云網(wǎng)盤:http://pan.baidu.com/s/1cAeU4I 提取碼:o09g
【制作樣本的工具】
制作正樣本的截圖工具:http://pan.baidu.com/s/1mhGVPzE 提取碼:c9le
訓練方法(99%):http://www.learnopencv.com/training-better-haar-lbp-cascade-eye-detector-opencv/Naotoshi Seo博士:http://note.sonots.com/SciSoftware/haartraining.html
==================================================================================================
制作正樣本工具的使用方法:
訓練步驟【步驟1:數(shù)據(jù)收集-->準備正負樣本文件和圖片】negative_imagespositive_images【步驟2:生成正負樣本描述文件】find ./negative_images -iname "*.jpg" > negatives.txtfind ./positive_images -iname "*.jpg" > positives.txt【步驟3:創(chuàng)建樣品】 (1)使用creationamples.pl為每個圖像創(chuàng)建.vec文件。該腳本是圍繞opencv_createsamples的包裝。如OpenCV文檔中所述 -“ opencv_createsamples用于準備正面和測試樣本的訓練數(shù)據(jù)集。opencv_createsamples以opencv_haartraining和opencv_traincascade應用程序支持的格式生成正樣本的數(shù)據(jù)集。輸出是一個帶* .vec擴展名的文件,它是一個包含圖像的二進制格式。 命令: 原文:perl bin/createsamples.pl positives.txt negatives.txt samples 5000 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 40 -h 40"自己:perl bin/createsamples.pl positives.txt negatives.txt samples 4009 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 24 -h 24"(2)使用mergevec.py將.vec文件合并到samples.vec中,如下所示:python ./tools/mergevec.py -v samples/ -o samples.vec【步驟4:運行訓練腳本,開始訓練生成.xml文件】 (1)LBP命令 原文:opencv_traincascade -data lbp -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 4000 -numNeg 7000 -w 40 -h 40 -mode ALL -precalcValBufSize 4096 -precalcIdxBufSize 4096 -featureType LBP自己:opencv_traincascade -data lbp -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 3000 -numNeg 7000 -w 24 -h 24 -mode ALL -precalcValBufSize 4096 -precalcIdxBufSize 4096 -featureType LBP(2)HAAR命令 原文:opencv_traincascade -data haar -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 4000 -numNeg 7000 -w 40 -h 40 -mode ALL -precalcValBufSize 4096 -precalcIdxBufSize 4096自己HAAR:opencv_traincascade -data haar -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 3000 -numNeg 7000 -w 24 -h 24 -mode ALL -precalcValBufSize 4096 -precalcIdxBufSize 4096自己 LBP: opencv_traincascade -data haar -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 3000 -numNeg 7000 -w 24 -h 24 -mode ALL -precalcValBufSize 4096 -precalcIdxBufSize 4096 -featureType LBP 在Window中的cmd下創(chuàng)建樣本描述文件的命令行: 包括全路徑創(chuàng)建樣本描述文件 dir /b/s>negatives.txt dir /b/s>positives.txt 正樣本描述文件后加上1 0 0 24 24 【注】描述文件,特別注意事項:(1)正樣本描述文件后面加上1 0 0 24 24(2)去掉正樣本、負樣本描述文件的最后一行HAAR訓練參數(shù):http://www.ithao123.cn/content-2561305.html
find ./negative_images -iname "*.jpg" > negatives.txtfind ./positive_images -iname "*.jpg" > positives.txtperl bin/createsamples.pl positives.txt negatives.txt samples 4009 "opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1 -maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 24 -h 24"python ./tools/mergevec.py -v samples/ -o samples.vecopencv_traincascade -data haar -vec samples.vec -bg negatives.txt -numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 3500 -numNeg 8000 -w 24 -h 24 -mode ALL -precalcValBufSize 2048 -precalcIdxBufSize 2048總結
以上是生活随笔為你收集整理的HAAR、LBP分类器训练的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 7、Linux中文件类型、文件属性
- 下一篇: 检测生成.xml文件的效果:以人脸xml