How to add changing captions to MATLAB movie

2 views (last 30 days)
Kelli
Kelli on 28 Oct 2015
Edited: Kelli on 28 Oct 2015
I have the following script for a movie:
clc;
clear;
% Make an avi movie from a collection of PNG images in a folder.
% Specify the folder.
myFolder = 'C:\Users\Kelli\Documents\MATLAB\DP2015';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% Get a directory listing.
filePattern = fullfile(myFolder, '*.jpg');
jpgFiles = dir(filePattern);
% Open the video writer object.
writerObj = VideoWriter('DPmov.avi');
% Go through image by image writing it out to the AVI file.
for frameNumber = 1 : length(jpgFiles)
% Construct the full filename.
baseFileName = jpgFiles(frameNumber).name;
fullFileName = fullfile(myFolder, baseFileName);
% Display image name in the command window.
%fprintf(1, 'Now reading %s\n', fullFileName);
% Display image in an axes control.
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
% Write this frame out to the AVI file.
imageNames = dir(fullfile(myFolder,'images','*.jpg'));
imageNames = {imageNames.name}';
for ii = 1:length(imageNames)
img = imread(fullfile(workingDir,'images',imageNames{ii}));
writeVideo(writerObj, thisimage);
end
end
% Close down the video writer object to finish the file.
The photos are time-lapse photos that are taken every hour. Is there a way to make a time stamp on each photo for when it was taken? I can't make my own timeline starting from the first time the photo was taken because there are gaps in the photos when the camera battery died.
Also--sorry sneaking another question in here--can I save the movie as .mov file?
I tried adding the following to the end, but it didn't work...
%--- convert to a quicktime movie ---%
axis([0 5 0 5]);
for i = 0:5
s = line(i,i,'Marker','o');
M(i+1) = getframe;
delete(s);
end
makeqtmovie('start','DPmovie.mov');
makeqtmovie('quality',1);
for i = 1:length(M)
movie(M(:,i));
makeqtmovie('addaxes');
end
makeqtmovie('finish');

Answers (0)

Community Treasure Hunt

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

Start Hunting!