How to Train Your Haar Classifier

I’ve been working with image processing in the last few months for a research project in SCoRe lab at UCSC. A part of the work required me to train a haar classifier.

Haar cascades are used to detect different objects in an image by using so-called haar-like features. Detection algorithm is based on the works of Viola and Jones. Although it’s not the sharpest tool in the shed (compared to HOG+SVM), it was the first to work real-time. Haar classifiers are widely used for face detection. Most image processing libraries like OpenCV and SimpleCV supports haar classifiers. And there are lots of trained classifiers on the internet. You just have to download the xml file and use it in your code.

But sometimes it really boils down to training your own classifier. Maybe because the ones in the web are not good enough or there are no classifiers available for your case at all.

Training a classifier is no easy job. You need a lot of positive images (images containing the object you want to detect) and negative images and hell of a lot of processing power. Fortunately there’s a great tutorial at Naotoshi Seo’s site which explains pretty much everything you need to know when it comes to training haar classifiers.

I used “opencv_traincascade” instead of “haartraining” which is now obsolete. “convert_cascade” doesn’t work with “opencv_traincascade” so I had to stop the training program and rerun it with one level reduced. This tricked it to produce the final cascade file with the intermediate training files.

Following result by my polkatu detector took 4800+ positive images and 2000+ negative images and 2 long months.

polkatu_detector.png

 
0
Kudos
 
0
Kudos

Now read this

Getting real time alerts from server to phone with Pushbullet

So I wanted to receive alerts from the long-running scripts on my Raspberry Pi. I used to have postfix to send an email but sometimes it took hours to notice the mail. I already had Pushbullet installed on Android, which is a service... Continue →