OpenCV3 & Python3 environment construction on Ubuntu

Environment construction on Ubuntu

The standard package is only for Python2, so prepare it yourself. There seems to be a problem with cmake's Python 3.4 detection process, and it didn't work very well, so I'll make a note of it as a reminder.

Target environment

It was relatively easy to do in a windows environment, but I never thought it would be so hard on Ubuntu.

Preparation

Install the required packages

Referenced site Installer Opencv 3 sur Ubuntu 14.04 Trusty (It's not English, but I understand it as it is)

sudo apt install libopencv-dev build-essential checkinstall cmake pkg-config yasm libtiff4-dev libjpeg-dev libjasper-dev \
libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev \
libv4l-dev python3-dev python3-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev \
libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils python3.4-dev

Copy pyconfig.h

I don't know if I need it

sudo cp /usr/include/python3.4m/pyconfig.h /usr/include/python3.4m/pyconfig.h_old
sudo cp /usr/include/i386-linux-gnu/python3.4m/pyconfig.h /usr/include/python3.4m/

Edit cmake file

I don't know that cmake has 3.4 in python version, so I'll tell you. FindPython{Interp,Libs}: Search for Python 3.4. The edit target is

Get the source code

git clone https://github.com/Itseez/opencv.git

cmake Set various options with cmake-gui In my environment, I got an error because the hash of the file is different, so I had to set WITH_IPP = OFF.

Detect Python libraries

Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.6", minimum required is "2.7") 
Could NOT find PythonLibs (missing:  PYTHON_INCLUDE_DIRS) (found suitable exact version "2.7.6")
Found PythonInterp: /usr/bin/python3.4 (found suitable version "3.4", minimum required is "3.4") 
Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES) (Required is exact version "3.4.0")
Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.6", minimum required is "2.7") 
Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable exact version "2.7.6") 
Found PythonInterp: /usr/bin/python3.4 (found suitable version "3.4", minimum required is "3.4") 
Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.4m.so (found suitable exact version "3.4.0")

make Once you have a Makefile, there should be no problem after that.

make -j4
sudo make install

Recommended Posts

OpenCV3 & Python3 environment construction on Ubuntu
Created Ubuntu, Python, OpenCV environment on Docker
Install OpenCV on Ubuntu + python
Environment construction of python and opencv
Python environment construction memo on Windows 10
Prepare Python development environment on Ubuntu
Anaconda python environment construction on Windows 10
Python environment construction
Building a Python environment on Ubuntu
Environment construction (python)
Python environment construction memo on Mac
Python development environment construction on macOS
python environment construction
Python --Environment construction
Python environment construction
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
python environment construction
Environment construction of "Tello_Video" on Ubuntu
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Python virtual environment and packages on Ubuntu
Steps to install Python environment on Ubuntu
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
Create an OpenCV3 + python3 environment on OSX
Build a Python + OpenCV environment on Cloud9
python windows environment construction
homebrew python environment construction
Python development environment construction
python2.7 development environment construction
build Python on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Mac environment construction Python
Python environment construction @ Win7
[Note] Python environment construction on rental server "CORESERVER"
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Install python package in personal environment on Ubuntu
[0] TensorFlow-GPU environment construction built with Anaconda on Ubuntu
[Venv] Create a python virtual environment on Ubuntu
Python 3.x environment construction by Pyenv (CentOS, Ubuntu)
[Ubuntu 18.04] Tensorflow 2.0.0-GPU environment construction
Python + Anaconda + Pycharm environment construction
Set up Python 3.4 on Ubuntu
Use matplotlib on Ubuntu 12 & Python
Python environment construction (Windows10 + Emacs)
CI environment construction ~ Python edition ~
Put Python 3.x on Ubuntu
Python environment construction For Mac
Anaconda3 python environment construction procedure
Build Python environment on Windows
Python3 environment construction (for beginners)
Introducing TensorFlow on Ubuntu + Python 2.7
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
Ubuntu14.04 + GPU + TensorFlow environment construction
[Tensorflow] Tensorflow environment construction on Windows 10
Linux environment construction (on WSL environment)
Environment construction of python2 & 3 (OSX)
[Python] OpenCV environment construction with Docker (cv2.imshow () also works)
I made a Python3 environment on Ubuntu with direnv.
Install NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.1, cudnn 7.6 on Ubuntu 18.04.3 LTS + python environment construction
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)