getframe problem
조회 수: 14 (최근 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!