Step1:Install Homebrew
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew update
Step2: Install Python 2.7 and Python 3 using Homebrew
$ brew install python python3
$ brew linkapps python
$ brew linkapps python3
$ which python
$ which python3
Step3: Install OpenCV 3 with Python bindings on macOS using Homebrew
if use python as programming language
$ brew tap homebrew/science
$ brew install opencv3 --with-contrib --with-python3 --HEAD
if use java as programming language
brew install opencv3 --HEAD --with-contrib --with-java
Step4: bash_profile
create bash_profile in home address
touch ~/.bash_profile
open ~/.bash_profile
add sentence in this file
# Homebrew
export PATH=/usr/local/bin:$PATH
save it in terminal
source .bash_profile
in new terminal
pkg-config --libs opencv
pkg-config --cflags opencv
Reference
http://www.jianshu.com/p/3d149f167b41
http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/ (太复杂)
Start with brew doctor
which will show you errors with your brew setup.
http://www.jianshu.com/p/b9b35db5f084 (fix error)
Follow up1: xcode and python
https://vandadnp.wordpress.com/2012/07/05/building-and-running-python-scripts-with-xcode-4-x/
point: Cmd+Shift+G to “Go to Folder” and then I type in /usr/bin/python