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.
Centos8 can install opencv in two ways
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.
If you want to install the latest version, you can install it through the source code, which is recommended here.
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
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
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
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.
make install
ln -s /usr/local/lib64/pkgconfig/opencv4.pc /usr/share/pkgconfig/
ldconfig
pkg-config --modversion opencv4
Will return normally
4.3.0
python3 -c "import cv2; print(cv2.__version__)"
Will return if there are no problems
4.4.0- pre
Recommended Posts