HaarTraining Exploration

December 14th, 2008 life 9 comments

Haar Tracking
So I have been trying to learn how to build Haarcascade files. There really is zero documentation online for this process, so its hard to tell if you are doing it right or wrong. This is where I am so far:

step 1:
You need to collect a bunch of negative images. Images that do not have the object that you are trying to track. You need to create a .dat file; a file that is just a list of all the images in a directory.

step 2:
There are a couple of techniques for step two. Opencv can generate positive samples from one image of the object you want to track, this is not the best technique but does work.
when you do this you get a bunch of images that look something like this.
Haar Training
Haar Tracking
The other approach is to have a series of positive images that are cropped. I think that this is the more accurate approach. I needed figure out how the openCv executable was building these samples. After figuring this out I build an app that loads a series of images that you can click all the objects in the image. You can also use a video camera to add more images and save out images. Here is a demo of the app working.

step 3:
Now you just need to train. Running the opencv haar training executable you will generate an .xml file to load in a haarTracking app. I am still learning all the settings for this step. The perfect tweak of the setting will give you the best result for what you want to track.

Here is what I have been able to get so far. The results are not to bad but I need to learn some more. Any help would be great.

9 Responses to “HaarTraining Exploration”

  1. Mark Steedman

    Hi Todd

    I am a student at Westminster University, London, and am currently working on a project where I am trying to use opencv’s haartraining to recognise hand gestures. I have positive and negative samples, but don’t really know where to go from here…or how to do it?

    I am trying to follow a few guides, but they make no sense to me as I am new to opencv/openframeworks/c++…

    Also, my haartraining.exe application quits as soon as I open it…is this normal?

    If you have any advice I would appreciate this greatly.

    Kind Regards

    Mark Steedman

  2. Jon

    Dude, great stuff.

    Any chance that you could give me that app you built for loading the positives images and then outlining them?

    Pretty please :D

    Jon

  3. nataly

    please I’m student from Peru , and I need to learn to use it, i dont understand how to have an empty project, to use and inicializate whit my own samples.
    thanks
    my email is natalybsa@gmail.com
    natalybsa@hotmail.com

  4. vinhvo

    Hi, can you point me out where can i get those negative samples ?
    Thank you.

  5. kutake

    Hi

    I’m at University of Zaragoza, Spain. I’m working on an app that counts the number of boxes in a small warehouse. For this project I’m using OpenCV, and I’m having some problems with the images.
    I would be very grateful if you could send me your fabulous app to use it into my project and to make my life easier.

    Thanks for all

  6. leo

    Hello,

    I work with OpenCV, but for the location of objects I use objectmarker but it’s not very practical. What software do you use in your video to retrieve objects?

    Thanks for all

  7. Wim Vanhenden

    Hi,

    Todd I was wondering how many positive vs negative samples you used to build this example?

    Thanks a lot for your help.

    Kind regards,

    Wim

  8. Bruce

    Hello,

    I work with OpenCV, but for the location of objects I use objectmarker but it’s not very practical. What software do you use in your video to retrieve objects?

    Thanks for all

Say Something