in General

Installing openCV 3.0 on macOS

doing some machine learning and want to install openCV the right way to be used with python, follow here!

Install home-brew for mac.

ruby -e "$(curl -fsSL"

python2.7 usually comes installed in macOS, if not

brew install python

add openCV to the search using the tap argument in home brew

brew tap homebrew/science

install openCV with the obvious command for installing opencv-2.4.12_2

brew install opencv

but we want to install opencv 3.0 which means, we have to compile from source.

hit the terminal with the following,

cd ~/Documents/dev
git clone
cd opencv
git checkout 3.0.0
mkdir build
cd build

      -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 OPENCV_EXTRA_MODULES_PATH=~/opencv/modules ..

now make with the number of jobs, i like to put the number of cores in your PC. when you don’t know, hit this to find out in a macOS sysctl -n hw.ncpu

make -j4

make install

when permissions are a problem, do the obvious

sudo make install

to check if it installed on your python path, hit the python shell


>>> import cv2
>>> cv2.__version__

if you want this to be installed in your python path of your virtual environment, you need to create a symbolic link of the installed openCV library in your brew installed python into your site packages of the virtual environment venv

next step of the project is to write the logic for converting the image/video feed as inputs for the machine learning algorithm.


Write a Comment



This site uses Akismet to reduce spam. Learn how your comment data is processed.