How to install opencv on mac with virtualenv with opencv_contrib modules (Easy and fast)

infinex
infinex
Jul 30, 2017 · 1 min read

Previously, i tried to install opencv with homebrew and have difficulty configuring for the python packages for virtualenv. I finally found a working methods which works!

  1. Download cmake with gui using macport
  2. sudo port install cmake +gui
  3. git clone https://github.com/opencv/opencv
  4. git clone https://github.com/opencv/opencv_contrib
  5. create empty folder build in opencv/build
  6. run opencv-gui
  7. configure opencv-gui based on the following, change to your specific folder when necessary
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \-D PYTHON2_PACKAGES_PATH=~/.virtualenvs/notebook/lib/python2.7/site-packages \-D PYTHON2_LIBRARY=/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/bin \-D PYTHON2_INCLUDE_DIR=/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Headers \-D PYTHON_EXECUTABLE=/Users/yj/.virtualenvs/notebook/bin/python \-D PYTHON2_NUMPY_INCLUDE_DIRS=~/.virtualenvs/notebook/lib/python2.7/site-packages/numpy/core/include \-D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON \-D BUILD_EXAMPLES=ON \-D OPENCV_EXTRA_MODULES_PATH=/Users/yj/Projects/opencv_contrib/modules ..
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade