Skip to content

Instantly share code, notes, and snippets.

@Naville Naville/README.md
Last active Jan 5, 2018

Embed
What would you like to do?
Compile OpenCV3 with opencv_contribution&&Python2&&Python3 Support

This is constructed with multiple tutorials online as well as opencv's issues

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/Development/opencv_contrib/modules -DPYTHON2_EXECUTABLE=$(which python2) -DPYTHON2_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  -DPYTHON2_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DPYTHON2_PACKAGES_PATH=$(python -c "import site; print(site.getsitepackages()[-1])")  -DPYTHON3_EXECUTABLE=$(which python3)  -DPYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  -DPYTHON3_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DPYTHON3_PACKAGES_PATH=$(python3 -c "import site; print(site.getsitepackages()[-1])") -DBUILD_opencv_python2=on -DBUILD_opencv_python3=on -DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DPYTHON_INCLUDE_DIRS=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_EXECUTABLE=$(which python3) ~/Development/opencv

This by default install for python3, for python2, change -DPYTHON_LIBRARY=$(python3 -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))") -DPYTHON_INCLUDE_DIRS=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_EXECUTABLE=$(which python3) 's python3 to python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.