Despite having done quite a bit of computer graphics over the years (even getting paid to do it), I haven’t really done much in the way of computer vision. I’m currently trying to work on a project for the upcoming Maker’s Faire that has something to do with computer vision (he says slyly, teasing his reader(s) mercilessly), so the first step is to try to calibrate a camera. This quantifies the distortions in the camera, and allows you to locate the camera in 3 dimensional space relative to a base coordinate system. Toward that end, I wrote a simple ellipse detector, and it works really well. On the fastest machine at my disposal, it processes this 640×480 frame (reduced here to 400×300) in about 3.5 milliseconds, and locates all of the ellipses in the scene to subpixel accuracy. Or at least, that’s the ultimate idea. But I have the feature detector working.
As I get more of the ultimate project working, i’ll post more info here, and it is my intention that eventually the entire project be available for download.
[tags]Computer Vision,Camera Calibration[/tags]
That is so cool – although the flashing graphic is either going to make me vomit or have a seizure.
You mention that you are doing it on your fastest machine, what sorts of specs and what is the bottleneck – is it entirely limited by processor speed? How well does it paralelize (not sure if that is even a word), if at all? Is that a webcam and therefore you could do realtime tracking/processing on the video stream (or at least have it save out entire uncompressed frames to disk somewhere?) – or are you taking it with a better digital camera and processing it in that manner?
I love this stuff and I think if I had the resources where I had more free time (as in, didn’t work) I would probably spend all day doing things like this.
What language did you use (I assume C) and are there any books you specifically recommend on the topic?
Sorry for all of the questions – but you always have cool things on here and I’m curious to learn more.
Yeah, sorry for the blinking. It was really even more obnoxious before I slowed it down.
The machines that I have at my disposal range from a 1ghz Via mini-itx machine (in fact, the machine hosting this blog) to my machine at work, which hosts two 3.4ghz Xeon CPUS. The Via processor takes almost 50ms to process the frame. My Xeon takes 3 or 4ms. My fastest home machine (an AMD Athlon 64 3700+), takes about 7 or 8 ms.
The code is written in C, and right now slurps up a jpg image (the image I used in this example was taken on my desk using my Panasonic digital camera at its lowest resolution, 640×480). It then converts the grayscale image into a bilevel bitmap by thresholding, and then finds “connected components” in the image. It does this using a flood fill algorithm whose code I cribbed from Paul Heckbert in the original Graphics Gems, which iterates over each component. For each pixel, it updates some basic statistics, and when the flood fill is finished, it determines if the statistics are consistent with an ellipse. If it is, then it does some more slightly magical math (involving finding eigenvalues and eigenvectors, and outputs the definitions of each ellipse).
Oops. I started writing this, and then realized I have an errand to run. Check back later, and I’ll have some more info, and links to the paper than inspired me.
Didn’t I tell you to use a fill algorithm? You own me a royalty! 🙂
How badly can a camera distort an elipse and still be detectable? Don’t you have a fish-eye lens?
The paper that I used to gain hints on how to detect ellipses is linked from here:
http://citeseer.ist.psu.edu/579418.html
The camera I used has fairly low distortion. In theory, it would be better to undo any camera distortion before doing the ellipse detection, but I haven’t needed to do that. I probably will as soon as I write the actual camera calibration code.
Pingback: WebRanger Internet TV » Blog Archive » Experiments in Computer vision.