# Train your own OpenCV Haar classifier
**Important**: This guide assumes you work with OpenCV 2.4.x. Since I no longer work with OpenCV, and don't have the time to keep up with changes and fixes, this guide is **unmaintained**. Pull requests will be merged of course, and if someone else wants commit access, feel free to ask!
This repository aims to provide tools and information on training your own
OpenCV Haar classifier. Use it in conjunction with this blog post: [Train your own OpenCV Haar
classifier](http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html).
## Instructions
1. Install OpenCV & get OpenCV source
brew tap homebrew/science
brew install --with-tbb opencv
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9.zip
2. Clone this repository
git clone https://github.com/mrnugget/opencv-haar-classifier-training
3. Put your positive images in the `./positive_images` folder and create a list
of them:
find ./positive_images -iname "*.jpg" > positives.txt
4. Put the negative images in the `./negative_images` folder and create a list of them:
find ./negative_images -iname "*.jpg" > negatives.txt
5. Create positive samples with the `bin/createsamples.pl` script and save them
to the `./samples` folder:
perl bin/createsamples.pl positives.txt negatives.txt samples 1500\
"opencv_createsamples -bgcolor 0 -bgthresh 0 -maxxangle 1.1\
-maxyangle 1.1 maxzangle 0.5 -maxidev 40 -w 80 -h 40"
6. Use `tools/mergevec.py` to merge the samples in `./samples` into one file:
python ./tools/mergevec.py -v samples/ -o samples.vec
Note: If you get the error `struct.error: unpack requires a string argument of length 12`
then go into your **samples** directory and delete all files of length 0.
7. Start training the classifier with `opencv_traincascade`, which comes with
OpenCV, and save the results to `./classifier`:
opencv_traincascade -data classifier -vec samples.vec -bg negatives.txt\
-numStages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1000\
-numNeg 600 -w 80 -h 40 -mode ALL -precalcValBufSize 1024\
-precalcIdxBufSize 1024
8. Wait until the process is finished (which takes a long time — a couple of
days probably, depending on the computer you have and how big your images are).
9. Use your finished classifier!
cd ~/opencv-2.4.9/samples/c
chmod +x build_all.sh
./build_all.sh
./facedetect --cascade="~/finished_classifier.xml"
## Acknowledgements
A huge thanks goes to Naotoshi Seo, who wrote the `mergevec.cpp` and
`createsamples.cpp` tools and released them under the MIT licencse. His notes
on OpenCV Haar training were a huge help. Thank you, Naotoshi!
## References & Links:
- [Naotoshi Seo - Tutorial: OpenCV haartraining (Rapid Object Detection With A Cascade of Boosted Classifiers Based on Haar-like Features)](http://note.sonots.com/SciSoftware/haartraining.html)
- [Material for Naotoshi Seo's tutorial](https://code.google.com/p/tutorial-haartraining/)
- [OpenCV Documentation - Cascade Classifier Training](http://docs.opencv.org/doc/user_guide/ug_traincascade.html)
# SRTP
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
关于篮球视频中的投篮镜头检测_SRTP.zip (29个子文件)
SRTP-master
samplesdescription.dat 107KB
tools
.DS_Store 14KB
get_video_frame.py~ 1015B
mergevec.py 6KB
get_negative_image.py~ 1KB
cutImage.py 1KB
hoop_tracker.py~ 1KB
cutImage.py~ 1KB
hoop_tracker.py 1KB
hoop_detection.py~ 1017B
get_video_frame.py 1018B
hoop_detection.py 1017B
get_negative_image.py 1KB
clean.sh 94B
auto.sh 526B
samples.vec 3.05MB
LICENSE 1KB
samples
.DS_Store 6KB
negatives.txt 224KB
clean.sh~ 75B
bin
createsamples.pl 3KB
classifier
.DS_Store 6KB
.gitkeep 0B
auto.sh~ 530B
hoop_detection.py 639B
README.md 3KB
trained_classifiers
.DS_Store 6KB
banana_classifier.xml 111KB
positives.txt 80KB
共 29 条
- 1
资源评论
好家伙VCC
- 粉丝: 1935
- 资源: 9137
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于 Python实现多模态语音和文本结合的情感识别(大模型finetune)高分项目代码
- shufflenet模型-基于深度学习AI算法对电路板瑕疵识别-不含数据集图片-含逐行注释和说明文档.zip
- shufflenet模型-基于卷积神经网络识别螃蟹-不含数据集图片-含逐行注释和说明文档.zip
- 技术资料分享zigbee无信标网络设备的加入非常好的技术资料.zip
- shufflenet模型-基于卷积神经网络识别单双眼皮-不含数据集图片-含逐行注释和说明文档.zip
- shufflenet模型-python训练识别河流岩石上的水生昆虫-不含数据集图片-含逐行注释和说明文档.zip
- 基于Matlab实现Stanley算法项目源码(下载即用)高分项目
- MapProjectInMatlab-Matlab工具箱使用资源代码
- 深度学习灰狼优化算法 matlab
- resnet模型-图像分类算法对捕食昆虫识别-不含数据集图片-含逐行注释和说明文档.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功