目录
一、如果你是32位系统安装opencv
树莓派4b 4G 32位系统下安装opencv_RayChiu757374816的博客-CSDN博客
二、需求背景
树莓派本身配置非常低,要在这样的平台上跑深度学习模型非常吃力,因此尽可能的让其发挥最强的性能是我们必须要考虑的事情,据说经实测,树莓派64位比32位性能强一倍,因此我们直接放弃32位系统直接上64位。
但是经过几天尝试,发现64位的软件源非常不好配,因此安装opencv就很难进行下去,无论科大源、清华源、阿里源、还是其他国内源、亦或是混合软件源配置,开始测试很难update成功,而国外的源本身访问就是问题,不做其他处理也不能用。
后来清华源测试也安装上了,其实就是配置好sources.list,具体配置看下方。
三、两种源方式
如果使用清华源
cat /etc/apt/sources.list
#deb http://deb.debian.org/debian buster main contrib non-free
#deb http://deb.debian.org/debian-security/ buster/updates main contrib non-free
#deb http://deb.debian.org/debian buster-updates main contrib non-free
# Uncomment deb-src lines below then 'apt-get update' to enable 'apt-get source'
#deb-src http://deb.debian.org/debian buster main contrib non-free
#deb-src http://deb.debian.org/debian-security/ buster/updates main contrib non-free
#deb-src http://deb.debian.org/debian buster-updates main contrib non-free
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
cat /etc/apt/sources.list.d/raspi.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
这里吐槽一下清华源官方,首先我的Debian版本是10:
其实第一时间我想到的是清华源官网找软件源,然后我根据版本找到64位的并更新软件源后update:
居然失败。。。
如果使用国外源
通过网线直连树莓派和PC电脑,并且PC开启科学方式上网,曲线救国让树莓派可以很好的用原装的debian国外源了
进而update upgrade等待一段时间就会更新好软件库,下载的软件都到
/var/cache/apt/archives/
这里了:
四、安装64位系统下的opencv依赖
参考上边32位的,有一些区别,libjpeg8-dev安装会提示已经被其他库实现了,根据提示安装这个:libjpeg62-turbo-dev就行,libjpeg62-turbo-dev:armhf的是32位的不用管,其他的这两个没有安装成功:
五、编译安装opencv
参考上边32位系统的来即可,也很顺利:
六、一些思考
因为测试安装这些环境花费了好多时间,因此想尽量减少重复的工作,之前需要来回烧录系统从头开始搞环境,之前我把upgrade下来的库做了备份,本来希望不要来回让我到官方源下载库了,但是后来发现好像不能重复使用这些缓存的包,依然会再花时间下载貌似版本不一样的包:
因此现在我考虑利用dd命令打包系统镜像备份系统,这样可以将已经配置好的系统环境状态保留下来,类似docker打包或者虚拟机镜像记录版本一样,但是目前没有来的及测试,后续有时间再搞吧。