Working Up

Working Up in Project Management, Systems Engineering, Technology, and Writing

Working Up header image 2

Working with OpenCV on OS X

July 22nd, 2009 · No Comments

by Dwayne Phillips

I return to some of my technical roots this week. I am experimenting with the OpenCV image processing and computer vision library. This is fun.

This is a “techie” blog post. Many years ago I worked with image processing. I did this work in graduate school and then wrote a lot of magazine articles on the topic for the old C/C++ Users Journal. I even published a book on the topic. Later, I revised the book and the eBook or PDF of all that is available at this link.

Just in the last couple of weeks, I started looking at the OpenCV library of image processing and computer vision routines (the Wikipedia page on OpenCV is here). There is a good book out now about this topic from O’Reilly.

As the pages on the Internet state, the OS X work on OpenCV is the most immature. MS Windows leads the way with Linux implementations close behind. Well, I work on Apple computers with OS X at home, so…

The OpenCV wiki is quite helpful. I used the loading and installation instructions found at this link. It wasn’t simple and straightforward, but it worked. First, I had subversion loaded on my machine. Subversion is a version control program that was simple to download and install on OS X. Here is the main page for Subversion. Second, I needed the cmake package. It was also simple to download and install on OS X. Here is the main page for cmake. Third, well the good new is there was no third.

The following subversion command downloaded OpenCV:

svn co http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk opencv

The following statements “installed” OpenCV. Actually, they built the libraries so that I could link to the routines I called when writing my own programs. Run these from a directory called opencv. You could call the directory anything you want (foo, foobar, whatever).

mkdir opencv/build
cd opencv/build
cmake ..
ccmake .
make -j8
sudo make install

I was finally ready to write a little program and try to link with OpenCV’s libraries. This is where I stumbled around for a few hours. Finally, I “figured it out.” The following uses the gcc compiler family to make a program called foo from a source file foo.c and the OpenCV libraries.

gcc -o foo foo.c -I/usr/local/include/opencv -L/usr/local/lib -lcxcore -lcv -lml -lhighgui -lcvaux

So there you have it. Twenty five years and a few generations of hardware and operating systems later, I am sort of programming with a computer vision library. If I only had tools like this back then…

Tags: Learning · OS X · Programming · Technology

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment