python OpenCV

Install OpenCV in Mac

OpenCV is Open Source Computer Vision library both academic and commercial.
Originally, it is based on C/C++.
Now, they have python, Java, Android, iOS library to wrap it.
Env

  • Mac OS X EI Capitan
  • python 2.7, 3.5
  • OpenCV 3.0

The easiest way to install is to use brew.
If you don’t have homebrew, install it.

Install python2.7, 3.5 using brew

brew install python python3
brew install numpy --with-python3

By default, Mac uses default python 2.7
To run above commands, now, we are using python of brew version

Install OpenCV 3.0 using brew

brew install opencv3 --with-contrib --with-ffmpeg --with-java --with-python3
brew link opencv3 --force

To run with –with-python3, we install python3 version. java and ffmpeg is arbitrary.
We cannot use qt5 in Mac so far.
OpenCV is under /usr/local/opt/OpenCV

Check

Check using command
python2

python
>>> import cv2
>>> cv2.__version__

python3

python3
>>> import cv2
>>> cv2.__version__