|
From: | Cameron MacArthur |
Subject: | Re: getframe() alternatives |
Date: | Fri, 30 Aug 2013 11:54:45 -0400 |
----- Original Message -----
From: Philip Nienhuis
Sent: 08/30/13 04:33 AM
To: Cameron MacArthur
Subject: Re: getframe() alternatives
Hi Cameron, First a few things: 1. Please do not top post; always answer BELOW the text, or below relevant stanzas, because that way discussions are a lot easier to follow for other people. I already asked you this before: https://mailman.cae.wisc.edu/pipermail/help-octave/2013-August/060006.html so please comply. 2. Please include the Octave Help mailing list, so others can benefit from the discussion as well. 3. The whole getframe.m I sent is a kludge (not such a bad one I'd say) supplied without any guarantee; I'll help you below but I'm not going to spend much time/priority on it. If it doesn't work right away you really have to sort out a few things yourself, or wait until someone sometime somewhere comes up with a better solution. Read on... Cameron MacArthur wrote: > Philip, > I added what you sent me to my code, now it looks like this where the > hardcopy stuff was: > print (h,'tmp.fig','dppm'); > ret = im2double (imread ('tmp.fig')); > % Truncate to even size to accomodate addframe() > if (mod (size (ret, 1), 2) > 0); ret = ret(2:end, :, :); endif > if (mod (size (ret, 2), 2) > 0); ret = ret(:, 2:end, :); endif > mov = addframe(mov,ret); > end > but I keep getting the error in Octave: > reading contents of C:\Users\Administrator\Desktop\SanDisk\FTS...done. > rendering frames... > *error: imread: cannot find tmp.fig* That is a clear message isn't it: imread() cannot find the (temporary) file tmp.fig where it expects it to be. I suppose the -in this case!- most obvious cause is that tmp.fig simply hasn't been created, i.e. the print() command a few lines higher up has failed. Now, the usual attack vector for this sort of issues is to try to manually execute the commands in the getframe.m function one by one to find out what fails where. Just copy or type the lines into the Octave terminal. If print() fails, it may be due to a lot of potential issues. But in this case I really suspect you haven't got Ghostscript (properly) installed such that Octave can find it; I think so because the "device" type "ppm" requires Ghostscript, and AFAIR print() doesn't error out but merely warns when Ghostscript isn't found. Execution continues then until a next command that relies on print()'s output gets into trouble and gives up. If so, you can also experiment with other devices rather than with ppm: try "emf", "gif", "svg", etc to find out which one works, or even which one works the best. Do a "help print" to see what is exactly needed. It may also be handy, just for reference, to show us what commands are used to make the movie. Only show these commands: - the call to avifile to create the movie; - how you create the figure and save its handle <...just skip all the pimping & polishing of your graphics...> - how you invoke getframe.m - how you call addframe() to add the frame to the movie. Philip > -Cameron > >> ----- Original Message ----- >> >> From: Philip Nienhuis >> >> Sent: 08/19/13 06:15 PM >> >> To: address@hidden >> >> Subject: Re: getframe() alternatives >> >> <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 >
Philip,
[Prev in Thread] | Current Thread | [Next in Thread] |