필터 지우기
필터 지우기

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

조회 수: 1 (최근 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

채택된 답변

David Tarkowski
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
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 CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by