OpenCV部署准备
Centos7 安装 opencv4.5.2 可能会导致编译错误!4.5.3进行了修复
下载地址
https://github.com/opencv/opencv_contrib/releases
https://github.com/opencv/opencv/releases
Cmake下载或升级
https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-linux-x86_64.tar.gz
Cmake安装
解压
tar -xvf cmake-3.21.1-linux-x86_64.tar.gz
编译
cd 进入解压目录
./configure
make && make install
OpenCV安装
将下载后的opencv和opencv_contrib放到/go目录下(目录可自定)
在/go目录下新建build目录(编译目录)
mkdir build
执行cmake命令(注意自己的目录)
cmake /go/opencv-4.5.3 -B/go/build -DENABLE_CXX11=ON -DOPENCV_EXTRA_MODULES_PATH=/go/opencv_contrib-4.5.3/modules -DBUILD_SHARED_LIBS=ON -DWITH_IPP=OFF -DWITH_MSMF=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF -DBUILD_DOCS=OFF -DENABLE_PRECOMPILED_HEADERS=OFF -DBUILD_opencv_saliency=OFF -DBUILD_opencv_wechat_qrcode=OFF -DCPU_DISPATCH= -DOPENCV_GENERATE_PKGCONFIG=ON -DWITH_OPENCL_D3D11_NV=OFF -DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int64_t -Wno-dev
此时新建的build目录应该不为空
进入build目录执行
make
编译过程时间较长
完成后编译的动态库位置 /usr/local/lib64
将动态库加入到环境中
vim /etc/ld.conf.d/opencv.conf
加入动态库的位置
/usr/local/lib64
刷新配置
ldconfig