notes/RK3568/移远/系统环境配置(编译OpenCV).md

144 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2024-04-29 22:22:30 +08:00
### 系统环境配置(编译OpenCV)
2023-09-11 18:18:20 +08:00
* 安装 software-properties-common
```
2023-10-18 17:00:19 +08:00
apt install software-properties-common -y
2023-09-11 18:18:20 +08:00
```
* 添加软件源
```
add-apt-repository "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main"
2023-11-11 13:41:44 +08:00
add-apt-repository "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe"
2023-09-11 18:18:20 +08:00
```
* 软件源更新
```
2023-10-18 17:00:19 +08:00
apt update
2023-09-11 18:18:20 +08:00
```
* 升级
```
2023-10-18 17:00:19 +08:00
apt upgrade
2023-09-11 18:18:20 +08:00
```
* 安装build-essential、cmake、git和pkg-config
```
2023-10-18 17:00:19 +08:00
apt install build-essential cmake git pkg-config -y
2023-09-11 18:18:20 +08:00
```
2023-09-13 22:30:46 +08:00
* 出现错误:
2023-10-18 17:00:19 +08:00
![错误信息](../../.image/CC706F1B-4AE8-477D-8275-52AC498D1966.png)
2023-09-11 18:18:20 +08:00
```
mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/
mkdir /var/lib/dpkg/info/
2023-10-18 17:00:19 +08:00
apt update
apt -f install
apt autoremove -y
2023-09-11 18:18:20 +08:00
```
* 安装jpeg格式图像工具包
```
apt-get install libjpeg8-dev -y
```
* 安装tif格式图像工具包
```
apt-get install libtiff5-dev -y
```
* 安装JPEG-2000图像工具包
```
2023-11-11 13:41:44 +08:00
apt install libjasper1 libjasper-dev
2023-09-11 18:18:20 +08:00
```
* 安装png图像工具包
```
apt-get install libpng-dev -y
```
* 安装视频 I/O 包
```
apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
```
* 安装 gtk2.0这一步比较麻烦如果一直无法安装成功可尝试将apt-get切换为国内镜像源
```
apt-get install libgtk2.0-dev -y
```
* 安装优化函数包
```
apt-get install libatlas-base-dev gfortran -y
```
2024-01-22 18:24:59 +08:00
<!-- apt install libblas-dev
apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev -y
apt install libdc1394-22-dev -y -->
2023-09-11 18:18:20 +08:00
* 解压
```
tar -xvf opencv-3.4.12.tar
cd opencv-3.4.12/
mkdir build
cd build
```
* 配置CMake
2023-11-11 13:41:44 +08:00
2023-09-11 18:18:20 +08:00
```
2023-11-11 13:41:44 +08:00
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_PNG=NO \
-D BUILD_JASPER=NO \
-D BUILD_TIFF=NO \
-D WITH_PNG=NO \
-D WITH_JASPER=NO \
-D WITH_TIFF=NO \
2024-03-13 16:34:53 +08:00
-D WITH_GSTREAMER=ON \
2024-01-22 18:24:59 +08:00
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D CMAKE_INSTALL_PREFIX=install ..
2023-09-11 18:18:20 +08:00
```
* 编译
```
make -j4
```
* 安装
```
make install
```
* 配置环境变量
```
vim /etc/ld.so.conf
```
* 在末尾添加 OpenCV 的 lib 路径
```
/usr/local/lib
```
* 更新
```
ldconfig
```
* 查看 OpenCV 版本,验证是否配置正确
```
pkg-config --modversion opencv
```