Is it possible to get timestamp information from ''getsnapshot'' function in Image Acquisition toolbox?

7 views (last 30 days)
Malu on 19 Aug 2020
Commented: Malu on 2 Sep 2020
Hello everyone!
I have started to work with the Image Acquisition toolbox, and to acquire data I have used the videoinput object and the getdata function up to now.
I wanted to make a comparisson with the getsnapshot but I can't get the timestamps data. The code up to now is as below :
for f =1:200
[frames, ts] = getsnapshot(vid);
elapsedtime = toc;
save('Timestamp.mat' , 'ts');
save('Frames.mat', 'frames');
But it saves only the absolute time of trigger and only 3 frames even though during the running of the program I can see that index f is incremented.
Is there smth I am doing wrong?
Or how could I approach to get the frames and timestamps information for 200 frames ?
Thank you in advance for your help!

Accepted Answer

Alan Moses
Alan Moses on 1 Sep 2020
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); %depends on your InstalledAdaptors - check by running 'imaqhwinfo'
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
[frames, ts] = getsnapshot(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;
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.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!