I want to build up hand gestures detection and recognition algorithm, I need help with my code and sadly it doesn't work

2 views (last 30 days)
Ahmed El Sheikh
Ahmed El Sheikh on 10 Jul 2016
Commented: Image Analyst on 12 Jul 2016
%vid to intialize a variable to save incoming video %videoinput to get video from webcam, video format, adopter number
vid = videoinput('winvideo', 1);
%Frames per trigger specifies the number of frames acquired, inf used %to state that frames will be acquired till an error occurs or stopped
%Returned color space is rgb as we are using this format
%extract images every 5 milli-second
%start acquiring video
while(vid.FramesAvailable <= 20)
% Get a snapshot of the current frame
data = getsnapshot(vid);
%Skin Color Extraction
% Here we do the image blob analysis.
% We get a set of properties for each labeled region.
stats = regionprops(roi, 'BoundingBox', 'Centroid');
hold on
%This is a loop to bound the skin colour in a rectangular box.
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
plot(bc(1),bc(2), '-m+')
hold off
stop(vid); flushdata(vid);

Answers (1)

Image Analyst
Image Analyst on 10 Jul 2016
It looks like your skin detection is all messed up. Whoever told you to use graythresh() for finding skin tone colored blobs in your image is mistaken. You need to customize your threshold to use fairly fixed thresholds. graythresh() tries to automatically find a threshold based on what's there and it can get confused if there is not enough skin tone, or too much, or the presence of other colors. Try the Color Thresholder app on the Apps tab of the tool ribbon to home in on the threshold you should use.
Image Analyst
Image Analyst on 12 Jul 2016
Why? Do you have flesh colored hands in front of a flesh colored background screen? I'd hope not. Why not attach an image so we can see it? Edge detection is rarely the best solution - I don't know why everyone wants to try it as a first step. I'm pretty sure you're best off looking at the colors of the hand and surrounding scene rather than doing edge detection, because, after all, things like faces and clothing will also have lots of edges in them so how will you tell the difference between hand edges and clothing edges? Maybe if only the hands are moving you can use optical flow, or combine optical flow with color segmentation.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!