hand detection in image

4 views (last 30 days)
Math
Math on 21 May 2014
Commented: Sadiq on 29 Jun 2014
My program captures an image from the webcam, and this image that I want to isolate the hand but is not working. Regionprops tried to grab his hand as the second largest area of the image after the head, but does not recognize. Need urgent help to fix the problem, Thanks!
Sorry for bad english, I'm foreign
my program:
% Starting Webcam . vid = videoinput ( ' Winvideo ', 1 ' RGB24_640x480 '); vid.FramesPerTrigger = 1; preview ( vid ) ; start ( vid ) ; % Get the image and display it pause ( 10 ) % Timeout 10s to initialize camera rgbImage = getSnapshot ( vid ) ; imshow ( rgbImage ) ; % Save the Picture on the Desktop saveas ( gcf , ' Imagemteste.jpg ' ) ; pause ( 3 )
% Define variables format long g ; format compact ; fontSize = 20 ; % Open Image folder = ' C : \ Users \ Castle \ Desktop ' ; BaseFileName = ' Imagemteste.jpg ' ; % Full name prefixed with path FullFileName = fullfile (folder , BaseFileName ) ;
% Convert to grayscale grayImage = imread ( FullFileName ) ; % Taking the error , converts the image to grayscale using only the channel % green [ rows , columns , numberOfColorBands ] = size ( grayImage ) ; if numberOfColorBands > 1 grayImage grayImage = ( : , : , 2 ) ; end
% Display the image in grayscale subplot ( 2 , 2, 1 ); imshow ( grayImage [ ] ); on axis ; title (' Original Image Grey ', ' FontSize ' , fontSize ) ; % Binarizar Image binaryImage grayImage = < 128 ; subplot ( 2 , 2, 2 ); imshow ( binaryImage [ ] ); title (' binarized image ', ' FontSize ' , fontSize ) ; % labels each object in a binary image labeledImage = bwlabel ( binaryImage ); % Measures the size of each region detected measurements regionprops = ( labeledImage , ' BoundingBox ', ' Position ' ) ; for k = 1 : length ( measurements ) = thisBB measurements ( k ) BoundingBox . ; rectangle ( ' Position' , [ thisBB (1) thisBB (2) thisBB (3) thisBB (4)] , " EdgeColor ',' r ' , lineWidth 2 ) end % Extract the hand which is the second largest element of the image allAreas = [ measurements.Area ] ; [ sortedAreas , sortingIndexes ] = sort ( allAreas , ' descend ' ) ; % sort in ascending order handIndex = sortingIndexes (2); Using IsMember % ( ) to extract the hand from the labeled image . handImage = IsMember ( labeledImage , handIndex ) ; 1 % Binarizar again handImage handImage = > 0 ; % Plot the final image subplot ( 2 , 2, 3); imshow ( handImage [ ] ); title (' Image of Hand ', ' FontSize ' , fontSize ) ;
  1 Comment
Sadiq
Sadiq on 29 Jun 2014
hi dear i am working on the same project, my task is also to recognize hand from video frames, it will be very nice of you if you help me,, my email id is sadiqanusar@gmail.com,

Sign in to comment.

Answers (0)

Categories

Find more on Image Processing and Computer Vision in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!