From: Lorenzo I. <lor...@gm...> - 2008-04-16 22:52:57
|
Dear All, Quite some time ago I asked some questions abut how to make a movie in Visual Python. Among the various answers I got, I was trying this suggestion: On 14/01/2008, Kadir Haldenbilen <kha...@ya...> wrote: > > Lorenzo Isella wrote: > > > I managed to get some decent animations on my laptop (running Debian > > testing); now my question is how to get at least a set of png (or any > > other decent format; pdf, eps, jpg etc...) files with the "snapshots" > > of my system. > > I can answer your question for Windows environment. Same or similar solution > MAY or > MAY NOT apply for Linux, I have no experience in Linux environment. > > First you need to install Python Image Library, PIL, if you have not done so > already. You may be using it already, if you are using TEXTURE feature of > the recent Beta versions of VPython. > > Then in your source code you need to add some lines, like the followings: > > import Image > import ImageGrab > ... > > Your animation code goes here > > ... > > while looping: > > im = > ImageGrab.grab((24,30,ImageWidth-4,ImageHeight-4)) > fn = "Cat"+str(pn)+".png" > im.save(fn) > > fn is the filename in Windows environment. > > IF THIS SYSTEM WORKS in LINUX, then someting similar to that of filename > should be sufficient. > ImageGrab needs the display location (upper-left corner) and display > sizedefined to it, so it picks up > the image from the screen for you. > > You need to set up some sort of a counter in the loop like the str(pn), to > get a unique > file name for each snapshot. > > Hope it works... > > Kadir > > > ________________________________ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. Now, unfortunately I do not think this works for linux. Consider the small example given below: #! /usr/bin/env python import scipy as s import numpy as n import pylab as p import visual as v import Image import ImageGrab x_list=s.arange(10) y_list=s.zeros(10) y_list[:]=1. z_list=y_list box_size=100. #v.scene = v.display(title="System Snapshot", width=box_size, height=box_size, x=0, y=0, # range=box_size, center=(0.,0.,0.)) my_rad=1. particles=[v.sphere(pos=loc,radius=my_rad,color=v.color.blue)\ for loc in zip(x_list,y_list,z_list)] im = ImageGrab.grab((24,30,ImageWidth-4,ImageHeight-4)) fn = "Cat"+str(pn)+".png" im.save(fn) If I run it on my machine (Debian testing) then I got the following error message: Traceback (most recent call last): File "<stdin>", line 11, in ? File "/usr/lib/python2.4/site-packages/PIL/ImageGrab.py", line 34, in ? import _grabscreen ImportError: No module named _grabscreen Is the module ImageGrab available for Debian (or for linux in general)? Or does anyone know of a workaround for this? Many thanks Lorenzo http://physics.syr.edu/~salgado/software/vpython/EMWave.py |
From: Erik T. <mrl...@gm...> - 2008-04-17 00:56:15
|
> > Is the module ImageGrab available for Debian (or for linux in general)? > Unfortunately, ImageGrab appears to only work on Windows. In the source code of ImageGrab.py it has the comments: # (New in 1.1.3) The <b>ImageGrab</b> module can be used to copy > # the contents of the screen to a PIL image memory. > # <p> > # The current version works on Windows only.</p> -Erik |
From: Lorenzo I. <lor...@gm...> - 2008-04-17 12:53:31
|
I see. So I think I am back to one of the old suggestions I was given, namely to use the povray plugin. Now, I think this is quite advanced for me. I got hold of the script corresponding to: http://www.gbiloba.org/download/SNP-definitif-640x480.avi Which also was recommended to me a long time ago. It is quite advanced and I cannot run it on my machine (again, I installed pymad but the system [and myself] cannot find some missing modules). However, maybe I would need something simpler to start from. I installed povray for Debian, but now what I would need is really some simple way to invoke it from Python to save (and then convert) a visual Python scene. Cheers Lorenzo Erik Thompson wrote: > > Is the module ImageGrab available for Debian (or for linux in > general)? > > > Unfortunately, ImageGrab appears to only work on Windows. In the > source code of ImageGrab.py it has the comments: > > # (New in 1.1.3) The <b>ImageGrab</b> module can be used to copy > # the contents of the screen to a PIL image memory. > # <p> > # The current version works on Windows only.</p> > > > -Erik |
From: Frédéric <fre...@gb...> - 2008-04-17 15:10:19
|
Le 17/4/2008, "Lorenzo Isella" <lor...@gm...> a écrit: >I see. So I think I am back to one of the old suggestions I was given, >namely to use the povray plugin. Now, I think this is quite advanced for me. >I got hold of the script corresponding to: >http://www.gbiloba.org/download/SNP-definitif-640x480.avi >Which also was recommended to me a long time ago. >It is quite advanced and I cannot run it on my machine (again, I >installed pymad but the system [and myself] cannot find some missing >modules). >However, maybe I would need something simpler to start from. >I installed povray for Debian, but now what I would need is really some >simple way to invoke it from Python to save (and then convert) a visual >Python scene. I wrote the script for a student, a few years ago. I admit there are a lot of stuff in it, not directly related to your problem (the annoying thing is to program the different trajectories and camera positions with a good timing to get a smooth movie). In fact, you only need to use povexport() function to export a VPython scene to a pov script, then run povray on it. If you do this for several pictures, then you just display them at 15-20 fps, and you have your movie ;) I will try to extract a little example from the big script... |
From: William C. W. <ww...@la...> - 2008-04-17 04:19:56
|
Hi Lornezo, Your best bet might be to forgo a Python-based solution and use something like ffmpeg to encode screen activity directly while the window is active. (ffmpeg is an open source command line encoding application that can also do video capture). You should be able to find a number of references, for example: http://ubuntu.wordpress.com/2006/06/08/how-to-create-a-screencast-in-ubuntu/ Good luck! Bill Ward > Dear All, > Quite some time ago I asked some questions abut how to make a movie in > Visual Python. > Among the various answers I got, I was trying this suggestion: > > > On 14/01/2008, Kadir Haldenbilen <kha...@ya...> wrote: > > > > Lorenzo Isella wrote: > > > > > I managed to get some decent animations on my laptop (running Debian > > > testing); now my question is how to get at least a set of png (or any > > > other decent format; pdf, eps, jpg etc...) files with the "snapshots" > > > of my system. > > > > I can answer your question for Windows environment. Same or similar > solution > > MAY or > > MAY NOT apply for Linux, I have no experience in Linux environment. > > > > First you need to install Python Image Library, PIL, if you have not > done so > > already. You may be using it already, if you are using TEXTURE feature > of > > the recent Beta versions of VPython. > > > > Then in your source code you need to add some lines, like the > followings: > > > > import Image > > import ImageGrab > > ... > > > > Your animation code goes here > > > > ... > > > > while looping: > > > > im = > > ImageGrab.grab((24,30,ImageWidth-4,ImageHeight-4)) > > fn = "Cat"+str(pn)+".png" > > im.save(fn) > > > > fn is the filename in Windows environment. > > > > IF THIS SYSTEM WORKS in LINUX, then someting similar to that of > filename > > should be sufficient. > > ImageGrab needs the display location (upper-left corner) and display > > sizedefined to it, so it picks up > > the image from the screen for you. > > > > You need to set up some sort of a counter in the loop like the > str(pn), to > > get a unique > > file name for each snapshot. > > > > Hope it works... > > > > Kadir > > > > > > ________________________________ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it > > now. > > > > Now, unfortunately I do not think this works for linux. Consider the > small example given below: > > > #! /usr/bin/env python > > import scipy as s > import numpy as n > import pylab as p > > import visual as v > > > import Image > import ImageGrab > > x_list=s.arange(10) > y_list=s.zeros(10) > y_list[:]=1. > z_list=y_list > > > > box_size=100. > > #v.scene = v.display(title="System Snapshot", width=box_size, > height=box_size, x=0, y=0, > # range=box_size, center=(0.,0.,0.)) > > my_rad=1. > > particles=[v.sphere(pos=loc,radius=my_rad,color=v.color.blue)\ > for loc in zip(x_list,y_list,z_list)] > > > im = ImageGrab.grab((24,30,ImageWidth-4,ImageHeight-4)) > fn = "Cat"+str(pn)+".png" > im.save(fn) > > > If I run it on my machine (Debian testing) then I got the following > error message: > > Traceback (most recent call last): > File "<stdin>", line 11, in ? > File "/usr/lib/python2.4/site-packages/PIL/ImageGrab.py", line 34, in ? > import _grabscreen > ImportError: No module named _grabscreen > > Is the module ImageGrab available for Debian (or for linux in general)? > Or does anyone know of a workaround for this? > Many thanks > > Lorenzo > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://physics.syr.edu/~salgado/software/vpython/EMWave.py > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |
From: William C. W. <ww...@la...> - 2008-04-18 16:39:57
|
Jaap, I'm not sure what you mean by "out of date"...the link opens fine for me again today when I retried it... The information, though, is almost two years old. If we dig a little deeper, I see that this method required patching ffmpeg to create an X11 grabber. Now, as you might expect, grabbing from X11 is a native part of the latest releases, so just go straight to the documentation for how you might pull it off: http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html#SEC4 Is this useful? (I have just started to work with ffmpeg for other purposes, but I'm not a frequent Linux user, so my insights are limited). Bill > William C. Ward wrote: >> Hi Lornezo, >> >> Your best bet might be to forgo a Python-based solution and use >> something >> like ffmpeg to encode screen activity directly while the window is >> active. >> (ffmpeg is an open source command line encoding application that can >> also >> do video capture). You should be able to find a number of references, >> for >> example: >> >> http://ubuntu.wordpress.com/2006/06/08/how-to-create-a-screencast-in-ubuntu/ >> >> Good luck! >> >> Bill Ward >> > > This link seems to be out of date! The idea is promising but an actual > link > will be useful. > > Jaap > > |