フィルターのクリア

Can I use blob detection to detect my hand?

3 ビュー (過去 30 日間)
Anjana Rao
Anjana Rao 2014 年 2 月 14 日
回答済み: zhang 2014 年 4 月 25 日
I want to detect my hand from a video, and I've used the blob detection code from ImageAnalyst's file exchange to try and do it, but it won't work. Can someone tell me where I'm going wrong? Or suggest some other method for hand detection? Here's the code I've used:
clc;
clear all;
close all;
closepreview;
vid = videoinput('winvideo', 1, 'YUY2_640x480'); %specify the video adaptor
src = getselectedsource(vid);
vid.ReturnedColorspace = 'grayscale'; %define the color format to GRAYSCALE
vid.FramesPerTrigger = 5;
preview(vid); %preview the video object
while(1)
preview(vid); %preview the video object
currentimg=getsnapshot(vid); %capture the image of interest
grayImage = currentimg;
% Get the dimensions of the image. numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Binarize the image.
binaryImage = im2bw(grayImage,0.58);
binaryImage = imfill(binaryImage, 'holes');
binaryImage = bwareaopen(binaryImage, 8000);
[labeledImage numberOfBlobs] = bwlabel(binaryImage, 8);
% Get all the blob properties.
blobMeasurements = regionprops(labeledImage, 'BoundingBox','Area');
allBlobAreas = [blobMeasurements.Area];
% Display the original gray scale image.
imshow(grayImage, []);
% Loop through all blobs, putting up Bounding Box.
hold on; % Prevent boxes from blowing away the image and prior boxes.
for k = 1 : numberOfBlobs
boundingBox = blobMeasurements(k).BoundingBox; % Get box.
x1 = boundingBox(1);
y1 = boundingBox(2);
x2 = x1 + boundingBox(3) - 1;
y2 = y1 + boundingBox(4) - 1;
verticesX = [x1 x2 x2 x1 x1];
verticesY = [y1 y1 y2 y2 y1];
plot(verticesX, verticesY);
end
end
Thank you!

採用された回答

Image Analyst
Image Analyst 2014 年 2 月 14 日
"it won't work" is not very descriptive. Can you attach an image/snapshot that it did not work for. You may need to adjust your threshold.
  9 件のコメント
Image Analyst
Image Analyst 2014 年 2 月 16 日
No one can say without looking at code. Put a stop in your catch statement and then investigate variables.
Anjana Rao
Anjana Rao 2014 年 2 月 17 日
Okay! Thank you again!

サインインしてコメントする。

その他の回答 (1 件)

zhang
zhang 2014 年 4 月 25 日
mark

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by