フィルターのクリア

forming video from frames

1 回表示 (過去 30 日間)
Nidhi Kumari
Nidhi Kumari 2018 年 7 月 11 日
コメント済み: Nidhi Kumari 2018 年 7 月 11 日
I have used the following code to form a video from 287 frames but the 'baseFileName' is formed in the order - frame1,frame10,frame100,....frame109,frame2,frame20,........frame287.The for loop is working properly.So kindly help in finding the error.I found this code online.
myFolder = 'C:\Users\yourUserName\Documents';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.PNG');
pngFiles = dir(filePattern);
writerObj = VideoWriter('YourAVI.avi');
for frameNumber = 1 : length(pngFiles)
baseFileName = pngFiles(frameNumber).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
thisimage = imread(fullFileName);
imshow(imageArray);
drawnow;
writeVideo(writerObj, thisimage);
end
close(writerObj);

採用された回答

Michiele Ogbagabir
Michiele Ogbagabir 2018 年 7 月 11 日
The problem seems to come from the way the files are sorted when you read them into pngFiles. They look like they are sorted in lexicographic order. You might want to check this question on how to sort them differently.
  1 件のコメント
Nidhi Kumari
Nidhi Kumari 2018 年 7 月 11 日
Thankyou so much. I got my answer :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by