Difference between revisions of "OpenCV on OSX"

From Noah.org
Jump to navigationJump to search
m (Created page with 'Category: Engineering In a nutshell, this is what you need to do: <pre> cd ~ # Setup Python virtual env for OpenCV work. pip install virtualenv virtualenvwrapper source /usr…')
 
m
 
Line 1: Line 1:
 
[[Category: Engineering]]
 
[[Category: Engineering]]
 +
[[Category: Python]]
 +
[[Category: OSX]]
  
 
In a nutshell, this is what you need to do:
 
In a nutshell, this is what you need to do:

Latest revision as of 15:40, 23 March 2016


In a nutshell, this is what you need to do:

cd ~
# Setup Python virtual env for OpenCV work.
pip install virtualenv virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
# See /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv cv
pip install numpy
# Build OpenCV.
brew install cmake pkg-config jpeg libpng libtiff openexr eigen tbb
cd ~
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 3.1.0
cd ~
git clone https://github.com/Itseez/opencv_contrib
cd opencv_contrib
git checkout 3.1.0
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D PYTHON2_PACKAGES_PATH=~/.virtualenvs/cv/lib/python2.7/site-packages \
    -D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/bin \
    -D PYTHON2_INCLUDE_DIR=/usr/local/Frameworks/Python.framework/Headers \
    -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON \
    -D BUILD_EXAMPLES=ON \
    -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
make -j4
# Try to avoid using "sudo make install"
make install

workon cv
python -c "import cv2; print(cv2.__version__)"