jacob andreas [.net]

OpenCV X Input

July 18, 2008

More fun with the marvelous OpenCV library. While red is still a convenient color to track, I’m no longer using real vegetation. Instead, I found an old pair of gloves that do the job quite well.

How it works

(Edit: rather embarrassingly, I seem to have accidentally deleted the source code for this project. However, you should be able to figure out everything you need from camshiftdemo.cpp in the samples/ folder. I apologize for the inconvenience.) Found it! Go to this directory and download redglove.cpp for examples.

A brief explanation: I’m no longer using the library’s object-tracking algorithms. Instead, the mouse is just tied to the position of the “average” red pixel, with some trivial logic for throwing away outliers. Once the bounding box of the glove drops below a certain width, a click event is triggered.

(Edit: I simulate clicks and mouse motion with the XTest library.)

(The interaction is not normally this laggy, but istanbul clobbers performance when compositing is enabled. Disable compositing, you say? I need my exposé: the window buttons on a taskbar would be too small to use reliably. The system’s not perfect. Yet.)

Some thoughts:

The click interaction really needs to be improved. There’s just enough “wobble” between the camera and an unsteady hand to make it very difficult to click without dragging, and perspective makes the rotate gesture almost impossible to execute when not dead center.

In the same vein, it would be good if I could get the program to even roughly judge the distance of the glove to set the threshold for click events dynamically.

Once I get the kinks ironed out of the current setup I’m going to try moving up to two gloves, but I think I have a way to go first. Glove-in-air interaction will never be a good model for desktop use, but I could see this being useful in applications (games in particular) that require only gross input.

CompizTomato: the FCI revolution

July 14, 2008

Some firm produce, a good webcam and a new era of Fruit-Computer interaction.

A few days ago I was looking for a v4l2 wrapper and stumbled across OpenCV. I’ve been hooked ever since. It’s an open computer vision library that provides a simple interface to a lot of sophisticated image processing.

As a little test of the system I hacked the sample blob tracking application to send signals to Compiz over DBus when the tracked object moves to the side of the screen. The tracking can be a little flaky so I needed a brightly colored object that would stand out against the background. We happened to have some tomatoes lying around in the kitchen, and thus was born CompizTomato.

As you can see from the video, the recognition is not perfect but certainly seems to get the job done. I can use it with only slightly diminished accuracy while sitting right in front of my computer against a busy background. Further testing has also revealed that I can also track my head and wobble from side to side, but it’s not quite as fun and considerably harder on the neck.

Without further adieu, the video:

http://www.youtube.com/watch?v=cD9ZMjy_rkE

fine print

All content in public domain unless otherwise specified. Powered by prgmr, FreeDNS, Wordpress and vim.