Thursday, January 16, 2014

Abandoned routes for the lego sumo project

During the development of the Sumo Arena with camera tracking I also tried a lot of approaches that DIDN'T work out. I think they are just as interesting as the final result, so I'll detail them here.

My first attempt was with processing. I went trough great pains to extend the great open source library NXTComm. I got it working. And contributed to the open source project. But then I abandoned the route for two reasons: java and openCV.
A while ago I discovered python, now I'm spoiled. I dislike java's semicolons, curly braces, variable types etc. etc. And was curious about openCV. Which - incidentally - plays very well with python and it's number crunching libraries SciPy and NumPy. In retrospect a bit of a shame, as is easy to install and plays well cross platform.

OpenCV - Haarcascades

I first played around with facial recognition and the algorithms behind that. What if I could train the computer to recognize robots instead of faces? After lots of code experiments it turned out that the haarcascades needed for facial recognition don't work very well rotated faces. Stand on your head and it doesn't work anymore. For the sumo match I needed to calculate rotation from each frame so this route was a dead end.

OpenCV - Feature recognition

Next I tried feature recognition. Computers can read QR codes, computers can detect transformed images in other images. So wouldn't they be able to recognize two mindstorms robots? Yes they could but... the process was too slow. I achieved a frame rate of 15 for detecting 1 robot. And I needed two robots at 30fps. Another 16h of coding wasted.

OpenCV - Blob recognition

First I figured that blob recognition would work best if I had a certain color on the robots that would really stand out. I thought that little LED lights would work nice. They would make for two spots that looked much brighter than their surroundings. And they look cool on robots too. Again I was wrong. Because of the autogain on most webcams the LEDs came in as white pixels, devoid of any color. Even with gain control at the lowest gain they stayed white.

The final solution was a couple of simple post-its. They stand out without triggering the camera gain. They are like very small 'green screens': easy to filter out.