python车牌识别系统开源代码_汽车牌照识别系统【YOLO+MLP】
車牌識(shí)別系統(tǒng)可以自動(dòng)檢測(cè)并識(shí)別圖像中的車輛牌照,其算法主要包括牌照定位、牌照分割、字符識(shí)別等步驟。本文將給出一種基于深度學(xué)習(xí)的車牌識(shí)別系統(tǒng)方案。
要快速掌握開(kāi)發(fā)人工智能系統(tǒng)的技能,推薦匯智網(wǎng)的 機(jī)器學(xué)習(xí)系列在線課程由于可以自動(dòng)地從視頻圖像中提取車輛牌照信息,因此車牌識(shí)別系統(tǒng)可以應(yīng)用于以下行業(yè):
- 公共安全:用于檢測(cè)被盜搶車輛,將車牌與盜搶車輛數(shù)據(jù)庫(kù)記錄比對(duì)即可發(fā)現(xiàn)。
- 停車管理:停車場(chǎng)入口自動(dòng)放行、出口自動(dòng)計(jì)費(fèi)。
- 道路安全:與雷達(dá)測(cè)試配合使用,識(shí)別超速車輛并記錄違章
我們的項(xiàng)目包含以下三個(gè)步驟:車輛牌照檢測(cè)、牌照字符分割、牌照字符識(shí)別。
1、車輛牌照檢測(cè)
我們使用Yolo(You Only Look One)算法來(lái)檢測(cè)車輛牌照。Yolo是一個(gè)基于卷積神經(jīng)網(wǎng)絡(luò)的深度學(xué)習(xí)目標(biāo)檢測(cè)架構(gòu)。該架構(gòu)由 Joseph Redmon , Ali Farhadi, Ross Girshick和Santosh Divvala引入,2015年推出第一個(gè)版本,然后逐漸升級(jí)至版本3:
- Yolo v1;論文
- Yolo v2:論文
- Yolo v3;論文
Yolo是一個(gè)端到端訓(xùn)練的單一網(wǎng)絡(luò),可以用來(lái)預(yù)測(cè)目標(biāo)的類別與邊界框。Yolo網(wǎng)絡(luò)速度極快,可以每秒45幀的速度實(shí)時(shí)處理圖像。其中一個(gè)較小規(guī)模的網(wǎng)絡(luò),被稱為Fast YOLO,甚至達(dá)到了令人咂舌的155幀/秒的處理速度。
下面我們來(lái)實(shí)現(xiàn)YOLO V3網(wǎng)絡(luò)。首先,我們準(zhǔn)備一個(gè)有700張包含土耳其車輛牌照的圖片的數(shù)據(jù)集,對(duì)每一張圖片,我們都使用一個(gè)桌面應(yīng)用LabelImg標(biāo)注出車牌位置并存入一個(gè)xml文件。數(shù)據(jù)下載及網(wǎng)絡(luò)訓(xùn)練腳本如下:
# 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在網(wǎng)絡(luò)訓(xùn)練完之后,為了識(shí)別圖像中的車輛牌照,我們從darknet/custom/weights中選擇最新的模型并在文件object_detection_yolo.py中寫(xiě)入其路徑名稱,我們也將使用yolov3.cfg文件,注釋掉訓(xùn)練部分,然后執(zhí)行:
python object-detection_yolo.py --image= image.jpg這就是我們的結(jié)果:
2、車牌字符分割
現(xiàn)在我們要分割出我們的車牌號(hào)碼。這個(gè)步驟的輸入是車牌圖像,我們必須能夠提取出單個(gè)字符的圖像。由于這一步驟的輸出將用于識(shí)別步驟,因此對(duì)于一個(gè)車牌識(shí)別系統(tǒng)而言,車牌分割步驟非常重要。為了盡可能的正確分割車牌字符,我們需要進(jìn)行必要的預(yù)處理。
像素投影直方圖用來(lái)找出字符區(qū)域的上限和下限、左邊及右邊。我們使用水平投影來(lái)找出字符的頂部 和底部位置,使用垂直投影來(lái)找出字符的左邊和右邊位置:
從車輛牌照中提取數(shù)字的另一個(gè)方法時(shí)使用形態(tài)學(xué)的開(kāi)/閉操作來(lái)生成一些連通區(qū)域,然后再使用連通跟蹤算法提取這些連通區(qū)域。
3、車牌字符識(shí)別
識(shí)別階段是我們的車牌自動(dòng)檢測(cè)與識(shí)別系統(tǒng)的最后一個(gè)環(huán)節(jié),識(shí)別是基于前面環(huán)節(jié)得到的單個(gè)字符圖像。我們的模型將對(duì)這些圖像進(jìn)行預(yù)測(cè),從而得到最終的車牌號(hào)碼。
為了盡可能利用訓(xùn)練數(shù)據(jù),我們將每個(gè)字符單獨(dú)切割,得到一個(gè)車牌字符數(shù)據(jù)集,該數(shù)據(jù)集中包含11個(gè)類(數(shù)字0-9以及阿拉伯單詞),每個(gè)類包含30~40張字符圖像,圖像為28X28的PNG格式。
然后,我們就多層感知器MLP和K近鄰分類器KNN的比較進(jìn)行了一些調(diào)研,研究結(jié)果標(biāo)明,對(duì)于多層感知器而言,如果隱層的神經(jīng)元增多,那么分類器的性能就會(huì)提高;同樣,對(duì)于KNN而言,性能也是隨著近鄰數(shù)量的增多而提高。不過(guò)由于KNN的可調(diào)整潛力要遠(yuǎn)遠(yuǎn)小于MLP,因此我們最終選擇在這個(gè)階段使用多層感知器MLP網(wǎng)絡(luò)來(lái)識(shí)別分割后的車牌字符:
你可以在這里找到代碼及數(shù)據(jù)集:github
原文鏈接:車輛牌照自動(dòng)檢測(cè)與識(shí)別 —— 匯智網(wǎng)
總結(jié)
以上是生活随笔為你收集整理的python车牌识别系统开源代码_汽车牌照识别系统【YOLO+MLP】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 哈尔滨银行结构性存款有保障吗?
- 下一篇: python人脸_Python 使用 f