My blog address: poke here
To run the command:
brew install opencv3 --with-python3 --c++11 --with-contrib brew link --force opencv3
Test:
$ python3 3.5.120201612:52:19) 4.2.17.3.0 (clang-703.0.31)] on darwin "help""copyright""credits"or"license"for more information. >>>import cv2
If there is no error, the installation was successful, congratulations! Explain the above command first.
Brew Install OPENCV3 This command is used to indicate the installation of the Python3 version, (with OpenCV, opencv3 two python versions, the former corresponds to Python2),
--with-python3 used to tell homebrew to let OpenCV support Python3,
--c++11 used to tell homebrew to provide c++11 support,
--with-contrib is used to install OPENCV contrib support.
If after the above steps are still not installed successfully opencv (in fact OpenCV has been installed, but not the correct and python3 associated), you can try again the following command:
brew&&brew link --force opencv3
Try again whether success, if successful, congratulations you do not have to look down, if not successful, and then look, we are the next task is to properly make Python3 and OPENCV related together. Notice that we have installed the program above using homebrew, homebrew installed program location is below.
So what we need to find is the OpenCV cv2*.so file, (refer to my previous Ubuntu installation OpenCV and finally the associated cv2.so file), and finally my so file location is:
/usr/local/Cellar/opencv3/3.1.0_4/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so
The following is associated with the PYTHON3 environment, and also with the virtual virtualenv development environment.
I'm associated with a virtual environment, and the Python entity environment is the same, just go to Python3 's Site-packages folder and create a soft link underneath the original so.
cd /usr/local/lib/python3.5/site-packages ln -s /usr/local/Cellar/opencv3/3.1.0_4/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so cv2.so
Activating the VIRTUALENV virtual environment, entering Python
>>>import cv2 >>> cv2.__version__ '3.1.0'
Run the following command to indicate that the installation was successful.
Reference: Poke here
Mac OS Installation OpenCV (PYTHON3)