how to construct a video from frames

am constructing video from frames... now i delete a frame... but then also i need to construct video from remaining frames... it can be the first frame i'm deleting or last frame or any other frame... still it must construct video with the remaining frames...
please help me with what modification i need to do here.... please reply...
here's the code i used to construct video when all frames are there..
for frame = 1 : numberOfFrames
outputBaseFileName = sprintf('%d.jpg', frame);
outputFullFileName = fullfile('frame', outputBaseFileName);
% Read the image in from disk.
thisFrame = imread(outputFullFileName);
% Convert the image into a "movie frame" structure.
recalledMovie(frame) = im2frame(thisFrame);
end
% Create new axes for movie.
fontSize=14;
figure;
set(gcf, 'Position',get(0,'Screensize')); % Maximize figure.
axis off;
title('Movie recalled from disk', 'FontSize', fontSize);
% Play the movie in the axes.
movie(recalledMovie);

 Réponse acceptée

Image Analyst
Image Analyst le 21 Nov 2012
Just change your for loop to start with the frame you want to begin with:
for frame = beginningFrameNumber : numberOfFrames

7 commentaires

Elysi Cochin
Elysi Cochin le 22 Nov 2012
sir i want to start with the first frame in the folder only... but in case any frame is missing also it shud continue with the next frame... for that what shud i do... si i need to check if that particular frame exists... if exists add to video if not exixts continue with next frame... like that i want... will that way work??
Use exist() to check if it exists and skip it if it is missing.
for frame = 1 : numberOfFrames
outputBaseFileName = sprintf('%d.jpg', frame);
outputFullFileName = fullfile('frame', outputBaseFileName);
% Skip this file if it does not exist.
if ~exist(outputFullFileName, 'file')
continue;
end
% Read the image in from disk.
thisFrame = imread(outputFullFileName);
% Convert the image into a "movie frame" structure.
recalledMovie(frame) = im2frame(thisFrame);
end
Walter Roberson
Walter Roberson le 22 Nov 2012
Test with exists() or place a try/catch around the imread()
Elysi Cochin
Elysi Cochin le 22 Nov 2012
sir when i run the above code the following error is coming...
??? Error using ==> movie Movie contains uninitialized frames
Error in ==> HumanInpainting>Reconstruct_Motion_Sequence_pushbutton_Callback at 551 movie(recalledMovie);
why sir???
Walter Roberson
Walter Roberson le 22 Nov 2012
When you say that it should continue on with the next frame when an image is missing, do you mean that it should duplicate the last frame that does exist, or do you mean that there should just be no frame at that point, resulting in a movie with fewer frames than the file numbers would hint ?
outframe = 0;
for frame = 1 : numberOfFrames
outputBaseFileName = sprintf('%d.jpg', frame);
outputFullFileName = fullfile('frame', outputBaseFileName);
% Skip this file if it does not exist.
if ~exist(outputFullFileName, 'file')
continue;
end
% Read the image in from disk.
thisFrame = imread(outputFullFileName);
% Convert the image into a "movie frame" structure.
outframe = outframe + 1;
recalledMovie(outframe) = im2frame(thisFrame);
end
Elysi Cochin
Elysi Cochin le 22 Nov 2012
thank u so much... its working... thanks a lot...

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by