1.下载opencv4.6.0
系统: ubuntu 1804 64位
点我下载opencv 4.6.0
https://codeload.github.com/opencv/opencv/zip/refs/tags/4.6.0
2.编译安装opencv4.6.0
进入到下载目录下:
unzip -qo opencv-4.6.0.zip -d ./
cd opencv-4.6.0
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_ENABLE_NONFREE=True -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.6.0/modules ..
make -j
sudo make install
安装install
截图:
3.配置opencv环境
sudo cp -a /usr/local/include/opencv4/opencv2/ /usr/local/include/
===========================================>>>>>>
sudo vim /etc/ld.so.conf
在ld.so.conf
写入如下信息:
include /usr/local/lib
===========================================>>>>>>
sudo vim /etc/bash.bashrc
在bash.bashrc
写入如下信息:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
4.成功安装截图
# 更新
sudo updatedb
sudo ldconfig
# 安装成功,查看版本
pkg-config --modversion opencv4