필터 지우기
필터 지우기

VideoWriter is only showing the last figure as opposed to full 135 image movie

조회 수: 1 (최근 30일)
Here is my code:
myFolder = 'C:\Users\Authorised User\Documents\MATLAB\OilDropForceImages\OilDropForceImagesResized'; 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);
for k = 1:length(pngFiles)
baseFileName = pngFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
imshow(imageArray, 'InitialMagnification', 77);
% Display image.
drawnow; % Force display to update immediately.
end
A = imageArray;
hold on
vid0bj = VideoWriter('OilDropForceMovie','MPEG-4');
open(vid0bj);
writeVideo(vid0bj,A)
hold off
close(vid0bj)
This code plots in MATLAB the full video I want to see which lasts roughly 20 seconds but when I convert it to windows media player it is only showing the final image. What am i doing wrong?

채택된 답변

Giridharan Kumaravelu
Giridharan Kumaravelu 2018년 7월 24일
You are writing the video outside of the loop, that is why you are seeing only the last image. Move the writeVideo command inside the loop, you will find the full plot video getting saved.
Hope this helps!
  댓글 수: 1
james Brown
james Brown 2018년 7월 24일
Thanks that makes a lot of sense. haha problem now is that permission is being denied to create the mp4 file but I'll try and sort this problem myself

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by