Thursday, 2 June 2011

Gesture recognition using Haar clasifier

Hiii, friends since some days, I have been working on Gesture recognition using  using Haar-like features. I havent been able to get very good results, owing to the lack of hand database. More over, the Classifier is taking hell lot of a time to get trained.

This is the result I got by using haar clasifier to train it for 2 gestures, my fist xml file being of nearly 70 kb, and xml file for L palm  being nearly 30 kb. They are indeed small, and so the result i get , u can see from the video.

For better results, I need to train my classifier with more positive images, nearly 3000, and negetive images nearly about 5000. Now, I am making my own collection of hand gestures :)
I heard of a Massey's Gesture database, but the link doesnt seem to be working. ( sighs )

But still u can use this database

I have started my training my new .xml files for closed fist or 'A' using 527 positive and 1142 negetive images, and it is taking like forever.( sighs ). I guess it may get fully trained within about three days. Then I will be posting my new results :)

 Using the results I get above, I tried simulating mouse movements, and clicking, I used my closed fist gesture to move the mouse, and the L palm for clicking. It wasnt that stable, but still, it works :) (cheers). Its fun..


  1. hi i want to ask you it is necssary that there should be more than 500 postive and ngeative image ?what does 30 stages mean?

    1. Hii Talha
      No, it is not necessary to use more than 500 +ve and -ve images, but the more the number of images we use to train, the better results we will get.
      If we use small number of images, then the results may not be satisfying. So, generally large number nearly 1000-3000 images are used to get good results.

      Training is finished, when required false alarm of cascade is achieved. 30 stages mean that the haar training will continue upto 30 stages or iterations, till the false alarm is acheived. A cascade can contain less than 30 satges if the false alarm is reached earlier.

    2. Thank you so much for reply

  2. hi @mit

    i'm working final project on gesture recognition using library emgu CV.
    Can i get your xml?
    I've tried some xml and these not working well, it still cannot distinguish between face and hand

    1. hii Yahya
      Check out this xml file to detect openpalm

      It works well with a whitish or yellow wall as background.
      Currently working on making my new xml files..Will post as soon as they are ready

    2. Thanx @mit. Good Luck with your new xml

      Maybe you can improve performance of detection by applying skin segmentation before processing image by haar classifier.

      Do you know or have any reference of description what every row mean inside haar xml file?

    3. Hii Sulha.Y
      I found this very useful..check it out

  3. Hi, how do you gather sample positive images? Does each picture needs to have a clear background? And, where do you test your xml files? What programming language and software do you use?

    Sorry for the many questions. Hope to hear from you soon.

    1. Hiii
      Positive images depends on what is it that you wan to detect. It need not have a clear background, but having it is more effective.
      I use OpenCV with C++ in codeblocks.
      To integrate OpenCV with Code::blocks follow

    2. Great, thanks. I've followed your tutorial in creating an xml file and I tested the generated xml file in Visual Studio 2010. Unfortunately it's not working. Any advice?

  4. Are u using openCV??
    Or any other library??
    How are you testing??

    1. Yes, I'am using openCV for generating xml files. But I'm using another library for testing, you can find it here It's a library for face detection in Windows Phone 7, but it can also detect other things such as hand gestures.

      If you have time, maybe you can take a look at it. Please :)
      The xml file can be found at the the folder Sample/models

  5. Hello. Can you send me a copy of your L-palm and fist xml files? I've trained a couple of xml files already and none has been detecting anything. I will just try your other xml files if I'm doing my testing right. Thanks.

  6. Hi!
    I used your tutorial to generate xml file to detect hand gesture with 2 fingers as positive. I can create the xml file. I used 10 positive images (hand gesture with 2 fingers opened) and 6 negative images (other images). But after I run the program, it detects lot of false positives. Even for hand gesture with 3 fingers opened, it detects it as positive. Please share ideas for better detection. Thanks!!!

  7. Hi dear first of all I must thank you..............

    I created my own xml files thanks to you ... By the way can I know do you have any xml files generated for vehicles or do you know any source to get them?

  8. A great work!!! Kudos to you!!!

    I have done my training with 3000 positive and 8000 negative. But am not able to get any input. Am doing my final year project in that and the time I have is short.

    Could you pls share your latest xml file for 2 gestures atleast?

    Am using it move a wheelchair in the real world. Pls help. Thanks in advance.

  9. Hey I use 1000 positive images and 4000 negative images with 20 stage.
    It got stuck at stage 6
    Can you help me pls...