Why is my getframe/movie not displaying my final frame?

7 vues (au cours des 30 derniers jours)
Brandon
Brandon le 3 Mar 2014
Commenté : Woo-Jin Cho Kim le 14 Juin 2016
Hi all,
I'm trying to to make a movie of a robot arm moving through space. Here is my code.
% Plotting
% Make a set of axes
frame0_x = [0 0 0; 10 0 0];
frame0_y = [0 0 0; 0 10 0];
frame0_z = [0 0 0; 0 0 10];
hfig = figure; hold on; grid on; view(27, 35);
xlabel('x'); ylabel('y'); zlabel('z');
xlim([-15 15]); ylim([-15 15]); zlim([-15 15]);
set(gca,'NextPlot','replaceChildren');
% Animate the movie
for j = 1:size(points1_trans, 3)
%pause
cla
hold on
plot3(frame0_x, frame0_y, frame0_z, '--k', 'linewidth', 2);
plot3(link1_x_trans(:, :, j), link1_y_trans(:, :, j), link1_z_trans(:, :, j), 'r', 'linewidth', 1);
plot3(link2_x_trans(:, :, j), link2_y_trans(:, :, j), link2_z_trans(:, :, j), 'r', 'linewidth', 1);
hold off
%pause
F(j) = getframe(hfig);
end
figure
movie(gcf, F, 2, 30)
My problem is that the when the loop cycles through, it displays the motion perfectly. However, when I use movie(), the final frame is the second-to-last position of the robot arm. In other words, it appears that getframe is dropping the final frame in the loop. I verified this by checking with image(F(1, 100).cdata).
What could be causing getframe() to fail to capture the final frame?
Thank you for your time.
  1 commentaire
Woo-Jin Cho Kim
Woo-Jin Cho Kim le 14 Juin 2016
Dear Brandon,
Your last frame is probably being projected but its probably because it loops too fast. If you open it as .avi you can pause it at the last second and you would be able to see the last frame.
The problem is that you need to add some sort of wait/pause command before it starts looping the movie again.
Best Regards, WJC

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by