VideoWriter -- trouble creating the example peaks.avi

1 Ansicht (letzte 30 Tage)
Justin Bailey
Justin Bailey am 28 Okt. 2011
Windows 7, 64-bit, Matlab R2011a...
I tried running the following code from the VideoWriter examples...
vidObj = VideoWriter('peaks.avi');
open(vidObj);
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
currFrame = getframe;
writeVideo(vidObj,currFrame);
end
close(vidObj);
This resulted in a faded still image of the first frame. Weirdly, my desktop behind the figure is also visible. I tried...
vidObj = VideoWriter('peaks.avi','Uncompressed AVI');
...which resulted in a video that looked sort of like a scrambled color TV set. Any ideas? Thanks in advance...
  3 Kommentare
Walter Roberson
Walter Roberson am 29 Okt. 2011
You could try putting a pause() in after the surf and before the getframe(). That will force a render update, and will give some time for that update to finish.
Justin Bailey
Justin Bailey am 29 Okt. 2011
THANK YOU so much for the quick and very helpful responses...
Sven... You were right, it was a getframe() problem. When I viewed interim frames, they looked like the first frame.
Walter... Yep, I put a pause() in after the surf and before the getframe() and that fixed the weird faded (w/ desktop behind) quality.
Thanks for pointing me in the right direction. I found a surprisingly easy fix...
set(gcf,'renderer','zbuffer')

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Justin Bailey
Justin Bailey am 29 Okt. 2011
set(gcf,'renderer','zbuffer')

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by