OpenCV, Day One

I’ve been building on my research lab’s computer vision codebase for a couple years now, slowly adding functionality as it’s needed to get some experiment or other done. It’s built on National Instruments’ LabWindows/CVI IDE, along with their image acquisition and low-level CV stuff, so it’s strictly Windows-based and the code is basically useless in any other setting. That, combined with the fact that I’m the only student currently using it, has led me to implement the bare minimum of what I need, and it’s shamefully sloppy. To boot, due to various issues with Windows and the NI software (which, of course, being proprietary and closed-source, we can do zilch about), it doesn’t even work reliably and is riddled with workarounds.

When I received an e-mail from National Instruments encouraging me to upgrade to Version 9 (will that be credit card or purchase order today?) while waiting an agonizingly long time best described as a fraction of an hour for my fifth try at generating a decent disparity map to complete, I decided to give the free software options another look.

I had already been playing around with libdc1394 on my desktop box in the lab, an x86 machine running Gentoo. Also, I had recently attended Gary Bradski’s OpenCV workshop at ICDSC 2008. Some poking around yesterday revealed that OpenCV is much more mature now than it was when I originally considered using it back in 2006.

After reading through most of Learning OpenCV from O’Reilly (of which Bradski is a co-author) last night, I realized I could probably replace almost all of my custom code with a few calls to OpenCV routines and some glue. It does practically everything I need for my two current projects: image capture, camera calibration, stereo calibration and geometry, background subtraction, interest point detection, correspondence, disparity map generation. And it does them far more efficiently, in most cases, than my own code. Best of all, the entire chain is now free software and is no longer bound to proprietary products (including the higher-level stuff, like PyDSSCC, which is already open-source and platform-independent).

Today, I wrote a short (about 40 lines, comments and whitespace included) C program that displays streaming video from two of my IEEE-1394 cameras in side-by-side windows. Not only does it actually work, without requiring rebooting or tweaking settings or sacrificing goats to Odin, but the frame rate is higher and it doesn’t randomly “forget” to grab a frame every so often.

I am thoroughly impressed so far. The rest of the week will see my try to implement both projects using OpenCV.

Dec 10th, 2008
Comments are closed.