Problem in recording video from webcam in matlab 2015

4 Ansichten (letzte 30 Tage)
Ali Tareq
Ali Tareq am 21 Mär. 2016
Kommentiert: Madhura Suresh am 24 Mär. 2016
To record video from webcam I've used following code in matlab 2015:
clear all;
clc;
vid = videoinput('winvideo',1, 'YUY2_640x480');
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb');
vid.FrameGrabInterval = 1;
start(vid)
aviObject = VideoWriter('myVideo.avi');
for iFrame = 1:100
I=getsnapshot(vid);
F = im2frame(I);
aviObject = addframe(aviObject,F);
end
aviObject = close(aviObject);
stop(vid);
But it seems to be working but following error resulted:
Error using imaqdevice/getsnapshot (line 65) A timeout occurred during GETSNAPSHOT.
Error in recording_video (line 17) I=getsnapshot(vid);
What is the problem?
  2 Kommentare
Walter Roberson
Walter Roberson am 21 Mär. 2016
Bearbeitet: Walter Roberson am 21 Mär. 2016
Are you able to preview() the webcam?
Is the timeout appearing on the first frame, or after several have been captured?
Madhura Suresh
Madhura Suresh am 24 Mär. 2016
Instead of adding the frame each time to the aviObject, have you tried attaching the VideoWriter to the videoinput object?
See this link for more information.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by