impoly crop frames from a webcam

1 次查看(过去 30 天)
SANG GYU LEE
SANG GYU LEE 2019-1-30
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);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by