MATLAB: Performing Edge Detection using a Webcam using Image Acquistion and Computer Vision Toolboxes

computer visionComputer Vision Toolboxedge detectionImage Acquisition Toolboximage acquistionlive video

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

Best Answer

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.
Related Question