项目地址:https://github.com/szad670401/HyperLPR.git
主要使用的是opencv,官方文档:http://www.woshicver.com/FirstSection/0_OpenCV-Python Tutorials/
1 安装开源库
pip install hyperlpr
2 demo实现(原项目给的demo)
#导入包
from hyperlpr import *
#导入OpenCV库
import cv2
#读入图片
image = cv2.imread("car1.jpg")#与py文件在同一目录下
#识别结果
print(HyperLPR_plate_recognition(image))
错误1:AttributeError: module 'cv2.cv2' has no attribute 'estimateRigidTransform'
分析1:可能是opencv版本过高,estimateRigidTransform方法已被启用,需要进行替换,替换规则如下
错误2:cv2.error: OpenCV(4.5.5) :-1: error: (-5:Bad argument) in function 'warpAffine'
分析2:cv2.estimateAffinePartial2D()和estimateAffine2D(),函数都有两个返回值,第一个返回值等于cv2.estimateRigidTransform()函数的返回值。所以需要对语句进行修改。
# mat_= cv2.estimateAffine2D(org_pts, target_pts, True)
mat_ , _= cv2.estimateAffine2D(org_pts, target_pts, True)
3 运行程序,效果如下
4 不足(待修改)
项目要求对图片内所有车牌进行识别,如上图只识别出了一个,需要进一步引用代码