Performing Edge Detection using a Webcam using Image Acquistion and Computer Vision Toolboxes
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mo
il 26 Feb 2013
Modificato: yogeshwar kansara
il 14 Apr 2015
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 Commenti
Risposta accettata
David Tarkowski
il 26 Feb 2013
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 Commento
yogeshwar kansara
il 14 Apr 2015
Modificato: yogeshwar kansara
il 14 Apr 2015
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Computer Vision with Simulink in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!