python车牌识别系统开源代码_汽车牌照识别系统【YOLO+MLP】
車牌識別系統可以自動檢測并識別圖像中的車輛牌照,其算法主要包括牌照定位、牌照分割、字符識別等步驟。本文將給出一種基于深度學習的車牌識別系統方案。
要快速掌握開發人工智能系統的技能,推薦匯智網的 機器學習系列在線課程由于可以自動地從視頻圖像中提取車輛牌照信息,因此車牌識別系統可以應用于以下行業:
- 公共安全:用于檢測被盜搶車輛,將車牌與盜搶車輛數據庫記錄比對即可發現。
- 停車管理:停車場入口自動放行、出口自動計費。
- 道路安全:與雷達測試配合使用,識別超速車輛并記錄違章
我們的項目包含以下三個步驟:車輛牌照檢測、牌照字符分割、牌照字符識別。
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 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文件,注釋掉訓練部分,然后執行:
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
原文鏈接:車輛牌照自動檢測與識別 —— 匯智網
總結
以上是生活随笔為你收集整理的python车牌识别系统开源代码_汽车牌照识别系统【YOLO+MLP】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 哈尔滨银行结构性存款有保障吗?
- 下一篇: python人脸_Python 使用 f