필터 지우기
필터 지우기

getframe problem

조회 수: 16 (최근 30일)
mat
mat 2012년 3월 22일
편집: Jeremy 2015년 12월 1일
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

답변 (4개)

Onomitra Ghosh
Onomitra Ghosh 2012년 3월 22일
You can try the workarounds mentioned in:
  댓글 수: 1
Lauren
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
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.

Bruno
Bruno 2014년 10월 15일
It works with me.

Jeremy
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.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by