最近在尝试用MATLAB来使用Webcam来录制影片
但是在跑MATLAB网站上的程式码
clear all;
clc;
vid = videoinput('winvideo',1, 'YUY2_320x240');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb');
vid.FrameGrabInterval = 1;
start(vid)
aviObject = VideoWriter('myVideo.avi'); % Create a new AVI file
for iFrame = 1:100 % Capture 100 frames
I=getsnapshot(vid);
F = im2frame(I); % Convert I to a movie frame
aviObject = addframe(aviObject,F); % Add the frame to the AVI file
end
aviObject = close(aviObject); % Close the AVI file
stop(vid);
在跑这个程式码时,会出现下面这个错误
winvideo: The device associated with device ID 1 is already in use. A
new videoinput object cannot be created for this device while it is in
use.
想请问这要怎么解决?