PyMash

Rick Stevens stevens at mcs.anl.gov
Tue Sep 9 17:24:29 CDT 2003


cool.

On Thu, 4 Sep 2003, Hiroyuki Komatsu wrote:

> I wrote a prototype of a python wrapper for OpenMash.  The atteched
> file <mash-code_pymash-5.2.diff> is the diff file for
> <http:///www.openmash.org/download/5.2/mash-src-5.2.tar.gz>.
> 
> 
> [Sample Code]
> I replaced headlessVideo.mash by Chris to a python code as a sample.
> (For the replacement, I had the great help of Chris.  Thanks!)
> Here is the core of the sample:
> 
> ============================================================
> from openmash               import OpenMash
> from openmash_VideoAgent    import VideoAgent
> from openmash_VideoPipeline import VideoPipeline
> 
> class HeadlessVideo:
>     def __init__(self, host, port, ttl = 16, key = None):
>         self.agent    = VideoAgent(host, port, ttl)
>         self.pipeline = VideoPipeline(self.agent)
>         if key is not None:
>             self.agent.install_key(key)
> 
>     def run (self, device_number, codec):
>         devices = self.pipeline.get_input_devices()
>         self.pipeline.select(devices[device_number], codec)
>         self.pipeline.start()
> 
>     def enhance (self, channel = None, format = None, bps = None,
>                  fps = None, quality = None):
>         self.pipeline.set_options(port = channel, norm = format, bps = bps,
>                                   fps = fps, quality = quality)
> 
> ------------------------------------------------------------
> 
>         def main(self, *args):
>             headless_video = HeadlessVideo(self.host, self.port, self.ttl,
>                                            self.key)
>             headless_video.run(self.device_number, self.codec)
>             headless_video.enhance(channel = self.channel,
>                                    format  = self.format,
>                                    bps     = self.bps,
>                                    fps     = self.fps,
>                                    quality = self.quality)
> 
>             while True:
>                 OpenMash.update()
>                 time.sleep(0.1)
> ============================================================
> 
> <mash-code>/mash/python/example/headless.py is the whole code.
> 
> 
> [Requirement to Complie]
>   SWIG
>   AutoTools (autoconf)
>   Python ;-)
> 
> 
> [How to Complile]
> 
> 1. Patch this patch.
>   % cd <mash-code>
>   % patch -p1 < <mash-code_pymash-5.2.diff
> 
> 2. Complie other source trees except mash.
> 
>   % build tcl
>   % build tk
>   % build otcl
>   % build tclcl
>   % build gsm
>   % build srm
> 
> 3. Create configure file in mash directory.
> 
>   % cd mash
>   % autoconf
> 
> 4. Create pymash
> 
>   % ./configure --disable-devel --python-includedir=<include dir for python>
>   % make pymash
> 
>   On my environment (Linux/Debin), python-includedir is
>   </usr/include/python2.3>
> 
> 
> [How to Test]
> 
>   % cd <mash-code>/mash/python
>   % TCLCL_IMPORT_DIRS=.. python example/headless.py 127.0.0.1 9886 -d0 &
>   % vic 127.0.0.1/9886
> 
>   The vic would probably display test transmission from headless.py.
> 
> 
> [How to Install]
> 
>   Not implemented yet.
> 
> 
> The current PyMash is based on smash (ie. non-Tk version).
> So, as a next step, I am going to modify PyMash to handle Tk or
> another window tool kit like WxPython.  And then, I have a plan to
> write a vic-clone in Python.
> 
> No more Tcl.
> --
> Hiro
> 
> 




More information about the ag-dev mailing list