|
From: | Philip Nienhuis |
Subject: | Re: getframe() alternatives |
Date: | Tue, 20 Aug 2013 00:15:22 +0200 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.11) Gecko/20100701 SeaMonkey/2.0.6 |
<help-octave ML added, other people can benefit as well> address@hidden wrote:
Philip, I saw your "getframe() alternatives" post and got very excited because I've been trying to do exactly the same thing. I have a matlab function that takes pictures overlayed with scatterplot data and makes it into a video. The function uses the matlab function "hardcopy" at the end to make the video like this: % add this frame to movie file %mov = addframe(mov,gcf); renderer = get(hnd,'renderer'); if strcmp(renderer,'painters') renderer = 'opengl'; end set(hnd, 'Units', 'pixels'); pixelsperinch = get(0,'screenpixelsperInch'); frame = hardcopy(hnd, ['-d' renderer], ['-r' num2str(round(pixelsperinch))]); addframe(mov,frame); but Octave can't understand hardcopy, so I tried to replace it with just: addframe(mov,gcf); but I get error: addframe: input frame should be in [0-1] I saw your post and was hoping you could help me. I'm a super matlab and Octave novice (like, yesterday) and I'm trying to make this matlab function work in octave for a collegue. Would you help me implement your solution to this problem for octave? (I tried adding this via your post:) HH = im2double (imread (gcf)); aviobj = addframe (aviobj, HH); but Octave doesn't like that either. Any help you can give would be super appreciated. Thanks for your time.
Currently I have no time; maybe tomorrow night (but I doubt it).Just a quick answer: gcf is a figure handle, isn't it? If so, you can't use that by adding it to the movie. It is a mere double (actually disguised as a figure handle).
You'd need to prepare a color bitmap for each movie frame and add that to the movie. I created the bitmaps by printing each picture to file, then reading it using imread into a bitmap and feed that to aviobj. All steps but the last one were done in an .m-file (attached). Each frame took ~20 secs to write and read; clumsily yes, but OK it worked. On my current "power"box at work I think it should go much faster (it has an SSD).
What we actually need is a binary getframe that makes a snapshot of the current figure and turns it into a bitmap. I've looked into it a while back it but got lost in the OpenGL and fltk sources.
Anuway I'll attach my old getframe.m to this mail. Philip
getframe.m
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |