OpenCV3 + Python + Mac

OpenCV is an open-source library for computer vision that we have found useful in bringing many applications to production settings. It is written in C++, but now also supports Python bindings, which can make rapid prototyping easier. Below we summarize our procedure for installing OpenCV3 on Mac OS X, with Python bindings and virtual environment support. The information can be found on many webpages, but was difficult to find all in one place. All of the following commands should be executed in the Terminal.

First install the Homebrew package manager if you have not already:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

At this point, you can test python bindings as follows:python -c "import cv2; print cv2.__version__"
and the output should be 3.x.x.

Lastly, some more operations are needed to allow these Python bindings to work inside a virtual environment. To manage virtual environments on Macs, we recommend using virtualenvwrapper, which can be installed as follows:pip install virtualenv
pip install virtualenvwrapper
echo 'source "/usr/bin/virtualenvwrapper.sh"' >> ~/.bash_profile
source "/usr/bin/virtualenvwrapper.sh"