训练一个管道识别模型

- 1 分钟前

一. 准备数据集

⚠️注意: OpenCV 需要切换到 3.4 版本,opencv4 编译 opencv_traincascade 会出现 Error。OpenCV4 更推荐用 RCNN 或其他神经网络来进行目标识别任务。

➜  bin git:(3.4) pwd
/Users/inger/opencv/opencv/build/bin

➜  bin git:(3.4)./opencv_createsamples -vec positive.vec -info ~/underground/datasets/positive.txt 18 -w 64 -h 64

➜  bin git:(3.4) cd ~/underground/datasets
➜  datasets ls
cascades            deform-collapse     negative.txt        obstacle            pipe                positive.vec
corrosion-damage    labelme             non-pipe            opencv_traincascade positive.txt
➜  datasets ./opencv_traincascade -data cascades -vec positive.vec -bg ~/underground/datasets/negative.txt -numPos 18 -numNeg 89 -numStages 5 -w 64 -h 64 -minHitRate 0.9999 -maxFalseAlarmRate 0.5 -mem 2048 -mode ALL
PARAMETERS:
cascadeDirName: cascades
vecFileName: positive.vec
bgFileName: /Users/inger/underground/datasets/negative.txt
numPos: 18
numNeg: 89
numStages: 5
precalcValBufSize[Mb] : 1024
precalcIdxBufSize[Mb] : 1024
acceptanceRatioBreakValue : -1
stageType: BOOST
featureType: HAAR
sampleWidth: 64
sampleHeight: 64
boostType: GAB
minHitRate: 0.9999
maxFalseAlarmRate: 0.5
weightTrimRate: 0.95
maxDepth: 1
maxWeakCount: 100
mode: ALL
Number of unique features given windowSize [64,64] : 13481422
参数 数值 说明
-data cascades 训练后生成xml的文件夹
-vec positive.vec 正向数据
-bg negative.txt 负向数据
-numPos 18 正向样本数
-numNeg 89 负向样本数
-numStages 5 训练迭代数
-w 64 图像宽
-h 64 图像高
-minHitRate 0.9999 期望最小检测率
-maxFalseAlarmRate 0.5 期望最大误检率
-mem 2048 使用的计算内存数(M)
-mode ALL 选择用来训练的haar特征集的种类
Inger Chao(赵琦)

Inger Chao(赵琦)

CS 研二在读

Inger Notes © 2021
rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora qq quora wechat