ubuntu20.04 和centos8平台opencv4.5.3&opencv_contrib编译

1、源码下载:包括opencv  opencv_ocntrib

链接:https://pan.baidu.com/s/12kz7qkAFeNimwtSZxv7lqA 
提取码:6prp 
 

2、其中将xfeatures2d.zip解压后的文件复制到  opencv_contrib/modules/xfeatures2d/src中

3、在opencv目录下建立文件夹build,将opencv_contrib目录放到opencv目录下

4、安装依赖库

sudo yum -y install epel-release
sudo yum -y install gtk2-devel
sudo yum install -y libpng-devel
sudo yum install -y jasper-devel
sudo yum install -y openexr-devel
sudo yum install -y libwebp-devel
sudo yum -y install libjpeg-turbo-devel 
sudo yum -y install libtiff-devel 
sudo yum -y install tbb-devel eigen3-devel
sudo yum -y install boost boost-thread boost-devel
sudo yum -y install libv4l-devel

5、进入到build目下

cd opencv
mkdir build
cd build 

6、编译和安装

cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local  -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules/ -D WITH_TBB=OFF  -D WITH_CUDA=OFF -D BUILD_opencv_gpu=OFF -D BUILD_opencv_gpuarithm=OFF -D OPENCV_GENERATE_PKGCONFIG=ON .. 

然后输入命令进行编译

make  -j8

ps:  -j8 表示使用多线程编译,可以减少编译时间 -j后面跟的数字具体根据自己机器的cpu核心数

编译100%后,进行安装

make install

7、添加路路径

sudo ln -s /usr/local/lib64/pkgconfig/opencv4.pc   /usr/share/pkgconfig/
sudo ldconfig

你可能感兴趣的:(Opencv,opencv)