1. 程式人生 > >基於百度AI實現 車牌識別

基於百度AI實現 車牌識別

原文:http://www.cnblogs.com/linbin524/p/8036158.html

 

 

基於百度AI實現 車牌識別

總目錄地址:AI 系列 總目錄 

需要最新原始碼,或技術提問,請加QQ群:538327407

我的各種github 開源專案和程式碼:https://github.com/linbin524

 

 

前言

   目前百度的AI介面相對完善,對於文字識別類的操作還需要開發者一一去嘗試,去評估這效果到底是怎麼的。

文字識別的介面相對簡單,官方提供的SDK也整合很好,筆者只是在這上面做了一些前期性的功能資料校驗和過濾,以及返回結果的處理。

 

實驗效果

先來看一下識別效果:

 1、精細化車牌(識別準確)

 

2、實際場景車牌 (識別準確)

 

 

3、多車牌(只識別到一個車牌)

 

 

 

實際拓展思路

鑑於上述結果,目前百度車牌識別可以做到 實際應用場景的處理,但要真正結合、融合,需要開發者們自己做些前期處理,比如說,你需要在攝像頭捕捉車牌時候,自己去動態抓取行駛車牌的車牌,

在使用單個請求將車牌傳送給百度,從而實現在真實環境中的車牌識別。

ps:有關相關的技術 可以參考我另外一篇部落格,動態視訊中的人臉捕捉與人臉識別。 部落格地址:

http://www.cnblogs.com/linbin524/p/linbin524.html

 

程式碼解析:

1、介面方法

複製程式碼

   /// <summary>
        /// 車牌識別 返回實體結果
        /// </summary>
        /// <param name="tempImage"></param>
        /// <returns></returns>
        public static APIBaseModel<DrivingLicenseModel> GetPlateLicense(Image tempImage)
        {

            APIBaseModel<DrivingLicenseModel> tempModel = new APIBaseModel<DrivingLicenseModel>();
            tempModel.contextModel = new DrivingLicenseModel();

            var client = new Ocr.Ocr(Config.clientId, Config.clientSecret);
            var image = ImageHelper.ImageToBytes(tempImage, System.Drawing.Imaging.ImageFormat.Png);
            string result = client.PlateLicense(image).ToString();
            if (result.Contains("\"error_code\""))//說明異常
            {

                tempModel.state = false;
                tempModel.contextModel.errorTypeModel = Json.ToObject<ErrorTypeModel>(result);
                tempModel.errorMsg = tempModel.contextModel.errorTypeModel.error_discription = OCR_CharacterRecognitionErrorType.GetErrorCodeToDescription(tempModel.contextModel.errorTypeModel.error_code);

            }
            else
            {
                tempModel.state = true;
                tempModel.contextModel.successModel = Json.ToObject<DrivingLicenseSuessResultModel>(result);

            }
            return tempModel;
        }

複製程式碼

 

原始碼地址:github 上的連結

 

筆者原創!如果您覺得閱讀本文對您有幫助,請點一下“推薦”按鈕,您的“推薦”將是我最大的寫作動力!歡迎各位轉載,轉載請新增原部落格連線,否則保留追究法律責任的權利,謝謝! 需要最新原始碼,或技術提問,請加QQ群:538327407,由於原始碼在不斷完善,會在之後同步到AI開源專案中 linbin524,我的部落格地址:http://www.cnblogs.com/linbin524/