Performing Edge Detection using a Webcam using Image Acquistion and Computer Vision Toolboxes
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I am currently trying to use Matlab to perform object edge detection on a live video feed using a webcam. I am able to do this quite easily using the Computer Vision Simulink blocks. However, I prefer to do this using MATLAB utilizing the functions available both in the Image Acquisition and Computer Vision Toolboxes (R2012a). My code is below:
hVideoSrc = imaq.VideoDevice('winvideo', 1, 'I420_320x240', ...
'ROI', [1 1 320 240], ...
);
hEdge = vision.EdgeDetector( ...
'Method', 'Prewitt', ...
'ThresholdSource', 'Property', ...
'Threshold', 15/256, ...
'EdgeThinning', true);
hAB = vision.AlphaBlender('Operation', 'Highlight selected pixels');
WindowSize = [300 300];
hVideoEdges = vision.VideoPlayer('Name', 'Edges');
hVideoEdges.Position = [210 hVideoOrig.Position(2) WindowSize];
while ~isDone(hVideoSrc)
frame = step(hVideoSrc);
edges = step(hEdge, frame);
composite = step(hAB, frame, edges);
step(hVideoEdges, edges);
end
As you can see there's nothing fancy in my code. Everytime I try and run this I get the following error:
Undefined function 'isDone' for input arguments of type 'imaq.VideoDevice'.
Error in ComputerVisionToolboxTest5 (line 19)
while ~isDone(hVideoSrc)
Any ideas why this is happening?
Your help would be really appreciated.
Regards,
Mo
0 件のコメント
採用された回答
David Tarkowski
2013 年 2 月 26 日
A VideoDevice object never runs out of data to return since it can always capture another frame. Because of this, there is no isDone method for such objects. You will need to find some other condition to test in your while loop.
1 件のコメント
yogeshwar kansara
2015 年 4 月 14 日
編集済み: yogeshwar kansara
2015 年 4 月 14 日
I am getting the similar error in my kinect sensor implementation code; but with the different function i am using. I found that function from mathworks website and the method is correct too.
clc clear all
utilpath = fullfile(matlabroot, 'toolbox', 'imaq', 'imaqdemos', ... 'html', 'KinectForWindows'); addpath(utilpath);
hwInfo = imaqhwinfo('kinect'); %colorDevice = videoinput('kinect',1);
%depthDevice = videoinput('kinect',2);
colorDevice = imaq.VideoDevice('kinect',1)
depthDevice = imaq.VideoDevice('kinect',2)
colorDevice.ReturnedDataType = 'uint16';
step(colorDevice);
step(depthDevice);
colorImage = step(colorDevice);
depthImage = step(depthDevice);
%flippedDepthImage=fliplr(depthImage);
%xyzPoints = depthToPointCloud(depthImage,depthDevice);
[xyzPoints,flippedDepthImage] = depthToPointCloud(depthImage,depthDevice);
Error is in the depthToPoinCloud(...) method.
What should be the problem? Thank you in advance.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!