フィルターのクリア

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 Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by