SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Abraham S. <ab...@cn...> - 2005年09月15日 20:20:49
Attachments: anim.py
Hi. I have the need to both display animations real time and to save 
them as files. Unfortunately, currently there doesn't seem a good 
unified method (although code currently exists on the web page to do 
both). I decided to try to unify animations with a couple of simple 
Python classes:
AnimationController - attached to an already drawn plot, and determines 
how specific plot will change over time (this is base class, so the 
functions: reset(), next(), prev(), and data() have to be overridden)
Animation - A collection of plots and AnimationControllers (1-to-1). 
Each cycle will have AnimationController update their corresponding 
plots (this is base class, so the function run() has to be overridden)
Then I have two backends for the Animation:
GTKAnimation - creates a 'live' animation
FileAnimation - creates an MPEG file
so all you need to do, is create your own AnimationController, and you 
can automatically create an MPEG file, or display the data live.
I thought I would throw this out there, and see if maybe other people 
were interested (and if maybe a toolkit should be created). Theres still 
some work to make it more flexible, and have more backends. Also, the 
FileAnimation is really a bad hack (using techniques suggested from 
previous posts). On my current system I couldn't get mencoder to work 
correctly (or mplayer, for that matter), so I had to use 'convert', but 
it's fairly easy to change it. Of course, ideally using the FFMPEG 
library would be best, but I don't have time to write the necessary SWIG 
files just now.
Also included is a quick example of phase-shifting sine-waves.
Abe
From: John H. <jdh...@ac...> - 2005年09月17日 03:05:02
>>>>> "Abraham" == Abraham Schneider <ab...@cn...> writes:
 Abraham> suggested from previous posts). On my current system I
 Abraham> couldn't get mencoder to work correctly (or mplayer, for
 Abraham> that matter), so I had to use 'convert', but it's fairly
 Abraham> easy to change it. Of course, ideally using the FFMPEG
 Abraham> library would be best, but I don't have time to write the
 Abraham> necessary SWIG files just now.
 Abraham> Also included is a quick example of phase-shifting
 Abraham> sine-waves.
Hey Abraham,
While longer term a cross platform animation mpeg wrapper toolkit
would indeed be nice, in the short term I think that classes like this
can be very useful to make animation easier. One thing I would like
to see is support for the recent matplotlib bbox/blit animation
features, which can make animation an order of magnitude faster. Have
you perused the animation wiki?
Beyond that, you may want to look at the RectangleSelector and
HorizontalSpanSelector in the widgets.py file to see how they handle
connections to draw_events, etc....
Thanks,
JDH
From: Abraham S. <ab...@cn...> - 2005年09月21日 23:13:02
Attachments: pyanim.tar.gz
I did take a look at the wiki, but for some reason I couldn't get it 
working first pass. I'll try again. I also realized that the Animation 
classes will have to be a bit more complex than I originally though, as 
they are essentially iterators, so they should be broken up into: 
ForwardAnimation, BidirectionalAnimation, and RandomAnimation.
Also, perhaps of general interest, my method of creating .MPG files with 
convert failed recently due to my movies being too long, and the huge 
number of frames cause convert to break (too many parameters on command 
line). Having no other options, I created a wrapper for FFMPEG. To save 
time (and so perhaps a better/more complete method would be better..) I 
have attached the library to this message, in case it helps anyone else. 
Of the many caveats:
(1) Only three functions are exposed, instead of the full functionality 
of FFMPEG. On the plus side, it's pretty easy to make a movie now.
(2) Most of the code is copied from output_example.c, from the FFMPEG 
source. This is in part because there is little to no documentation that 
comes with the library. To save time I kept most of the source code the 
same, but just encapsulated in with a C++ class. There are a couple 
things done in it, which I have left alone, but have no clue what they 
do (if anyone has any suggestions as to what they do [e.g. how to 
determine the size of video_outbuf_size], it would be greatly appreciated).
(3) I've never touched anything related to video before, so there's a 
good chance I messed up a bunch of other stuff.
(4) I used Boost::Python instead of SWIG, mainly because I know 
Boost::Python, and I don't know SWIG.
(5) You will need (of course) FFMPEG installed on your computer (the 
CVS version is considered the most correct version to run)
With that said, it seems to work fairly well. Along with the library, I 
included a small test python program that shows how to use it 
(simulating the game of life). One things I've noticed, is that with 
graphs, to get any decent quality from the MPEG, you have to set the 
bitrate extremely high..
Abe
>Hey Abraham,
>
>While longer term a cross platform animation mpeg wrapper toolkit
>would indeed be nice, in the short term I think that classes like this
>can be very useful to make animation easier. One thing I would like
>to see is support for the recent matplotlib bbox/blit animation
>features, which can make animation an order of magnitude faster. Have
>you perused the animation wiki?
>
>Beyond that, you may want to look at the RectangleSelector and
>HorizontalSpanSelector in the widgets.py file to see how they handle
>connections to draw_events, etc....
>
>Thanks,
>JDH
>
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by:
>Tame your development challenges with Apache's Geronimo App Server. Download
>it for free - -and be entered to win a 42" plasma tv or your very own
>Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
>_______________________________________________
>Matplotlib-devel mailing list
>Mat...@li...
>https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
> 
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /