OpenCV in action: Fungi by Todd Vanderlin. (CC)

Linux can be an ideal operating system for visualists – with a little attention, anyway. Because it’s a free OS, you have a unique amount of control over hardware, and you can easily deploy your setup to any machine – perfect for last-minute computer changes for gigging, or for shipping off for installations. We’ll be looking at various tips for working with this OS, but I wanted to start with some install tricks for using Intel’s widely-used, open-source computer vision platform. On Windows and Mac, you have fairly easy installers. Linux is trickier.

Worse, a recent Ubuntu bug kept me from installing at all. Basically, it’s possible to install packages depending on ffmpeg (like Blender) in ways that prevent other key dependencies from installing correctly. (I think I described that more or less accurately.) The most active iteration of this bug:

Bug #312898: libxxx-dev should be installable with libxxx-unstripped

That bug has a number of duplicate reports, such as 343005.

This is already fixed in a file that is available in Karmic, aka 9.10, the release due out this fall and currently in alpha. But I didn’t want to wait. Here’s the fix that finally worked for me.

1. Install ffmpeg and development libraries. Get the ffmpeg dependencies from Karmic and install the .deb files one at a time. Start with libavformat-dev. Package Installer (gdebi-gtk) will return an error if another dependency is required. One at a time, install the dependencies (you may need to choose File > Refresh once a file is installed) for each package it requests. The files are available here:
ffmpeg-debian in Ubuntu Karmic
So, for 32-bit, the most current downloads I grabbed were at:
i386 build of ffmpeg-debian 4:0.5+svn20090609-1ubuntu3

2. Use a fixed version of OpenCV for Ubuntu. Once ffmpeg is installed, you’ll want to grab a different version of OpenCV that has some fixes for capture. (I actually was unable to even install the OpenCV version from subversion, so this was quite a lot easier.) The problem – and solution instructions – are detailed in a blog post by Gijs Molenaar.
Getting video i/o working with opencv and Ubuntu Jaunty (9.04)
He also provides a package repository for his fix:

3. Laugh heartily and enjoy. Once you’ve got all of this working, it should be easier to make use of OpenCV in OpenFrameworks (site | cdm tag), and to use the handy OpenCV library for Processing (site | cdm tag) — which in turn comes with some great example code.

OpenCV Library for Processing (a project of the Atelier hypermédia at the École Supérieure d’Art d’Aix-en-Provence,maintained by Stéphane Cousot and Douglas Edric Stanley.)

The next challenge: getting multiple cameras working easily, so you can, for instance, ignore your built-in webcam and use a PS3 Eye. The solution to that appears to be OpenCV’s cvCam library, which I think is not fully supported in the Processing library (yet – I may try to get that working).

Multiple cameras with cvCam and OpenCV [OpenCV FAQ]

Andy Best has done some terrific tutorials on making use of this combination:

Processing Tutorials: Getting Started with Video Processing via OpenCV

OpenCV Motion Tracking, Face Recognition with Processing: I’m Forever Popping Bubbles

Now, please note: this is me hacking around. Your mileage may vary — and some folks reading this site may have a better sense of what they’re doing than I do. So definitely let us know your feedback, whether you’ve worked out a better way or have found other issues.

Also, I really do wonder: is there a way we could start to maintain a Launchpad repository for everything you need for video capture and computer vision in Processing under Ubuntu, rather than having to cobble together solutions? The problem is, with this many different pieces, video often winds up painfully out of sync. That’s not just a Linux problem – Mac and Windows often suffer, too. But on Linux, it’s solvable.

Previous post

Interactive Musical Whimsy, with Lightning Bugs: Mujik Free on iPhone

Next post

VJ Video Review: Uncompressed HD Mixing with Matrox MXO2 Mini and Laptops

  • squawk! "perfect for last-minute computer changes for gigging, or for shipping off for installations" methinks the mac is the answer for that one… one disk image, all machines.

    but yes, a dedicated linux box for dedicated applications, this is a good thing.

  • Toby: yes, except that you've got limited hardware choices (well, legally, anyway).

  • this post made my day for a few reasons:

    1) i totally beleive in linux as a visualist platform:personally i feel linux as a natural choice for everything, but as you said, it's reallya good choice to pack installations. if you're doing art you need a workable medium.

    2) opencv is an incredibly powerful tool, but it can be tricky to understand and, from time to time, its installation can involve obscure practices, gris-gris talismans and assorted prayers. it's always good to find a library of "this worked for me" solutions…

    …which brings me to:

    3) yes, yes, yes a computer vision repository is absolutely needed. I'm no guru, but i'm ready to contribute my 2 cents.

  • Zak

    Why not just using Gijs's Molenaar's package ? It's only 3 command line to get it! And you don't mess your distro with Karmic packages.

  • Pingback: Tutorials - Setup OpenCV for Android, iOS, Linux, and Windows()