龙空技术网

车牌识别系统原理与代码「YOLO+MLP」

新缸中之脑 12419

前言:

如今我们对“基于卷积神经网络的车牌识别算法”大概比较看重,大家都想要剖析一些“基于卷积神经网络的车牌识别算法”的相关知识。那么小编也在网摘上收集了一些有关“基于卷积神经网络的车牌识别算法””的相关内容,希望兄弟们能喜欢,朋友们一起来学习一下吧!

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

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

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

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

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

1、车辆牌照检测

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

Yolo v1;论文Yolo v2:论文Yolo v3;论文

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

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

# First download Darknet project$ git clone  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/  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 informationsclasses = 1train = custom/train.txtvalid = custom/test.txtnames = custom/classes.namesbackup = 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  -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文件,注释掉训练部分,然后执行:

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

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

标签: #基于卷积神经网络的车牌识别算法