Rapid image capture for video assembly?
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!