Install the latest OpenCV4.3 under Centos8

Preface##

OpenCV is a cross-platform Computer Vision and Machine Learning software library based on the BSD license (open source) release, written in C++ language, it has C++, [Python] (https://baike.baidu.com/item/Python/407313), Java and MATLAB interfaces, and supports Windows, Linux, Android and Mac OS. OpenCV mainly tends to real-time visual applications, and uses MMX and SSE instructions when available. Provide support for C#, Ch, Ruby, GO.

installation##

Centos8 can install opencv in two ways

dnf installation

One is installed through dnf, which is simple to install, the version is 3.4.1, and the version is lower but stable.

dnf install opencv opencv-devel opencv-python

Execute the above command to install successfully, check whether the installation is successful through the command

pkg-config --modversion opencv

If it returns

3.4.1

Prove that the installation was successful.

Source installation opencv

If you want to install the latest version, you can install it through the source code, which is recommended here.

1、 Install dependencies
 dnf install epel-release git gcc gcc-c++ cmake3 qt5-qtbase-devel \

 python3 python3-devel python3-pip cmake python3-devel python3-numpy \

 gtk2-devel libpng-devel jasper-devel openexr-devel libwebp-devel \

 libjpeg-turbo-devel libtiff-devel tbb-devel libv4l-devel \

 freeglut-devel mesa-libGL mesa-libGL-devel \

 boost boost-thread boost-devel gstreamer1-plugins-base

It should be noted here that eigen3-devel cannot be installed directly through dnf, it needs to be installed through the following command

dnf --enablerepo=PowerTools install eigen3-devel
2、 Download OpenCV and OpenCV contrib library#####

Create a temporary directory

mkdir -p /tmp/opencv && cd /tmp/opencv
//This is slower, recommend the following domestic sources
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git

**Note **, the download speed of github is too slow, the reason is not listed. If you want to be faster, you can try to set /etc/hosts to increase

13.229.188.59 github.com
52.216.146.19 github-cloud.s3.amazonaws.com
199.232.4.133 raw.githubusercontent.com

The actual situation is not much faster, the download speed makes people crash. Here to recommend domestic sources (update github official code daily, caring:)), execute the following commands.

git  clone https://gitee.com/mirrors/opencv.git
git  clone https://gitee.com/mirrors/opencv_contrib.git
3、 Create a temporary directory and enter
cd /tmp/opencv/opencv && mkdir build && cd build

4、 Configure OpenCV build, run the following command

cmake3 -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local  -D INSTALL_C_EXAMPLES=ON  -D INSTALL_PYTHON_EXAMPLES=ON  -D OPENCV_GENERATE_PKGCONFIG=ON  -D OPENCV_EXTRA_MODULES_PATH=/tmp/opencv/opencv_contrib/modules  -D BUILD_EXAMPLES=ON ..

After the execution is complete, the output will be as follows:

- - Build files have been written to:/tmp/opencv/opencv/build
5、 Compile and run the following command
make -j1

Please note here, please modify the value of -j according to the processor, you can type nproc to view, the number of cpu in my system is 1.

6、 Install the OpenCV library, run the following command
make install
7、 Create the symlink opencv4.pc file to the /usr/share/pkgconfig directory, and then run ldconfig to rebuild the library cache
ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/
ldconfig
8、 Check OpenCV version
pkg-config --modversion opencv4

Will return normally

4.3.0
9、 To verify that the Python cv2 module is running, please run the following command
python3 -c "import cv2; print(cv2.__version__)"

Will return if there are no problems

4.4.0- pre
Official information: https://gocv.io/

Recommended Posts

Install the latest OpenCV4.3 under Centos8
Centos install the latest version of cmake
Install mysql5.7 under CentOS7
Install ActiveMQ under Centos7
Install PostgreSQL12 under CentOS7
Install CentOS under VMware
Install mysql under Centos 7
Install Jenkins under Centos 7
Install MariaDB under MariaDB Centos7
Install mysql5.1 under CentOS6.5
CentOS7 update the latest kernel | RPM directly install the kernel
Ubuntu install the latest Python 3.
Install Oracle11gR2 database under CentOS6.9
Install MySQL under Linux (CentOS 7)
Install Java JDK8 under CentOS6
Install MongoDB database under CentOS7
CentOS 6.8 under linux install mongodb
Centos7.6 install MySQL+Redis (latest version)
Install Mesos tutorial under CentOS7
Install and configure keepalived under CentOS 5.9
Compile and install LAMP under Centos 5.2
[Introduction to redis] Install redis under Centos
Install Harbor mirror warehouse under CentOS
Install Python3 and ansible under CentOS8
Install and use docker under CentOS 6.8
1.5 Install Centos7
The latest Centos7 installation Mysql8 guide
Install Python3 and Py under CentOS7
How to install OpenCV on CentOS 8
Install Mono 3.2 and Jexus 5.4 under CentOS 6.3
Install the latest version of Thunderbird and exchange plugins under ubuntu
Compile and install libmodbus library under CentOS7
Install mysql8.0.13 version under Linux CentOS7 system
Install Mono 2.10.8 and Jexus 5.0 under 32- and 64-bit CentOS 6.0
The fourth installment of Zabbix under CentOs7
Three ways to install JDK under CentOS
Install Docker CE in yum under CentOS 7
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS install Redmine
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
Centos6.5 install Tomcat
CentOS install Python 3.6
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Centos7 install Python2.7
Centos 7.6 install seleniu
CentOS 7.3 install Zabbix3
Centos7 install LAMP+PHPmyadmin
CentOS install mysql
CentOS install openjdk 1.8
CENTOS6.5 install CDH5.12.1 (1)
CentOS install PHP
CentOS6 install mist.io
Centos7 install Docker