Effacer les filtres
Effacer les filtres

Can't save a video with VideoWrite: Error [Frame must be 550 by 420]

2 vues (au cours des 30 derniers jours)
Valeria Leto
Valeria Leto le 4 Mai 2020
% 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!

Réponses (1)

Image Analyst
Image Analyst le 4 Mai 2020
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.

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by