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!