前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >基于深度学习的车牌识别系统【YOLO+MLP】

基于深度学习的车牌识别系统【YOLO+MLP】

作者头像
用户1408045
发布2019-08-05 15:37:00
8.1K0
发布2019-08-05 15:37:00
举报
文章被收录于专栏:汇智网教程汇智网教程

车牌识别系统可以自动检测并识别图像中的车辆牌照,其算法主要包括牌照定位、牌照分割、字符识别等步骤。本文将给出一种基于深度学习的车牌识别系统方案。

在这里插入图片描述
在这里插入图片描述

要快速掌握开发人工智能系统的技能,推荐汇智网的 机器学习系列在线课程

由于可以自动地从视频图像中提取车辆牌照信息,因此车牌识别系统可以应用于以下行业:

  • 公共安全:用于检测被盗抢车辆,将车牌与盗抢车辆数据库记录比对即可发现。
  • 停车管理:停车场入口自动放行、出口自动计费。
  • 道路安全:与雷达测试配合使用,识别超速车辆并记录违章

我们的项目包含以下三个步骤:车辆牌照检测、牌照字符分割、牌照字符识别。

1、车辆牌照检测

我们使用Yolo(You Only Look One)算法来检测车辆牌照。Yolo是一个基于卷积神经网络的深度学习目标检测架构。该架构由 Joseph Redmon , Ali Farhadi, Ross Girshick和Santosh Divvala引入,2015年推出第一个版本,然后逐渐升级至版本3:

Yolo是一个端到端训练的单一网络,可以用来预测目标的类别与边界框。Yolo网络速度极快,可以每秒45帧的速度实时处理图像。其中一个较小规模的网络,被称为Fast YOLO,甚至达到了令人咂舌的155帧/秒的处理速度。

下面我们来实现YOLO V3网络。首先,我们准备一个有700张包含土耳其车辆牌照的图片的数据集,对每一张图片,我们都使用一个桌面应用LabelImg标注出车牌位置并存入一个xml文件。数据下载及网络训练脚本如下:

代码语言:javascript
复制
# First download Darknet project
$ git clone https://github.com/pjreddie/darknet.git# in "darknet/Makefile" put affect 1 to OpenCV, CUDNN and GPU if you # want to train with you GPU then time thos two commands
$ cd darknet
$ make# Load convert.py to change labels (xml files) into the appropriate # format that darknet understand and past it under darknet/
 https://github.com/KhazriAchraf/ANPR# Unzip the dataset
$ unzip dataset.zip# Create two folders, one for the images and the other for labels
$ mkdir darknet/images
$ mkdir darknet/labels# Convert labels format and create files with location of images
# for the test and the training
$ python convert.py# Create a folder under darknet/ that will contain your data
$ mkdir darknet/custom# Move files train.txt and test.txt that contains data path to
# custom folder
$ mv train.txt custom/
$ mv test.txt custom/# Create file to put licence plate class name "LP"
$ touch darknet/custom/classes.names
$ echo LP > classes.names# Create Backup folder to save weights
$ mkdir custom/weights# Create a file contains information about data and cfg 
# files locations
$ touch darknet/custom/darknet.data# in darknet/custom/darknet.data file paste those informations
classes = 1
train  = custom/train.txt
valid  = custom/test.txt
names = custom/classes.names
backup = custom/weights/# Copy and paste yolo config file in "darknet/custom"
$ cp darknet/cfg/yolov3.cfg darknet/custom# Open yolov3.cfg and change :
# " filters=(classes + 5)*3" just the ones before "Yolo"
# in our case classes=1, so filters=18
# change classes=... to classes=1# Download pretrained model
$ wget https://pjreddie.com/media/files/darknet53.conv.74 -O ~/darknet/darknet53.conv.74# Let's train our model !!!!!!!!!!!!!!!!!!!!!
$ ./darknet detector train custom/darknet.data custom/yolov3.cfg darknet53.conv.74

在网络训练完之后,为了识别图像中的车辆牌照,我们从darknet/custom/weights中选择最新的模型并在文件object_detection_yolo.py中写入其路径名称,我们也将使用yolov3.cfg文件,注释掉训练部分,然后执行:

代码语言:javascript
复制
python object-detection_yolo.py --image= image.jpg

这就是我们的结果:

在这里插入图片描述
在这里插入图片描述

2、车牌字符分割

现在我们要分割出我们的车牌号码。这个步骤的输入是车牌图像,我们必须能够提取出单个字符的图像。由于这一步骤的输出将用于识别步骤,因此对于一个车牌识别系统而言,车牌分割步骤非常重要。为了尽可能的正确分割车牌字符,我们需要进行必要的预处理。

在这里插入图片描述
在这里插入图片描述

像素投影直方图用来找出字符区域的上限和下限、左边及右边。我们使用水平投影来找出字符的顶部 和底部位置,使用垂直投影来找出字符的左边和右边位置:

在这里插入图片描述
在这里插入图片描述

从车辆牌照中提取数字的另一个方法时使用形态学的开/闭操作来生成一些连通区域,然后再使用连通跟踪算法提取这些连通区域。

3、车牌字符识别

识别阶段是我们的车牌自动检测与识别系统的最后一个环节,识别是基于前面环节得到的单个字符图像。我们的模型将对这些图像进行预测,从而得到最终的车牌号码。

为了尽可能利用训练数据,我们将每个字符单独切割,得到一个车牌字符数据集,该数据集中包含11个类(数字0-9以及阿拉伯单词),每个类包含30~40张字符图像,图像为28X28的PNG格式。

然后,我们就多层感知器MLP和K近邻分类器KNN的比较进行了一些调研,研究结果标明,对于多层感知器而言,如果隐层的神经元增多,那么分类器的性能就会提高;同样,对于KNN而言,性能也是随着近邻数量的增多而提高。不过由于KNN的可调整潜力要远远小于MLP,因此我们最终选择在这个阶段使用多层感知器MLP网络来识别分割后的车牌字符:

在这里插入图片描述
在这里插入图片描述

你可以在这里找到代码及数据集:github


原文链接:车辆牌照自动检测与识别 —— 汇智网

(adsbygoogle = window.adsbygoogle || []).push({});

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、车辆牌照检测
  • 2、车牌字符分割
  • 3、车牌字符识别
相关产品与服务
图像识别
腾讯云图像识别基于深度学习等人工智能技术,提供车辆,物体及场景等检测和识别服务, 已上线产品子功能包含车辆识别,商品识别,宠物识别,文件封识别等,更多功能接口敬请期待。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档