Rapid image capture for video assembly?
Mostrar comentarios más antiguos
I am trying to make a video using the code given below. It is very slow. A test run took circa 2 hrs 20 mins. I would like improve the speed. Usually, I would not use "cla" which increases the speed greatly but in this case the memory demands are too high for my available RAM. (Note the total number of points to plot is 10^6 and the number of frames is 2000, much higher than I usually have to contend with.) I compared use of "cla" with closing the figure and opening a new one for each frame and "cla" is faster by hours. Turning the figure visibility off leads to no frames being captured. Any ideas for speed gains?
n = 10^6; %Number of points
intvl = 500; %Number of points added per frame of video
mars = jet(n);
fRate = 60;
xn = randn(1,n);
yn = randn(1,n);
[sxn, I] = sort(xn);
syn = yn(I);
gtex = 'Some_';
atex = 'parameter_';
btex = 'values_';
ctex = 'go_';
dtex = 'here';
para = [gtex atex btex ctex dtex];
pos = [218 102 1332 798]; % [x y width height]
vidObj = VideoWriter(para,'MPEG-4');
vidObj.FrameRate = fRate;
vidObj.Quality = 100;
open(vidObj);
tic
figure(WindowState="maximized");
for q=1:intvl:n+1
scatter(sxn(1:q-1),syn(1:q-1),1,mars((1:q-1),:))
set(gcf,'ToolBar','none');
set(gca,'color',[0 0 0])
set(gca,"XTick",[])
set(gca,"YTick",[])
set(gca,"ZTick",[])
axis equal
clim([min(sxn) max(sxn)])
drawnow
currFrame = getframe(gcf,pos);
writeVideo(vidObj,currFrame);
cla
end
close(vidObj);
toc
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!