12/24
12:17
IT OpenCV

Installing OpenCV 2.4.9 on Mac OSX with Python Support

source link  https://jjyap.wordpress.com/2014/05/24/installing-opencv-2-4-9-on-mac-osx-with-python-support/

Installing OpenCV 2.4.9 on Mac OSX with Python Support
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

发表评论