作者wantfly1324 (风飙扬)
看板MATLAB
标题[其他] Webcam以被使用
时间Fri Oct 3 10:43:41 2014
最近在尝试用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.
想请问这要怎麽解决?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 134.139.169.120
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MATLAB/M.1412304223.A.3B7.html
1F:推 x46824682x: close all 10/04 19:22