impoly crop frames from a webcam
Afficher commentaires plus anciens
I am getting an error when I try to crop a polygon area from a webcam video (which only shows the cropped polygon from the frame)
vid=videoinput('macvideo',1,'YCbCr422_1280x720');
set(vid,'FramesPerTrigger',Inf);
set(vid,'ReturnedColorspace','rgb');
vid.FrameGrabInterval=5;
start(vid);
data=getsnapshot(vid);
imshow(data);
h = impoly();
position = wait(h);
BW = createMask(h);
while(vid.FramesAcquired<=100)
data=getsnapshot(vid);
data(~BW) = 255;
imshow(data);
end
stop(vid);
flushdata(vid);
clear all;
When I run this script, I see a snapshot of my webcam where I can draw a polygon on it. But that is it. When I close the image after setting a polygon, it gives me an error
Invalid or deleted object.
Error in imroi/parseInputsForCreateMask (line
90)
h_ax = ancestor(obj.h_group,'axes');
Error in imroi/createMask (line 258)
[obj,h_im] =
parseInputsForCreateMask(varargin{:});
Error in camshift2 (line 11)
BW = createMask(h);
Réponses (0)
Catégories
En savoir plus sur Motion Detection dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!