getframe problem
16 次查看(过去 30 天)
显示 更早的评论
i am trying to make a video clip (avi) from a sequence of surf plots.
i used the getframe function to capture a series of figures depicting an evolvement of some data. a clip is created (through writeVideo). when i run the clip, instead of the full moving video i get a still image of the first frame mixed with my own desktop background details. this is a mess up coming from getframe.
any suggestions why this happens and how it could be overcome?
thanks a lot
mat
0 个评论
回答(4 个)
Onomitra Ghosh
2012-3-22
You can try the workarounds mentioned in:
1 个评论
Lauren
2013-11-22
Hi Mat,
I was having the same problem you described. I used option 1 from the link above, and it seemed to solve the problem for me. In the code below, if I uncommented either of the two commented lines within the for loop, it would not work without changing the renderer to zbuffer. Once I added the line to set the renderer to zbuffer, I could uncomment either the surf or the mesh command in the for loop, and was able to produce the desired avi video clip.
clear all;
close all;
i_test = 25*pi/180;
theta = 0:0.1*pi:2*pi;
x_test = cos(theta);
y_test = cos(i_test)*sin(theta);
z_test = sin(i_test)*sin(theta);
[sphere_x,sphere_y,sphere_z] = sphere(25);
sphere_x = 0.5*sphere_x;
sphere_y = 0.5*sphere_y;
sphere_z = 0.5*sphere_z;
figure;
axis([-1.5,1.5,-1.5,1.5,-1.5,1.5]);
axis square;
title Title;
xlabel x; ylabel y; zlabel z;
hold on;
set(gcf,'Renderer','zbuffer')
k_test = 1;
for t = 0:0.01*pi:2*pi
cla;
plot3(x_test,y_test,z_test,'-r',cos(t),cos(i_test)*sin(t),...
sin(i_test)*sin(t),'ok');
% surf(sphere_x,sphere_y,sphere_z,'EdgeColor','black',...
% 'FaceColor',[0,.5,0]);
% mesh(sphere_x,sphere_y,sphere_z,'EdgeColor',[0,.5,0]);
text(.6,-1.2,-1,['t = ' num2str(t)]);
testMovie(k_test) = getframe(gcf);
k_test = k_test + 1;
end
Jan
2012-3-22
I had some success with adding a pause(0.02) before the getframe call. Using drawnow only helped in 99% of the pictures only.
0 个评论
Jeremy
2015-12-1
编辑:Jeremy
2015-12-1
I'm having a similar problem, when I call movie(F), I get only the first frame of the video, then the call to movie ends. (Matlab 2015b, on Mac OS X 10.10.5). Any ideas?
(Also, the frame it shows is off center on the plot and partially hidden, not sure if this is relevant or not)
***Update: Never mind, I was accidentally skipping frames, so my F matrix had only every fourth entry filled in, I guess the empty entries stopped it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!