Setting up OpenCV on Mac OSX Snow Leopard

2

Posted by Noj | Posted in Uncategorized | Posted on 06-07-2010

OpenCV is this god like library written in C/C++ that is used for computer vision. It has more than 500 algorithms and many modules for doing various different computer vision tasks. I thought I might give it a go.

After quick googling I landed on http://opencv.willowgarage.com/wiki/ . Downloaded OpenCV from sourceforge.net and ran make. Gave some error that it needs cmake. I downloaded cmake and ran the installer again. It still failed giving a 200 line error that made no sense.

I then did heaps more googling. Someone suggested to do a “sudo port install opencv”. Tried installing through macports. Even that failed as openCV had dependancies on 30 different libraries. Some libraries weren’t compatible with x64 architecture. I tried installing the libraries one by one by forcing macports to find x64 versions, but that failed as well. Some libraries won’t just get along with me.

Then after 3 days of painful searching and googling and trying out every possible method out there, I came upon this website http://vislab.cs.vt.edu/~vislab/wiki/index.php?title=Vision . It had a pre-built openCV mac framework. It had a beautiful installer and it installed like a charm. Moral of story “Terminal Geeks sometimes need to learn on how to make installation process easier for those who aren’t experts  in the domain”.

Then was there was another challenge. How do you get the code to compile. After another day of rumbling and swearing at openCV. I came upon this magic line. “-arch i386″ was the key here.

g++ -O3 <filename>.cpp -arch i386 -framework OpenCV -o <filename>

Also you’ll need to change the C/C++ headers in the following form.

“cv.h” – <OpenCV/OpenCV.h>
“highgui.h” – <OpenCV/highgui.h>
“cvXXXXX.h”-<OpenCV/XXXXX.h> where XXXXX is a library like cvaux, cvcompat, cvcore e.t.c

Hope this blog post can save others time who have similar problems. I will be uploading videos and my experiments shortly.

Comments (2)

Great! A few people have been asking me about how to install opencv on a mac. I have no idea, because I don’t have one… I’ll redirect them here.

Glad you found it useful.

Write a comment