Can't save a video with VideoWrite: Error [Frame must be 550 by 420]
조회 수: 3 (최근 30일)
이전 댓글 표시
% video traiettoria
v = VideoWriter('traiettoria');
open(v);%
figure
scatter(0,0,200,'r','filled','s');
hold on;
grid on, grid minor, axis equal;hold on;
title('traiettoria AUV in coordinate ne USBL');
xlabel('est (m)');hold on;
ylabel('nord (m)'); hold on;
curve = animatedline('Color','b','LineStyle','-','LineWidth',1);
for k = 1:length(t_raw_sec)
addpoints(curve,e_no_outliers(k),n_no_outliers(k))
drawnow;
frame = getframe(gcf);
writeVideo(v,frame);
end
close(v);
I can't save the video because the frames are not the same size, I suppose...any suggestion?Thanks!
댓글 수: 0
답변 (1개)
Image Analyst
2020년 5월 4일
You need to set up the movie in advance so that all the frames are the same size. Here is a snippet you can modify.
% Set up the movie structure.
% Preallocate movie, which will be an array of structures.
% First get a cell array with all the frames.
allTheFrames = cell(numberOfFrames,1);
vidHeight = 344;
vidWidth = 446;
allTheFrames(:) = {zeros(vidHeight, vidWidth, 3, 'uint8')};
% Next get a cell array with all the colormaps.
allTheColorMaps = cell(numberOfFrames,1);
allTheColorMaps(:) = {zeros(256, 3)};
% Now combine these to make the array of structures.
myMovie = struct('cdata', allTheFrames, 'colormap', allTheColorMaps);
For a full demo, see my attached demo, movie_made_from_surf.m, where I make a movie out of a figure that I'm animating.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!