Displaying all frames after capturing video on webcam

1 次查看(过去 30 天)
I want to display frames after capturing live video from webcam. The number of frames are specified in while loop.I am using imaqmontage but it displays only last frame where should I place this function so that I get all the frames capture after I stop my webcam.below is my code:
a = imaqhwinfo;
%[camera_name, camera_id, format] = getCameraInfo(a);
% Capture the video frames using the videoinput function
% You have to replace the resolution & your installed adaptor name.
vid = videoinput('winvideo');
% Set the properties of the video object
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
vid.FrameGrabInterval = 5;
%start the video aquisition here
start(vid)
figure
% Set a loop that stop after 100 frames of aquisition
while(vid.FramesAcquired<=20)
% Get the snapshot of the current frame
data = getsnapshot(vid);
[frames timestamp] = getdata(vid,1);%to capture every available frame
subplot(2,2,1:2);
imshow(data)
subplot(2,2,3); imshow(frames)
subplot(2,2,4); imcontour(rgb2gray(frames),2);
% Display the image
set(gca, 'xticklabel', []);
set(gca, 'yticklabel', []);
xlabel([ 'Time Stamp t=' num2str(timestamp, '%2.1f') 'seconds']);
pause(.5);
end
stop(vid);
a = axes;
%Display each image frame acquired on axes a.
imaqmontage(data, 'Parent', a);

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by