72 GitHub stars and counting — spmallick/opencv-haar-classifier-training is a Perl project TopGit is tracking across repositories on the platform. Learn how to train your own OpenCV Haar classifier
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
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.
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.
Start training the classifier with opencv_traincascade, which comes with
OpenCV, and save the results to ./classifier:
After starting the training program it will print back its parameters and then start training. Each stage will print out some analysis as it is trained:
===== TRAINING 0-stage =====
<BEGIN
POS count : consumed 1000 : 1000
NEG count : acceptanceRatio 600 : 1
Precalculation time: 11
+----+---------+---------+
| N | HR | FA |
+----+---------+---------+
| 1| 1| 1|
+----+---------+---------+
| 2| 1| 1|
+----+---------+---------+
| 3| 1| 1|
+----+---------+---------+
| 4| 1| 1|
+----+---------+---------+
| 5| 1| 1|
+----+---------+---------+
| 6| 1| 1|
+----+---------+---------+
| 7| 1| 0.711667|
+----+---------+---------+
| 8| 1| 0.54|
+----+---------+---------+
| 9| 1| 0.305|
+----+---------+---------+
END>
Training until now has taken 0 days 3 hours 19 minutes 16 seconds.
Each row represents a feature that is being trained and contains some output about its HitRatio and FalseAlarm ratio. If a training stage only selects a few features (e.g. N = 2) then its possible something is wrong with your training data.
At the end of each stage the classifier is saved to a file and the process can be stopped and restarted. This is useful if you are tweaking a machine/settings to optimize training speed.
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).
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)
Material for Naotoshi Seo's tutorial
OpenCV Documentation - Cascade Classifier Training
Is spmallick/opencv-haar-classifier-training open source?
TopGit's metadata for spmallick/opencv-haar-classifier-training does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What is spmallick/opencv-haar-classifier-training?
spmallick/opencv-haar-classifier-training (spmallick/opencv-haar-classifier-training) is a Perl project on GitHub. From the project's own README: Learn how to train your own OpenCV Haar classifier
Where do I read more about spmallick/opencv-haar-classifier-training?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/spmallick/opencv-haar-classifier-training is the definitive source.
Read full README in the tab above.
Curious whether opencv-haar-classifier-training is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about opencv-haar-classifier-training.