Archive | May 2014

Installing OpenCV 2.4.9 on Mac OSX with Python Support

**OpenCV is now at 3.0.0! :), I will write up a guide on that when I get around to installing it

*Here is the updated version of my previous post since Brew finally added the most recent version of OpenCV!

1. First of all I’ll be using the package manager Homebrew to simplify things, you can get it here: http://brew.sh/

The reason I’ve decided to use Homebrew was because it installs packages into their own directory which makes everything nice and easy to find. I tried macports but didn’t like it.

2. Once you have brew installed you can go ahead and and add homebrew/science which is where OpenCV is located using:

brew tap homebrew/science

3. If you want to see other possible options such as when compiling (such as using tbb) you can use info

brew info opencv

Go ahead and install OpenCV now

brew install opencv

4. You’re done! You can find OpenCV at

cd /usr/local/Cellar/opencv/2.4.9/

Setting up Python

1. Navigate to your python path, if you don’t know where it is when you installed Python you can find it in your .bash_profile or using

cat ~/.bash_profile | grep PYTHONPATH

in my case we’ll be using

cd /Library/Python/2.7/site-packages/

2. Once there we need to link our compiled OpenCV files, create a symlink using

ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so

3. You’re done! You can make sure it works by running python and typing

import cv
Advertisements

Brew removing problem packages

In my last post I edited the opencv formula so I could get 2.4.8 before it was supported by brew. Now that they finally added 2.4.9 it was a pain to get it to forget my changes and just overwrite them.

error: Your local changes to the following files would be overwritten by merge:

I tried

rm /usr/local/Library/Taps/homebrew/homebrew-science/opencv.rb

This didn’t help so if you made any changes and brew finally gets the new version in my case for opencv the only thing that worked was

brew untap homebrew/science
brew update
brew tap homebrew/science

I hope this helps!