Thursday, August 18, 2011

Building OpenCV 2.3.1 on Ubuntu 11.04

Getting OpenCV 2.3.1 to compile on Ubuntu can be interesting.  The first issue is tracking down all of the dependencies you need to get the different parts of it to work properly.  There is more information on dependencies needed at the OpenCV wiki here and here.  I found this page on a blog as well which will help to get a lot of the dependencies down.

For me specifically, I had a couple of problems on 11.04.  Make sure you have the following packages installed to enable gstreamer and unicap support:

libgstreamer-plugins-base0.10-dev
libgstreamer0.10-dev
libunicap2
libunicap2-dev
libucil2-dev

The second major problem is that OpenCV 2.3.1 doesn't fully track the latest releases of ffmpeg.  This patch helps, but bear in mind that it's for OpenCV 2.3.0 and there have been changes between versions.  You'll have to install the patch by hand to take care of some of the differences.

Once this is done, you should be ready to build.  On my system I ran cmake as:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D WITH_TBB=ON -D WITH_XINE=ON -D WITH_UNICAP=ON -D BUILD_EXAMPLES=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_DOCUMENTATION=ON -D BUILD_SHARED_LIBS=ON ..
If you have all of the extra media repositories on Ubuntu enabled, I'd highly recommend NOT disabling shared libraries when building OpenCV.  You'll avoid some linking errors due to concurrent versions of some of the multimedia libraries that might be installed.

After that, when you compile make sure you add in something like -I/usr/local/include and -L/usr/local/lib to your makefile to make sure you're pulling in the version you just compiled instead of the default and you should be good to go.

Parallel Programming: Understanding the impact of Critical Sections

Found this link earlier.  More and more people need to learn how to properly do parallel programming, but we seem to be getting less and less graduates that understand how to do it.

Fun With Verizon

So we had an odd outage here at the Maddox house.  Internet quit working.  Phone quit working.  FIOS boxes couldn't access the Internet either (tested On Demand, Widgets, etc).  So I called Verizon tech support.

Me: Yeah, everything except for the television video stream has quit.
Tech: Have you changed anything on your router?
Me: Not for about a year now.
Tech: Let me run some tests and check.  Oh I found the problem, your wireless on your router was turned off.
Me: Yeah, it's been off for about a year now.  I'm using a Wireless N router.
Tech: I turned your router's Wireless back on.  Did that fix things?
Me (thinking): WTF?  The wireless has been off for a year and why would that affect the FIOS boxes and phones anyway.
Me: Nope.  Maybe you should reset the equipment here?
Tech: Well, let's see if turning the wireless on fixed things.
Me (beating my forehead so hard I made it flat): Um, ok,

Quick VNCViewer Tip

Yes, yes I know this is insecure so shush :)

You might know that vncserver on UNIX boxes pretty much requires you to set a password for logins.  If you're on a secure system or just don't really care, it's pretty easy to write a shell script to log into such server without prompting you for a password:

echo "yourpassword here" | vncviewer "your options here" -autopass host:whichever screen you used