Python2.7 + CentOS7 + OpenCV3

menu

I want to use OpenCV3 with Python2.7, so I will prepare an environment on CentOS7.

environment

Install the packages you may need

# yum -y groupinstall base "Development tools"
# yum -y install cmake
# yum -y install numpy python-devel python-imaging

OpenCV installation

Clone source

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

Build

# 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

Verification

# python -c 'import cv2; print cv2.__version__'
3.2.0

Recommended Posts

Python2.7 + CentOS7 + OpenCV3
OpenCV Samples (Python)
[Note] openCV + python
CentOS8 --Install --Python3
python openCV installation (memo)
Binarization with OpenCV / Python
Summary about Python3 + OpenCV3
Install Python3.4 on CentOS 6.6
Introduction to OpenCV (python)-(2)
Python 2.7 installation (yum) (CentOS 6.8)
OpenCV3 Python API list
Introducing Python 2.7 to CentOS 6.6
Python OpenCV tutorial memo
Install Python 2.7.3 on CentOS 5.4
Python, OpenCV camera capture
OpenCV basic code (python)
OpenCV for Python beginners
Python 3.5 installation (yum) (CentOS 6.8)
"Apple processing" with OpenCV3 + Python3
Image editing with python OpenCV
Camera capture with Python + OpenCV
[Python] Using OpenCV with Python (Basic)
Install Python 3.8 on CentOS 7 (SCL)
OpenCV3 installation for Python3 @macOS
Install Python 3.7 and Django 3.0 (CentOS)
Install OpenCV on Ubuntu + python
Make Opencv available in Python
Switch from python2.7 to python3.6 (centos7)
Face detection with Python + OpenCV
Install Python 3.8 on CentOS 8 (AppStream)
Notes on installing Python on CentOS
Using OpenCV with Python @Mac
Environment construction of python and opencv
Shining life with Python and OpenCV
[Python] Using OpenCV with Python (Image Filtering)
Neural network with OpenCV 3 and Python 3
[Python] Using OpenCV with Python (Image transformation)
[Python] Using OpenCV with Python (Edge Detection)
Put python, numpy, opencv3 in ubuntu14
Disable python2.6 ssl3 protocol in centos6
Background subtraction, python, mog, gmg, opencv3.1
Easy Python + OpenCV programming with Canopy
Set up Python environment on CentOS
Create a python environment on centos
Try face recognition with python + OpenCV
Cut out face with Python + OpenCV
Face recognition with camera with opencv3 + python2.7
Load gif images with Python + OpenCV
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
Install Python on CentOS using Pyenv
Find image similarity with Python + OpenCV
Use OpenCV with Python 3 in Window
Draw an illustration with Python + OpenCV
Introduction to image analysis opencv python
Build a python3 environment on CentOS7
Track baseball balls with Python + OpenCV
Graph Based Segmentation with Python + OpenCV
Install Python on CentOS using pyenv
CentOS 6.x x86_64 Python-2.7.4 rpm Package Creation
Draw arrows (vectors) with opencv / python
OpenCV3 & Python3 environment construction on Ubuntu