最近在嘗試用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.
想請問這要怎麼解決?