Skip to content

Instantly share code, notes, and snippets.

@MollsReis
Last active August 1, 2016 18:32
Show Gist options
  • Save MollsReis/ed7a428f718c8f6632b9 to your computer and use it in GitHub Desktop.
Save MollsReis/ed7a428f718c8f6632b9 to your computer and use it in GitHub Desktop.
Install OpenCV for MacOS with Python 3.4 + VirtulEnv
#!/usr/bin/env bash
# this script will download, configure, compile, and install opencv for macos with python 3.4 using a virtualenv
# instructions are from http://www.pyimagesearch.com/2015/06/29/install-opencv-3-0-and-python-3-4-on-osx/
# you need git, homebrew, and a virtualenv with python 3.4
# grab prereqs
brew install cmake pkg-config jpeg libpng libtiff openexr eigen tbb ffmpeg
# grab opencv source
cd ~
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
# configure build
cd ~/opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D PYTHON3_PACKAGES_PATH=~/<VIRTUAL ENV PATH HERE>/lib/python3.4/site-packages \
-D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4m.dylib \
-D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/include/python3.4m \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_opencv_python3=ON \
-D WITH_CUDA=OFF \
-D WITH_FFMPEG=ON \
-D WITH_QT=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules ..
# compile and install
make -j4
sudo make install
# clean up after yourself
cd ..
rm -rf build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment