help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getframe() alternatives


From: Cameron MacArthur
Subject: Re: getframe() alternatives
Date: Sun, 01 Sep 2013 19:11:12 -0400

 

 

----- Original Message -----

From: Philip Nienhuis

Sent: 08/30/13 02:44 PM

To: Cameron MacArthur

Subject: Re: getframe() alternatives

 
Cameron MacArthur wrote: 
<long snip> 
> 1. Sorry, but I'm not sure what you mean by "top post". I just hit 
> "reply" to the email, should I respond a different way i.e through the 
> forum etc? Or scroll to the bottom of the email and respond here like 
> I've done this time? 

The latter yes. Looks good now, thanks very much. 

The idea is to answer immediately below relevant stanzas, like I try to 
do below (and snip irrelevant stuff on the way). Get the idea? 

<snip> 
> I tried copying and pasting the lines one-by-one into the command 
> prompt, but the print statement, imread etc, is all in a larger loop 
> with the code above it that overlays a scatterplot over each frame, so I 
> just return the error once I finish typing the loop. 

Well you can also edit getframe.m and temporarily add the statement 

  keyboard 

immediately under the "function" statement and before all the other 
statements. getframe.m will be interrupted there and then you can do 

  dbstep 

in the Octave terminal to execute each command in turn. After each step 
you can inspect variable values. 

> I'm positive that 
> ghostscript is installed, and nearly positive that octave can find it, I 
> added an environment variable to it just to be sure, so I don't think 
> that's the error. Is there something I can type into Octave to check though? 

Ghostscript isn't vital. GIF, JPG  etc should work too. I just chose ppm 
because it gave me the best picture quality (YMMV). Windows metafile 
(emf) may also work, but I don't know if imread can read it (didn't try). 

To check ghostscript:   In the Octave terminal, type: 

system ("gswin32") 

and check if a Ghostscript terminal pops up (it does on my WinXP box 
with octave-3.6.4_gcc4.6.2, i.e. the same version as yours AFAICS. 

system ("gswin32c") 

should get you a Ghostscript prompt within the Octave terminal (exit it 
by typing: 
quit 

If this doesn't work you obviously may have to fix this first. 
Older Octave versions for Windows used to require the file gswin32c.exe 
to be copied to gs.exe (in the ghostscript ./bin subdir). A while ago I 
was told that this bug has been fixed ages ago; but maybe this helps 
(worth a try). 
Another issue could be that you have ghostscript installed in a path 
containing spaces (the infinitely-abusive "C:\Program Files" or worse: 
"C:\Program Files (X86)") - a recipe for havoc. 

> I tried nearly all of the other devices, especially the ones that don't 
> need ghostscript, and still get the same error. 
> Here are my commands to make the movie: 
> call to avifile to make movie, create figure and handle: 
> % open movie and prepare rendering window 
> mov = avifile(output_file,'compression','msmpeg4v2'); 
> %open(mov); 
> hnd = figure; 
> set(hnd,'visible','off'); 
                     ^^^^ 
What if you comment this one out? 

> set(hnd,'WindowStyle','normal'); 
> getframe/addframe: 

Literally like that? 

> print (gcf,'tmp.fig','-dppm');%print (h, 'tmp.fig', '-dppm'); 

Literally like that? 

> 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); 
> %addframe(mov,gcf); 
> end 

> For the sake of completeness, I had mentioned earlier that the 
> getframe/addframe is in a larger loop (to overlay scatterplot data). The 
> entire larger loop for rendering is included below. 

<long snip> 

It is usually not efficient to debug individual functions while called 
in a loop. First check if a function works "stand-alone". 
So, better do something like: 

sombrero   # Octave makes a nice plot 
# No need to supply figure handle, sombrero is the current figure: 
print ("tmp.fig", "-dppm") 

If the print command doesn't work, you'll have to find out why - I can't 
from here. 
If it does, do: 

sombrero 
hhh = getframe 

and only then start debugging getframe as per my previous reply. 

Success, 

Philip

Philip,

 

It worked! to an extent.  I commented out:

 

set(hnd,'visible','off');

 

I kept the:

set(hnd,'WindowStyle','normal');

Line and it print and read the figure.  The only problem is that it isn't looping.  The output video (which, coincidentally isn't .avi, just type "file" but that's fine because I just change the file type to .avi) is only one frame long.  Any thoughts on why it's not looping and creating all the frames to the video?

 

Honestly, I can't thank you enough for walking me through all of this and helping me so much.  You've definitely done all of your good deeds for the week, and it's very much appreciated.

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]