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