How do I perform time lapse image acquisition and save individual images?

2 次查看(过去 30 天)

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2021-2-25
Follow a modified form of the approach example is this example:
Instead of logging to disk, log data to memory. Use the FramesAcquiredFcn callback to save individual frames as images:
vid = videoinput('winvideo');
%% Do actual time-lapse acquisition
framerate = 17.5296; % Previously calculated according to example
capturetime = 30;
vid.FrameGrabInterval = 10;
vid.FramesPerTrigger = floor(capturetime * framerate / vid.FrameGrabInterval);
vid.FramesAcquiredFcnCount = 1; % Execute callback for each frame
vid.FramesAcquiredFcn = @saveFrame;
start(vid);
wait(vid, Inf);
function saveFrame(vid, event)
image = getdata(vid, 1);
imwrite(image, [num2str(vid.FramesAcquired) '.jpg']);
end

更多回答(0 个)

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by