Skip to content

Instantly share code, notes, and snippets.

@gaquino
Last active August 29, 2015 14:07
Show Gist options
  • Save gaquino/e8e297bd52fdbfb7f007 to your computer and use it in GitHub Desktop.
Save gaquino/e8e297bd52fdbfb7f007 to your computer and use it in GitHub Desktop.
Install OpenCV with Python module at Mac
1-) Download and install Brew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
$ brew upgrade
$ brew install wget
$ brew install cmake
2-) Download and install OpenCV 2.4.9
$ wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip?r=http%3A%2F%2Fopencv.org%2Fdownloads.html&ts=1413724769&use_mirror=ufpr
$ unzip opencv-2.4.9.zip
$ cd opencv-2.4.9.zip
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_open cv_ocl=OFF ..
$ make -j8
$ sudo make install
3-) install numpy and opencv+python by brew
-add homebrew/science which is where OpenCV is located using
$ brew tap homebrew/science
$ brew install numpy
$ brew install opencv
4-) Create python opencv lib symlinks
$ cd /Library/Python/2.7/site-packages/
$ sudo ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
$ sudo ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so
5-) test it
Gustavos-MacBook-Pro:site-packages gaquino$ python
Python 2.7.8 (default, Oct 16 2014, 05:18:45)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>
@gaquino
Copy link
Author

gaquino commented Oct 20, 2014

Get any trouble with xcode command line on Yosemite? try to install it manually https://developer.apple.com/downloads/index.action?=command%20line%20tools#.

On my iMac last command line was not updated and brew just stop to work and come back to normal when I apply this command line package 10.10 sdk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment