车牌识别算法,支持12种中文车牌类型 基于yolov5的车牌检测 车牌矫正以及 基于CRNN的车牌识别

1.单行蓝牌 2.单行黄牌 3.新能源车牌 4.白色警用车牌 5 教练车牌 6 武警车牌 7 双层黄牌 8 双层武警 9 使馆车牌 10 港澳牌车 11 双层农用车牌 12 民航车牌
效果如下:

基于yolov5车牌检测

车牌检测+关键点定位

1.第一步是目标检测,目标检测大家都很熟悉,常见的yolo系列,这里的话我用的是我修改后的yolov5系列),用yolov5训练的车牌检测效果如下:

如果对上面这样图片进行识别的话,那么干扰信息很多,会造成误识别,这里就是为什么要进行关键点识别,假设我们得到车牌的四个角点坐标:
通过透视变换,透视变换即可得到下图:

这样的图片进行识别的话就会非常容易了
所以在检测的同时,我们需要进行关键点定位
透视变换代码:

def four_point_transform(image, pts):# obtain a consistent order of the points and unpack them# individuallyrect = order_points(pts)(tl, tr, br, bl) = rect# compute the width of the new image, which will be the# maximum distance between bottom-right and bottom-left# x-coordiates or the top-right and top-left x-coordinateswidthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))maxWidth = max(int(widthA), int(widthB))# compute the height of the new image, which will be the# maximum distance between the top-right and bottom-right# y-coordinates or the top-left and bottom-left y-coordinatesheightA = np.sqrt(((tr[0] - br[0]) ** 2) + ((tr[1] - br[1]) ** 2))heightB = np.sqrt(((tl[0] - bl[0]) ** 2) + ((tl[1] - bl[1]) ** 2))maxHeight = max(int(heightA), int(heightB))# now that we have the dimensions of the new image, construct# the set of destination points to obtain a "birds eye view",# (i.e. top-down view) of the image, again specifying points# in the top-left, top-right, bottom-right, and bottom-left# orderdst = np.array([[0, 0],[maxWidth - 1, 0],[maxWidth - 1, maxHeight - 1],[0, maxHeight - 1]], dtype = "float32")# compute the perspective transform matrix and then apply itM = cv2.getPerspectiveTransform(rect, dst)warped = cv2.warpPerspective(image, M, (maxWidth, maxHeight))# return the warped imagereturn warped

2.这里关键点定位我们利用和人脸识别类似的方法进行,人脸是5个点,而车牌我们仅仅需要四个点就可以了。

车牌检测训练数据集可以主要利用了CRPD 和CCPD数据集,这里有我训练的代码,数据我也转换好了,直接训练就可以了
https://github.com/we0091234/Chinese_license_plate_detection_recognition

车牌识别

拿到车牌区域的图片后就可以利用crnn进行车牌识别了
整理了一些数据,包括12种车牌的训练数据集,以及训练步骤
车牌识别代码:my_demo_new.py

from plateNet import myNet_ocr
import torch
import torch.nn as nn
import cv2
import numpy as np
import os
import time
import argparse
def cv_imread(path):   #读取中文路径的图片img=cv2.imdecode(np.fromfile(path,dtype=np.uint8),-1)return imgdef allFilePath(rootPath,allFIleList):fileList = os.listdir(rootPath)for temp in fileList:if os.path.isfile(os.path.join(rootPath,temp)):allFIleList.append(os.path.join(rootPath,temp))else:allFilePath(os.path.join(rootPath,temp),allFIleList)# plateName="#京沪津渝冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云藏陕甘青宁新学警港澳挂使领民深危险品0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
plateName=r"#京沪津渝冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘粤桂琼川贵云藏陕甘青宁新学警港澳挂使领民航深0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
mean_value,std_value=(0.588,0.193)
def decodePlate(preds):pre=0newPreds=[]for i in range(len(preds)):if preds[i]!=0 and preds[i]!=pre:newPreds.append(preds[i])pre=preds[i]return newPredsdef image_processing(img,device):img = cv2.resize(img, (168,48))img = np.reshape(img, (48, 168, 3))# normalizeimg = img.astype(np.float32)img = (img / 255. - mean_value) / std_valueimg = img.transpose([2, 0, 1])img = torch.from_numpy(img)img = img.to(device)img = img.view(1, *img.size())return imgdef get_plate_result(img,device,model):# img = cv2.imread(image_path)input = image_processing(img,device)preds = model(input)# print(preds)preds=preds.view(-1).detach().cpu().numpy()newPreds=decodePlate(preds)plate=""for i in newPreds:plate+=plateName[i]return platedef init_model(device,model_path):check_point = torch.load(model_path,map_location=device)model_state=check_point['state_dict']cfg = check_point['cfg']model = myNet_ocr(num_classes=78,export=True,cfg=cfg)        #export  True 用来推理model.load_state_dict(model_state)model.to(device)model.eval()return modelif __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument('--model_path', type=str, default='output/360CC/crnn/2022-09-26-21-30/checkpoints/checkpoint_11_acc_0.9657.pth', help='model.pt path(s)')  parser.add_argument('--image_path', type=str, default='images', help='source') device = torch.device("cuda" if torch.cuda.is_available() else "cpu")# device =torch.device("cpu")opt = parser.parse_args()model = init_model(device,opt.model_path)if os.path.isfile(opt.image_path): right=0begin = time.time()img = cv_imread(opt.image_path)if img.shape[-1]!=3:img = cv2.cvtColor(img,cv2.COLOR_BGRA2BGR)plate=get_plate_result(img, device,model)print(plate)else:file_list=[]allFilePath(opt.image_path,file_list)for pic_ in file_list:try:pic_name = os.path.basename(pic_)img = cv_imread(pic_)if img.shape[-1]!=3:img = cv2.cvtColor(img,cv2.COLOR_BGRA2BGR)plate=get_plate_result(img,device,model)print(plate,pic_name)except:print("error")
有问题可以加入qq qun:871797331

车牌识别算法 基于yolov5的车牌检测+crnn中文车牌识别 支持12种中文车牌识别相关推荐

  1. 基于YOLOv5的舰船检测与识别系统(Python+清新界面+数据集)

    摘要:基于YOLOv5的舰船检测与识别系统用于识别包括渔船.游轮等多种海上船只类型,检测船舰目标并进行识别计数,以提供海洋船只的自动化监测和管理.本文详细介绍船舰类型识别系统,在介绍算法原理的同时,给 ...

  2. 【最强最全车牌识别算法】支持13种中文车牌识别的云端API部署(可直接获取源码使用)

    项目简介 在城市交通管理.视频监控.车辆识别和停车场管理中车辆检测与车牌识别是一项富有挑战而重要的任务.利用深度学习识别不同条件下的车辆及其车牌信息.更具体地说,实时目标检测网络(Yolov5)用于从 ...

  3. 基于YOLOv5的目标检测系统详解(附MATLAB GUI版代码)

    摘要:本文重点介绍了基于YOLOv5目标检测系统的MATLAB实现,用于智能检测物体种类并记录和保存结果,对各种物体检测结果可视化,提高目标识别的便捷性和准确性.本文详细阐述了目标检测系统的原理,并给 ...

  4. 【目标检测】基于yolov5的红细胞检测和计数(附代码和数据集,Ubuntu系统)

    写在前面:"路虽远,行则将至:事虽难,做则必成.只要有愚公移山的志气.滴水穿石的毅力,脚踏实地,埋头苦干,积跬步以至千里,就一定能够把宏伟目标变为美好现实." 首先感谢兄弟们的订阅 ...

  5. 基于YOLOv5的停车位检测系统(清新UI+深度学习+训练数据集)

    摘要:基于YOLOv5的停车位检测系统用于露天停车场车位检测,应用深度学习技术检测停车位是否占用,以辅助停车场对车位进行智能化管理.在介绍算法原理的同时,给出Python的实现代码.训练数据集以及Py ...

  6. 项目:基于yolov5的舰船检测+pycharm+机器学习+图像检测

    项目:基于yolov5的舰船检测+pycharm+机器学习+图像检测 项目将深度学习的方法引入海洋目标的检测,利用深度神经网络模型强大的学习能力和模型通用性,来实现准确.可靠和快速的目标自动检测和识别 ...

  7. 使用YMIR生产基于yolov5的头盔检测模型

    使用YMIR生产基于yolov5的头盔检测模型 1.概述 2.YOLOV5结构解析 YOLOV5在coco数据集性能测试图 3.算法基本信息 动手实测 查看训练.测试数据集 模型训练启动页面 模型运行 ...

  8. 【目标检测】基于yolov5的钢筋检测和计数(附代码和数据集)

    写在前面: 首先感谢兄弟们的订阅,让我有创作的动力,在创作过程我会尽最大能力,保证作品的质量,如果有问题,可以私信我,让我们携手共进,共创辉煌. 文末获取代码和数据集,请看检测效果: 一. 介绍 基于 ...

  9. 计算机视觉算法——基于Transformer的目标检测(DETR / Deformable DETR / DETR 3D)

    计算机视觉算法--基于Transformer的目标检测(DETR / Deformable DETR / DETR 3D) 计算机视觉算法--基于Transformer的目标检测(DETR / Def ...

  10. 基于YOLOv5的疲劳检测,可检测是否玩手机,抽烟,喝水,眨眼,打哈欠等

    基于YOLOv5的疲劳检测,可检测是否玩手机,抽烟,喝水,眨眼,打哈欠等

最新文章

  1. 华为:Access、Hybrid和Trunk三种模式的理解
  2. mysql之DML(SELECT DELETE INSERT UPDATE)
  3. linux安装vi 插件,Ubuntu上Vim安装NERDTree插件的详细操作步骤
  4. struts2文件上传一个错误的解决
  5. 参加金蝶OperaMasks-WebFramework成都推广活动后的感想
  6. bootstrap内容部分API解读(1)
  7. 元器件大一点好,还是小一点好?
  8. Spring IoC 容器
  9. qt中的qwidget如何实现自定义部件_2.3信号和槽(中)
  10. 最少交换次数python_leetcode第200周赛第三题leetcode1536. 排布二进制网格的最少交换次数...
  11. 4本数据库新书,大神都在追着看
  12. java 子串替换_Java中的多个同时子串替换
  13. Spreadjs表格
  14. uniapp好用项目和插件总结
  15. 【小象学院】案例4——52周存钱挑战v4.0
  16. linux中dns服务故障,Linux nslookup命令对DNS域名服务器进行故障排除
  17. Keil--视力保护--背景设置
  18. 什么是kick-off meeting?
  19. pip install 报错:ERROR: Exception: Traceback (most recent call last):..raise ValueError(“check_hostnam
  20. 华为电脑Linux进pe,华为 PE-TLOOM 开启USB调试模式

热门文章

  1. 网站建设中做到需求分析细致,网站优化也就顺理成章了
  2. PHP从入门到精通 第二版pdf
  3. python 人体建模_Matplotlib学习---可视化人体姿态
  4. SEO原创助手-SEO免费原创助手工具自动分析网站排名
  5. ITween操作API
  6. 微信开放平台Android常见问题
  7. java中XML转JSON、JSON转XML、XML转对象(Object)、对象(Object)转XML,利用XSD验证XML(手把手教你如何接收、处理、验证XML数据)
  8. Amaze UI后台管理模板 v2.7.2
  9. malloc函数说明
  10. html古诗竖行排列,古诗词竖版图片