Last active
June 2, 2016 05:25
-
-
Save fpdevil/a29d53d00679041ff36b8ee2aac94420 to your computer and use it in GitHub Desktop.
Revisions
-
fpdevil revised this gist
Jun 2, 2016 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,9 @@ * First install the python3 using homebrew ```bash $ uname -a Darwin apple 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64 $ brew install python3 $ brew linkapps $ brew install cmake pkg-config -
fpdevil revised this gist
Jun 2, 2016 . 1 changed file with 40 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,41 +1,63 @@ # OpenCV3 with Python3.5 on Mac OS X Yosemite ## Installation of the dependencies * First install the python3 using homebrew ```bash $ brew install python3 $ brew linkapps $ brew install cmake pkg-config $ brew install jpeg libpng libtiff openexr $ brew install eigen tbb ``` ### Set the Path Variables ```sh export PATH=/usr/local/bin:$PATH export PYTHONPATH=/usr/local/lib/python3.5/site-packages ``` ### Check the Python 3 version and path ```sh $ which python3 /usr/local/bin/python3 ``` ### Install the NumPy Package using the Python package manager ```sh $ pip3 install numpy ``` ### Check the python system variables ```python $ python3 -m sysconfig $ python3 >>> import numpy as np >>> np.get_include() '/usr/local/lib/python3.5/site-packages/numpy/core/include' ``` ### Clone the opencv and opencv_contrib packages from github ```sh $ git clone https://github.com/Itseez/opencv.git $ cd opencv $ git checkout 3.1.0 $ git clone https://github.com/Itseez/opencv_contrib $ cd opencv_contrib $ git checkout 3.1.0 ``` ### Create the build directory ```sh $ cd opencv $ mkdir build $ cd build ``` ### Using cmake to configure * Adjust the Python3 Paths and set INSTALL_C_EXAMPLES=OFF ```bash $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D PYTHON3_EXECUTABLE=/usr/local/bin/python3 \ @@ -48,25 +70,31 @@ $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D BUILD_EXAMPLES=ON \ -D BUILD_opencv_python3=ON \ -D OPENCV_EXTRA_MODULES_PATH=/opt/software/opencv_contrib/modules .. ``` #### If there are no errors, run the make ```bash $ make -j4 ``` #### Install the library ```bash $ make install ``` #### Check the OpenCV Python shared object ```bash > ll /usr/local/lib/python3.5/site-packages/cv2* -rwxr-xr-x /usr/local/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so > ll lib/python3/ -rwxr-xr-x cv2.cpython-35m-darwin.so # Check the version $ python3 Python 3.5.1 (default, Feb 21 2016, 11:54:27) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.1.0' ``` -
fpdevil created this gist
Jun 2, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,72 @@ $ brew install python3 $ brew linkapps $ brew install cmake pkg-config $ brew install jpeg libpng libtiff openexr $ brew install eigen tbb export PATH=/usr/local/bin:$PATH export PYTHONPATH=/usr/local/lib/python3.5/site-packages $ which python3 /usr/local/bin/python3 $ pip3 install numpy $ python3 -m sysconfig $ python3 >>> import numpy as np >>> np.get_include() '/usr/local/lib/python3.5/site-packages/numpy/core/include' $ git clone https://github.com/Itseez/opencv.git $ cd opencv $ git checkout 3.1.0 $ git clone https://github.com/Itseez/opencv_contrib $ cd opencv_contrib $ git checkout 3.1.0 $ cd opencv $ mkdir build $ cd build Using cmake to configure Adjust the Python3 Paths and set INSTALL_C_EXAMPLES=OFF $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D PYTHON3_EXECUTABLE=/usr/local/bin/python3 \ -D PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.5/site-packages \ -D PYTHON3_LIBRARY=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5m.dylib \ -D PYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m \ -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/site-packages/numpy/core/include \ -D INSTALL_C_EXAMPLES=OFF \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D BUILD_EXAMPLES=ON \ -D BUILD_opencv_python3=ON \ -D OPENCV_EXTRA_MODULES_PATH=/opt/software/opencv_contrib/modules .. If there are no errors, run the make $ make -j4 Install the library $ make install Check the OpenCV Python shared object > ll /usr/local/lib/python3.5/site-packages/cv2* -rwxr-xr-x /usr/local/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so > ll lib/python3/ -rwxr-xr-x cv2.cpython-35m-darwin.so Check the version $ python3 Python 3.5.1 (default, Feb 21 2016, 11:54:27) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.1.0'