# Hand detection in matlab

I am beginner and I want a help to know how to detect hand in Matlab.

First, I need code which detects skin and then draw a rectangle around a region so it show to me face and hand.

When I try to make rectangle only around hand and the hand is away from the face, the the rectangle is drawn around the face instead.

What do I need to do to discount the face and only draw the rectangle around the hand?

• Why don't you tell us what you've tried, and what you're trying to do with the detection? Your question is way too open-ended to get a sensible answer. – Peter K. Jun 8 '13 at 15:11
• first code which detect skin and then draw a rectangle around a region so it show to me face and hand and i try to made rectangle only around hand but when hand be away from face , the rectangle is drawn around face then what way correct ? – kjG Jun 8 '13 at 16:50
• I've tried to update your question with this information. Do you have any sample pictures? Please upload them to an image-sharing site and post the links in your question. We can insert them into the question (you will be able to when you have enough rep). – Peter K. Jun 8 '13 at 22:05
• sorry for replaying later i made it but it is not accurate can i upload it to you and can you help me to make it accurate ??? because our project is helping deaf people and the accurate of detecting hand is very important in our project – kjG Jun 17 '13 at 22:09
• Please upload them to an image-sharing site and post the links in your question. – Peter K. Jun 18 '13 at 0:51

As far as I can tell, Matlab's Computer Vision toolbox provides vision.CascadeObjectDetector for object detection, with support only for Frontal Face (CART),Frontal Face (LBP),Upper Body,Eye Pair,Single Eye,Single Eye (CART),Profile Face,Mouth,Nose. When you say: "the rectangle is drawn around the face instead.", that is happening because you are calling CascadeObjectDetector without specifying a specific object to detect, resulting in CascadeObjectDetector setting the to FrontalFaceCART by default. You are probably doing something like this:

detector = vision.CascadeObjectDetector;


Try doing this:

detector = vision.CascadeObjectDetector('Nose');


And you'll see how the nose is detected.

You are probably then getting excited, because it would be really easy then passing 'Hand' as a parameter instead of 'Nose', or anything. But unfortunately until now CascadeObjectDetector doesn't provide a model for 'Hand'. However, there exists a way to archieve this, the last ComputerVision toolbox provides the trainCascadeObjectDetector which you can use for detecting your own models(the hand for example). You'll see that this consists of a training process where you have to supply positive and negative images to develop your own detector, further explanations are given in the links. There is another useful tool you can use for this: a GUI tool for getting easier the classification process.

Hope this helps

• really Thank you very very much for your replaying :) – kjG Jun 17 '13 at 22:10