树莓派3B+/4 配置LRP python3环境搭建

标题在onenote上做的笔记,不方便转md,图片转不了,所以长图加纯文字。包含刷系统,常用设置,安装令人头疼的python库以及解决的思路

  1. OS

选择sd卡和下载好的镜像;

在清华镜像站下载img,不能刷iso的镜像,那是给pc端模拟树莓派用的。
https://mirrors.bfsu.edu.cn/#
北京外国语的镜像快些。

一边下一边刷arch 的系统。
插电开机后,有绿灯闪烁即正常。配置好wifi文件后,等待连接即可

使用xshell填写ip 192.168.137.90 和用户名密码 pi raspberry

选择接受并保存

连接成功后。

开启虚拟显示器模式后的远程vnc。 5901端口

  1. arch 默认是debian10的清华源,可以更换常规的pip源(百度)
    sudo apt-get install python3-pip
    为archlinux安装 python3的包管理工具
    pip3 install hyperlpr
    pip3安装hyperlpr给python3安装,它会自动安装对应依赖包

opencv4.5的编译应该比较久。
手头上有树莓派4,用来编译应该比3B+要快些。
等会opencv、keras之类的就用4b来安装。
刚好3B+上的一键安装opencv报错了。换机弄原生debian。
测试了在3B+上的系统可以在4上运行。

在debian原生系统上,仍然需要raspi-config开启vnc。

第一次发现显示不了界面,要修改分辨率resolution再reboot。

root 密码

获得低延时体验就调低画面质量。

使用requirements.txt安装依赖的方式
pip3 install -r requirements.txt
遇到opencv找不到指定版本,怀疑和换源有关。
Could not find a version that satisfies the requirement opencv-contrib-python3.4.2.16 (from -r requirements.txt (line 31)) (from versions: 3.4.11.45, 3.4.13.47, 4.4.0.46, 4.5.1.48)
No matching distribution found for opencv-contrib-python
3.4.2.16 (from -r requirements.txt (line 31))

sudo apt-get install python3-opencv
apt安装opencv。

将py37的离线包更具仓库的版本要求安装。

sudo apt-get install python3-scipy
使用这个安装 scipy 后可以正常安装keras
安装好keras和cv后发现import有问题,一般是numpy的版本问题,重新安装过,卸载再安装,将其他安装好后最后安装numpy。

sudo apt-get install libopencv-dev
倒入cv报错。导入keras只有警告说明numpy问题解决。

sudo apt-get install libatlas-base-dev
树莓派3B+安装opencv坑点,遇到了ImportError: libhdf5_serial.so.100: cannot open shared object file: No such file
https://blog.csdn.net/qq_38269799/article/details/83384291
ImportError: libhdf5_serial.so.100: cannot open shared object file: No such file or directory
原因:缺少了若干模块
解决方案:直接安装

发现pip3 安装的时候没有sudo 不知道会不会是cv安装后加载不了的结果。
pip3 install opencv-contrib-python
重新安装了这个模块。
这个编译感觉也比较久。
这里编译了一天还是报错,最后再stackflow和github的issue老大哥们的帮助下找到一片安装的文章。发现是指令不同。
sudo pip3 install opencv-python
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting opencv-python
Downloading https://www.piwheels.org/simple/opencv-python/opencv_python-4.5.1.48-cp37-cp37m-linux_armv7l.whl (10.5MB)
100% |████████████████████████████████| 10.5MB 37kB/s
Requirement already satisfied: numpy>=1.14.5 in /usr/lib/python3/dist-packages (from opencv-python) (1.16.2)
Installing collected packages: opencv-python

https://blog.piwheels.org/new-opencv-builds-including-opencv-4-x/

https://stackoverflow.com/questions/53137197/importing-opencv-in-python-idle-error-shared-object-file/60237868#60237868

https://github.com/amymcgovern/pyparrot/issues/34

demo的运行结果,注意图片名要对,不然会爆错
attributeerror: ‘nonetype’ object has no attribute ‘copy’

现在LRP的环境搭建已经完成。

  1. 编写代码
    a. 多线程picamera函数
    b. 循环实时检测车牌
    c. gpio点亮,注意端口 3和4不一样,//
    d. 文件读取 车牌

使用vscode远程ssh调试代码:

总结一下,树莓派3和4的系统可以通用,用4的性能在安装编译上比较有优势。
demo编写完成后,只是实现了一个车牌的单次识别,还剩下gpio在3b上的调用。
pi@raspberrypi:~/project/python $ pwd
/home/pi/project/python

pi@raspberrypi:~/project/python $ ls
car_num.txt HyperLPR LRPdemo.py test.py
其中 txt文件作为指定车牌的内容,可以用数据库代替。
运行 LRPdemo.py 会持续识别车牌号码,直到识别到含有txt的车牌为止。
pi raspberry 初始账户密码或者改过后的root

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_44880154/article/details/112390196