lundi 5 mars 2012

Python, pyglet, OpenGL and OpenCL

Hello,
I started this blog to talk about a new hobby of mine : programming.
As I had a bit of time for me this summer and I also just had learned how to use Matlab (mainly for image processing), I decided to extend this experience with some little OpenCV experiments. I started in C++ but was not completely happy with the compiling process so I decided to switch to python and give it a try... And I fell in love with it, it is a language that is actually really easy and fun to develop with. I made a little program that allow to control the mouse with the web-cam (color tracking, no clicks) and in august I started to use OpenGL, the result gave this blog its name :






 







It represents 1M particles moving inside a cube with a little collision detection algorithm to maintain them inside. It uses pyglet (http://www.pyglet.org/,
for windowing and also as OpenGL wrapper, I particularly like the "batch" feature, see for yourself !

The GUI is done with a tiny library called glydget by Nicolas P. Rougier (http://www.loria.fr/~rougier/coding/python) I really like the design but there are some extending to do, I would especially need a slider (someday I'll make one of mine...).

Particles movement and collision detection at the edge of the cube run on the GPU (graphic card) thanks to PyOpenCL (http://wiki.tiker.net/PyOpenCL). The OpenCL kernels derivate from the outstanding tutorial from Ian Johnnson (http://enja.org/category/tutorial/advcl/). The particles are in fact a points cloud with geometry shader. The resource from dlampletest was particularly useful (http://sites.google.com/site/dlampetest/python/vectorized-particle-system-and-geometry-shaders) as long as the pyglet glsl wrapper from swiftcoding (http://swiftcoder.wordpress.com/2008/12/19/simple-glsl-wrapper-for-pyglet/) to build the system.

I also implemented a FPS-type camera and a trackball that I derived from this tutorial (http://www.siteduzero.com/tutoriel-3-4978-controle-avance-de-la-camera-partie-1-2.html). This is a French tutorial but an English tutorial, from swiftless (http://www.swiftless.com/) or others should not be too difficult to find on Google).

It is implemented on my personal laptop (Ubuntu 11.10, Intel i5, Geforce GT 330M, python 2.7.2) and runs at ~15FPS, I tried to post a video of it but the result was too flickery.

I will not release the code as it is a rather old project that I already rebuild from byte codes using uncompyle2 (https://github.com/wibiti/uncompyle2), a little tool that I recommend when you, as I, have lost your files and want to recover them from byte codes (.pyc). I also think that I already provide an exhaustive list of better resources than mine that can be use to develop pretty fast the same program. But I will stay open to discuss it with you if you are interested.
This will be the only post on this project but I will post soon on my new project that I started last month which I called "Virtual Optics".

Aucun commentaire:

Enregistrer un commentaire