Reputation: 177
Here is my test code to capture frames from webcam. The feed terminates prematurely. I don't know why. Someone, help. Only two or three frames are captured and then it exits prematurely.
vid = videoinput('winvideo', 1);
triggerconfig(vid, 'manual');
set(vid, 'FramesPerTrigger', 1);
set(vid, 'TriggerRepeat', inf);
set(vid, 'ReturnedColorSpace', 'grayscale');
start(vid);
try
while(vid.FramesAcquired <= 3)
trigger(vid);
img = getdata(vid);
imshow(img);
hold on;
disp('acquired');
end
catch
disp('Error');
stop(vid);
end
disp('exit');
stop(vid);
Upvotes: 2
Views: 339
Reputation: 6424
check this line of code:
while(vid.FramesAcquired <= 3)
change the number (3) to the number of the frames you need.
Upvotes: 1