centos通过安装包安装opencv
时间: 2023-10-03 11:01:47 浏览: 107
1. 安装依赖库
```shell
yum -y install gcc gcc-c++ cmake git gtk2-devel pkgconfig numpy ffmpeg ffmpeg-devel gstreamer-plugins-base-devel libpng-devel libjpeg-devel libtiff-devel jasper-devel zlib-devel openexr-devel libwebp-devel libdc1394-devel libv4l-devel gstreamer1-plugins-base-devel eigen3-devel tbb-devel
```
2. 下载安装包
```shell
mkdir opencv
cd opencv
wget https://github.com/opencv/opencv/archive/4.5.2.tar.gz
tar -zxvf 4.5.2.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/4.5.2.tar.gz
tar -zxvf 4.5.2.tar.gz
```
3. 编译安装
```shell
cd opencv-4.5.2
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.2/modules ..
make -j8
make install
```
4. 配置环境变量
```shell
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf
ldconfig
```
5. 测试安装是否成功
```shell
pkg-config --modversion opencv4
```
如果返回版本号,则说明安装成功。
阅读全文