Is it possible to get timestamp information from ''getsnapshot'' function in Image Acquisition toolbox?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 :
start(vid)
for f =1:200
tic;
[frames, ts] = getsnapshot(vid);
elapsedtime = toc;
end
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!
0 Kommentare
Akzeptierte Antwort
Alan Moses
am 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
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Acquisition Using Any Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!