I want to use OpenCV3 with Python2.7, so I will prepare an environment on CentOS7.
# yum -y groupinstall base "Development tools"
# yum -y install cmake
# yum -y install numpy python-devel python-imaging
I want to use createLBPHFaceRecognizer (), so opencv_contrib is also cloned
# cd /usr/local/src
# git clone https://github.com/opencv/opencv.git
# git clone https://github.com/opencv/opencv_contrib.git
Check out stable version
# cd /usr/local/src/opencv
# git tag | tail
2.4.9.1
3.0-ocl-tech-preview
3.0-ocl-tp2
3.0.0
3.0.0-alpha
3.0.0-beta
3.0.0-rc1
3.1.0
3.2.0
3.2.0-rc
# git checkout 3.2.0
# cd /usr/local/src/opencv_contrib
# git tag | tail
3.0.0
3.0.0-beta
3.0.0-rc1
3.1.0
3.2.0
3.2.0-rc
# git checkout 3.2.0
# mkdir /usr/local/src/opencv/build
# cd /usr/local/src/opencv/build
# cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_opencv_python2=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D PYTHON_EXECUTABLE=$(which python) \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
..
# make -j$(nproc)
# make install
Put a symbolic link so that you can refer to it from Python
# ln -s /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/site-packages/cv2.so
# python -c 'import cv2; print cv2.__version__'
3.2.0
Recommended Posts