Yes, it is possible to store the frames and timestamp data. You may use the start and stop function inside the loop to avoid logging only time of trigger. You can save the frames data by initializing a 4-D vector based on your loop size. The following example captures 5 frames:
vid = videoinput('winvideo', 1);
obj_info = imaqhwinfo(vid);
frame_len = 5;
frame_record = zeros(obj_info.MaxHeight,obj_info.MaxWidth,vid.NumberOfBands,frame_len,'uint8');
time_stamp = NaT(frame_len,1);
for f =1:frame_len
start(vid)
[frames, ts] = getsnapshot(vid);
stop(vid);
t = fix(ts.AbsTime);
t = datenum(t);
d = datetime(t,'Format','HH:mm:ss','convertFrom','datenum');
time_stamp(f,1) = d;
frame_record(:,:,:,f) = frames;
end
save('Timestamp.mat' , 'time_stamp');
save('Frames.mat', 'frame_record');
The code runs for a longer time as compared to using start and stop outside the loop, but this can be one way to ensure correct timestamp logging.
Best Answer