树莓派4b 4G 64位系统下安装opencv

本文介绍在树莓派64位系统上安装OpenCV的过程,包括配置国内外软件源、安装依赖库及编译步骤。面对软件源配置难题,文章分享了使用清华源和国外源的经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目录

一、如果你是32位系统安装opencv

二、需求背景

三、两种源方式

如果使用清华源

如果使用国外源

四、安装64位系统下的opencv依赖

五、编译安装opencv

六、一些思考


一、如果你是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打包或者虚拟机镜像记录版本一样,但是目前没有来的及测试,后续有时间再搞吧。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值