How to generate .txt file including exposure time and timestamp ?
1 view (last 30 days)
Show older comments
Hi,
I am acquising video from image acquisition toolbox. Afterwards, I am splitting the video into frames starting from 00000.jpg to the last frame. My actual aim is to generate a .txt file which must consists of image-ID (00000.jpg), timestamp and exposure time (respectively as below). These data should be written into the file as number-of-images by 3. A sample visualization of the file is as below;
00000 1461161056.2800557613 3.6060349941
00001 1461161056.3000824451 3.6060349941
00002 1461161056.3200588226 3.6060349941
00003 1461161056.3400502205 3.6060349941
00004 1461161056.3600392342 3.6060349941
00005 1461161056.3800461292 3.6060349941
00006 1461161056.4000482559 3.6060349941
00007 1461161056.4200584888 3.6060349941
00008 1461161056.4400272369 3.6060349941
00009 1461161056.4600312710 3.6060349941
00010 1461161056.4800560474 3.6060349941
. . .
. . .
. . .
Splitting code is:
% Open an sample avi file
filename = 'C:\Users\Ender\Desktop\Example7.avi';
mov = VideoReader(filename);
% Output folder
outputFolder = fullfile(cd, 'frames7');
if ~exist(outputFolder, 'dir')
mkdir(outputFolder);
end
%getting no of frames
numberOfFrames = mov.NumberOfFrames;
numberOfFramesWritten = 0;
for frame = 1 : numberOfFrames
thisFrame = read(mov, frame);
outputBaseFileName = sprintf('%3.5d.jpg', frame-1);
outputFullFileName = fullfile(outputFolder, outputBaseFileName);
imwrite(thisFrame, outputFullFileName, 'jpg');
progressIndication = sprintf('Wrote frame %4d of %d.', frame,numberOfFrames);
fprintf(progressIndication);
numberOfFramesWritten = numberOfFramesWritten + 1;
end
progressIndication = sprintf('Wrote %d frames to folder "%s"',numberOfFramesWritten, outputFolder);
disp(progressIndication);
How can I obtain such .txt file ?
2 Comments
Rik
on 25 Dec 2018
If you can obtain the requiered values inside the loop, it is trivial to write it to a text file with fprintf.
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!