A failed example of hand gesture recognition using openCV haartraining classifiers

haartraining performance

haartraining result

This example aimed to provide a good classifier that was able to recognise a flat contract palm in videos, but the results, as demonstrated in the haar performance evaluation, turned out quite disappointed. Here I list the details of this example, including the first stage of sampler extract, creating samples, training samples, and the final evaluation.

Note that this example was a very typical in terms of hand gesture recognition – it followed good procedural flows of haartraining and evaluation, but with low level accuracy of hand gesture recognition in video streams.

What this example aimed to do?

So far when I was typing these words there were still very few functions provided by openCV to be able to recognise natural hand gestures accurately, some laboratory demos may should improved recognition performance though.

For this reason, this example was proposed to provide a good hand gesture recognition function that was based on openCV haartraining. As a good starting point to detect complicated hand gestures, the example focused on flat contract palm gesture.


The example started from collecting a good number of gesture pictures, as required by haartraining, both positive pictures and negative pictures were collected with 4,000-5,000 pictures each category. A simple picture sampler was described in one prior article here haartraining sample picture collector.

hand gestures

haartraining progresses:

haartraining start

haartraining results

haartraining results2

haartraining results3

haartraining results4

all haartraining done until here.



Since the original outcomes of the haartraining were .txt files in respective folders, it needed a converter to produce .xml file for test use. The txt2xml converter can be found her haar converter.

Finally the test programme to see how the trained haar classifier worked with video streams. The test codes can be found here hand gesture haar test.

and the final outcomes:

haartraining performance

Author: Andol Li

A HCI researcher, a digital media lecturer, an information product designer, and a python/php/java coder.

30 Comments On “ A failed example of hand gesture recognition using openCV haartraining classifiers”

  1. nice !!
    i hope this project will not be closed !^^
    but do handgesture without kinect must be difficult beecause with a simple webcam cpu need do all the work ^^

    • @lainiwaku
      thank you for your concern, fortunately this did not have serious influence on the project – it is going another way now.
      about the difficulty of hand gesture detection without kinect, i guess, the most difficulty does not fall into the limitations of webcam and cpus, rather it is the weakness of algorithms that supported accurate hand gesture extraction from chaotic backgrounds. let me know if you have any good ideas about this.

  2. Hello i am reading this site for some time. I just want to say that i am satisfied by quality of information provided by the author.

  3. Andol,

    I’ve used your haar training xml file taked from here http://www.andol.me/hci/1830.htm. What’s the difference between 1256617233-1-haarcascade_hand.xml and 1256617233-2-haarcascade_hand.xml . I’ve used either with AS3 implementation of Viola-Jones feature detection algorithm (http://blog.inspirit.ru/?p=416) but hand isn’t detected. Also, using 1256617233-2-haarcascade_hand.xml slows the flash app, because it’s a Tree based cascade. Author advises using Stump based cascade for faster performance. Would you be able to release your cascades based on Stumps?

        • @Andol,
          I’ve seen several hand image databases, but they are only accessible to researchers. Here’re 2 I found: http://bosphorus.ee.boun.edu.tr/hand/Home.aspx
          If you’re a researcher, you can apply and mostly like access will be provided. I’m working for a private company, so I don’t think I’d be given access.

          I’m curious why OpenCV doesn’t include at very least hand detection cascade. It must be some top secret data! 🙂 I understand it’s a lot of work and people don’t want to share the results for nothing.

          As for cascade.xml used in CCV Hand project I’m not sure whether it’s xml problem or the AS3 problem that I use. More like likely hand cascade xml problem, because AS3 script, as you can see here http://blog.inspirit.ru/wp-content/uploads/facedetect/Main.swf , detect face features just fine. It uses opencv cascade files for face, mouth, eyes detection.

          • @sergi
            thanks for your information, I have registered the hand shape database and am waiting for the administrator’s approval to access the download – may be ok to share one with you for research purpose.

        • @sergi
          thanks for your kind help – actually I have 24/7 running computers, but they are not powerful enough and used to take ages to generate the final xml – and sometimes it happens that the xml doesnt have good detect results and needs to change some training paramters – in that case the time is totally wasted – that is why I need a powerful computer to do the training fast – last time it took me 6 days to train around 9,000 positive open palm positive samples, but the result was not satisfied.

        • @sergi
          I am going to do that – rent a amazon super computer for the haar training of varieties of hand gestures, money is not the biggest problem – I got some fundings from Google.
          you sparked me, sergi.

    • @sergi
      these xml files have been given up due to the incompatibility of hand detection, i believe, my colleagues have mentioned that to me before.

  4. I’ve just launched traincascade on open hands with LBP feature, which is supposed to train faster and generate more optimal cascade files.

    Here’s command to run training in the background when I’m logged out.

    $ nohup nice opencv_traincascade -data haar -vec vecfile.
    vec -bg negative.txt -numstages 20 -minHitRate 0.999 -maxFalseAlarmRate 0.5 -numPos 1602 -numNeg 3020 -mode ALL -w 20 -h 20 -baseFormatSave -featureType LBP >
    ../training.log 2> ../log.err < /dev/null &

  5. It also helps reduce the fat and cholesterol levels in your blood, which deters the body from storing too much excess fat.
    Pterostilbene is one natural compound that has been garnering a lot of attention because of its health benefits.

    Doctor Oz has called garcinia cambogia the “holy grail”
    of weight loss.

  6. Do you mind if I quote a few of your articles as long as I provide credit and sources back to your website?
    My website is in the exact same niche as yours and my users would genuinely
    benefit from some of the information you provide here. Please let me know if this alright with you.
    Thank you!

  7. Wow, marvelous blog layout! How long have you been blogging for?
    you make blogging look easy. The overall look of your site is great, let alone
    the content!

  8. I was wondering if you ever thought of changing the layout of
    your website? Its very well written; I love what youve got to say.

    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of text
    for only having 1 or two images. Maybe you could space it out better?

Leave a comment
Due to technical adjustments, the comment function is shortly closed and will be re-openning soon. Thanks.

Copyrights 2006-2018 © All rights reserved
Theme Tree2, re-designed by Andol Li, powered by WordPress and Bootsrap
WWW.ANDOL.ME | 浙ICP备15040508号-1
公安备案图标 浙公网安备33010602004018号
Back to top