Monday, February 02, 2009

pygame -- better OSX support, midi virtual keyboard example, basic camera module on windows, imports in ironpython (the .NET/C# python).

Some fairly exciting pygame updates...

Brian has removed the dependency pygame had on pyobjc.

This is important because pyobjc has become not well enough maintained for pygame. It is part of the apple supplied python, but not other versions of python commonly used on OSX. We had to make a binary of it ourselves for the last release -- because there wasn't one supplied by the maintainers.

OSX pygame needs testing as a result of this change... You can download the latest auto-build from svn that passes all the unittests here: http://thorbrian.com/pygame/builds.php

The midi module also works on OSX now... to go with the linux, and windows support. The above automatic builds also include the midi stuff for windows/mac. So you can attach midi devices (like keyboards, drums, guitars, synths etc) and use them to control your game (or robots).

Camera update: There is now a simple implementation of the pygame.camera module on windows using the vidcap module. This is a python module that uses direct show, and directx 8. I'm not sure this module will make it into pygame. We will need to talk with the author of the module to see if we can include it, and also see how easily it compiles (direct show has a reputation of being quite insane to use). However this little wrapper allows almost the same API to be used for camera access on windows and linux. Next will be an implementation that uses python-opencv -- which will make it possible to use on MacOSX as well. This will mean we will have less work to do, but rely on some optional dependencies. In the future, as we implement the camera module on other platforms -- these optional dependencies will disappear. I think this will be the quickest way to get a basic implementation on each platform... and allow us to refine the implementation in later releases. A stop gap measure if you will.

Lenard made a virtual piano example for the new midi module.
. This can be used to play midi notes with your mouse, or other pointing device.

Marcus has been continuing some work on the pgreloaded branch -- the super clean refactor of pygame that includes python3 support amongst other things. It is hoped that pgreloaded will become pygame2 sometime in the future.


pygame is able to be imported into ironpython!!!
Ironclad is a project to allow importing of CPython extensions into the ironpython version of python. Ironpython is the .net version of python, that runs on the .net VM with C# etc.

The subversion ironclad is at the stage where it can import pygame... but still needs a few problems to be fixed before things will run. details here:
http://ironpython-urls.blogspot.com/2009/01/ironclad-08-released-python-c.html
. Ironclad is capable of running a good portion of numpy, which shows that it should be able to work with many C extensions -- since numpy is a complex and large C extension module.

Emulating the C API of python will allow ironpython to use many existing optimized C extensions. Now that the approach has been proven to work, I hope other python implementations take note of this research proof -- and provide a CPython API emulation. (I'm thinking of pypy, jython, and tinypy :)

Also... in case you missed it... Simon Wittber has been working on a project involving giant python powered robots!!. Rumor has it that he used pygame for the Human Machine Interface(HMI) portion.

2 comments:

astraw.com said...

I wrote some cross-platform camera stuff at http://code.astraw.com/projects/motmot/wiki/cam_iface I mainly work on libdc1394 on linux, but there is support for QuickTime SequenceGrabber, and Prosilica's Gig-E cameras. I'd like to add support for directshow on Windows and UVC cameras on Linux. It's BSD licensed.

illume said...

Very cool!

I didn't know about your work... it looks very interesting(I did look at vision egg, but not any of the other stuff).

I think the v4l2 camera work that Nirav did on pygame.camera should work with uvc cameras on linux. I'm pretty sure the UVC cameras have a v4l2 driver.

We should definitely share code! I've sent a link to your web page to nirav (http://eclecti.cc/) so he can have a look too.

cu.