Graduation Design Smart Parking - License Plate Recognition Raspberry Pi Environment Construction

My task today is to build an environment for graduation design on Raspberry Pi, such as opencv

Raspberry Pi ready to boot

First burn the Raspberry Pi system

Put the blank ssh file into the boot disk of the SD card

Manually create a blank Notepad .txt file, name it ssh, rename it, and delete the .txt extension. Put this file into the boot disk of the SD card.

Configure the wifi file and put it into the boot disk of the SD card

Use the same method to create a new blank file wpa_supplicant.conf (note to delete the extension .txt)

Open wpa_supplicant.conf with a text editor and enter the following configuration, you can use multiple network{} to configure multiple wifi:

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    
    
	ssid="将我替换成第一个WiFi的名字,不删除引号,不能有中文"
	psk="将我替换成WiFi密码,不删除引号"
	priority=将我替换成数字,数字越大代表优先级越高
}
network={
    
    
	ssid="将我替换成第二个WiFi的名字,不删除引号,不能有中文"
	psk="将我替换成WiFi密码,不删除引号"
	priority=将我替换成数字,数字越大代表优先级越高
}
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
    
    
	ssid="dyk"
	psk="dyk159357"
	priority=5
}
network={
    
    
	ssid="FAST_55555"
	psk="dyk159357"
	priority=2
}

get raspberry pi ip

Change the source of the Raspberry Pi

The default download speed is very slow, so we need to replace the domestic source ourselves

Edit the /etc/apt/sources.list file

sudo vim /etc/apt/sources.list 

Use # to comment out the content of the original file and replace it with the following

deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi

Edit the /etc/apt/sources.list.d/raspi.list file

sudo vim /etc/apt/sources.list.d/raspi.list

Use # to comment out the content of the original file and replace it with the following

deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui

After replacing the source, run the following two commands

sudo apt-get update
sudo apt-get upgrade

This command will visit each URL in the source list, read the software list, and save it locally on the Raspberry Pi.

The above steps realized that Respbian's package manager apt-get changed the source to the Tsinghua University software mirror site, and updated the software list. In the future, when executing sudo apt-get install on the Raspberry Pi command line, the software name will be automatically downloaded from Tsinghua University. Open source software mirror site high-speed download

insert image description here

Change the source of pip

Configure the source change script

This method is effective for pro-testing on Raspberry Pi

Enter and run the following three commands in sequence on the command line of the Raspberry Pi

sudo mkdir ~/.pip
cd .pip
sudo chmod 777 pip.conf
sudo vim pip.conf

Enter the following into the open file:

[global]
timeout = 10
index-url =  http://mirrors.aliyun.com/pypi/simple/
extra-index-url= http://pypi.douban.com/simple/
[install]
trusted-host=
    mirrors.aliyun.com
    pypi.douban.com

Install Remote Desktop

sudo apt-get install xrdp

install opencv

I didn't choose to compile and install here. It's a waste of time, although it's not very clear the difference between compiling and installing and not compiling and installing.

Install dependencies

Please execute the following commands one by one:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libhdf5-dev libhdf5-serial-dev
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test python3-pyqt5
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev

Then execute

sudo pip3 install --no-cache-dir opencv-contrib-python==3.4.3.18

Test for successful installation

Run the following commands in sequence: sudo python3 >>> import cv2 >>> print(cv2.version) If the installation version can be output normally, the installation is successful.

import cv2  # 导入库
cap = cv2.VideoCapture(0)  # 开启摄像头

# 循环读取图像
while True:
    ok, img = cap.read()  # 读取摄像头图像
    if ok is False:
        print('无法读取到摄像头!')
        break

    # 展示图像
    cv2.imshow('image', img)

    k = cv2.waitKey(10)  # 键盘值
    if k == 27:   # 通过esc键退出摄像
        break

# 关闭摄像头
cap.release()
cv2.destroyAllWindows()

Install on Raspberry Pi

Big guy blog link
Thanks to this blog, I installed and reinstalled the Raspberry Pi system twice

To re-replace the source of pip or you can't download it

[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
extra-index-url=https://www.piwheels.org/simple/
[install]
use-mirrors = true
mirrors = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

some necessary environment

sudo apt-get install libhdf5-dev -y
sudo apt-get install libatlas-base-dev -y
sudo apt-get install libjasper-dev -y
sudo apt-get install libqt4-test -y
sudo apt-get install libqtgui4 -y
sudo apt-get install libatlas-base-dev -y

pip install

python3 -m pip install hyperlpr

Running the official website code directly will report the following error

pip3 install opencv-python==3.4.6.27
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

Because the latest version of opencv is not compatible with Raspberry Pi, it is necessary to roll back the version and install the environment that opencv depends on to run.

reinstall opencv

pip3 install opencv-python==3.4.6.27

test code

#导入包
from hyperlpr import *
#导入OpenCV库
import cv2
#读入图片
image = cv2.imread("car3.jpg")
#识别结果
print(HyperLPR_plate_recognition(image))

insert image description here
Ok, the environment is also very troublesome to set up, here is a record hahaha a little excited

Guess you like

Origin blog.csdn.net/qq_44866153/article/details/122532783