Insight VR

Linux porting notes

by matt on Mar.25, 2008, under Lasers, missile command

Hello, Matt here. I’m going to discuss the Linux port of the Missile Command game. I have a Logitech QuickCam Messenger. After I installed gspcav1 on Gentoo Linux, the webcam “just worked”. Now I needed to get it working with the game.

The main task in porting to linux is to poll the webcam and push a buffer of image data to the process function that looks for red. A simple enough task.

A month or so ago, I had looked for python wrappers to the v4l interface, and I thought I came across one for v4l2 (v4l v. 1 doesn’t work now), but alas I downloaded into my /tmp directory and it has now gone into the bit bucket, and my search-fu isn’t good enough to find it again. So after getting frustrating that I’m either losing my memory or just retarded, I started looking for other wrappers. I found one called Fluendo Halogen. Using their example code I soon had image data going to the process function. But when I tried to play the game there appeared to be some weird feedback loop going on and the laser had no effect. What to do?

Debugging here is a tiny bit different that normal debugging. How do I know if the webcam is seeing the laser? And if it is why is it not being detected? Turns out that PIL has a nice function to convert a data buffer to an image. So by converting the buffer to an image, I could see what the webcam was seeing. To make a long story short, instead of giving my back a stream of RGBA values, I was getting back BGRA values (red and blue were switched) and the image was upside down. I tried the naive method of rearranging the buffer, but it was prohibitivly slow. So my brother told me to alter the processing matrices that searched for red. I also added a flip Y coordinate argument and the game was off and running.

So if you are interesting in running under linux, make sure you have Fluendo Halogen installed (or in your PYTHONPATH). Good luck!

:
No comments for this entry yet...

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!