android車牌識(shí)別系統(tǒng)EasyPR使用詳解
上篇文章介紹了身份證識(shí)別,現(xiàn)在我們來(lái)說(shuō)說(shuō)關(guān)于車牌識(shí)別。
EasyPR是一個(gè)開(kāi)源的中文車牌識(shí)別系統(tǒng),gitHub地址
EasyPR有如下特點(diǎn):
1. 它基于openCV這個(gè)開(kāi)源庫(kù),這意味著所有它的代碼都可以輕易的獲取。
2. 它能夠識(shí)別中文。例如車牌為蘇EUK722的圖片,它可以準(zhǔn)確地輸出std:string類型的”蘇EUK722”的結(jié)果。
3. 它的識(shí)別率較高。目前情況下,字符識(shí)別已經(jīng)可以達(dá)到90%以上的精度。
使用方法
package com.android.guocheng.easypr; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; import com.fosung.libeasypr.view.EasyPRPreSurfaceView; import com.fosung.libeasypr.view.EasyPRPreView; public class MainActivity extends AppCompatActivity { private EasyPRPreView easyPRPreView; private Button btnShutter; private TextView text; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); easyPRPreView = (EasyPRPreView) findViewById(R.id.preSurfaceView); btnShutter = (Button) findViewById(R.id.btnShutter); text = (TextView) findViewById(R.id.text); initListener(); } @Override protected void onStart() { super.onStart(); if (easyPRPreView != null) { easyPRPreView.onStart(); } } @Override protected void onStop() { super.onStop(); if (easyPRPreView != null) { easyPRPreView.onStop(); } } @Override protected void onDestroy() { super.onDestroy(); if (easyPRPreView != null) { easyPRPreView.onDestroy(); } } private void initListener() { easyPRPreView.setRecognizedListener(new EasyPRPreSurfaceView.OnRecognizedListener() { @Override public void onRecognized(String result) { if (result == null || result.equals("0")) { Toast.makeText(MainActivity.this, "換個(gè)姿勢(shì)試試!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, "識(shí)別成功", Toast.LENGTH_SHORT).show(); text.setText(result); } } }); btnShutter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { easyPRPreView.recognize();//開(kāi)始識(shí)別 } }); } }
布局文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00000000"> <com.fosung.libeasypr.view.EasyPRPreView android:id="@+id/preSurfaceView" android:layout_width="match_parent" android:layout_height="match_parent"/> <Button android:id="@+id/btnShutter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:text="識(shí)別" android:textSize="16sp" android:textColor="#FFFFFF" android:background="@color/colorAccent"/> <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:gravity="center" android:textColor="#FFFFFF" android:textSize="16dp" android:text="請(qǐng)將車牌放入框內(nèi)"/> <TextView android:id="@+id/text" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:gravity="center" android:textColor="#FFFFFF" android:textSize="18dp" android:layout_below="@+id/title"/> </RelativeLayout>
別忘了在manifest加入攝像機(jī)權(quán)限<uses-permission android:name="android.permission.CAMERA" />
app在運(yùn)行時(shí),有車牌限定框,在框的范圍內(nèi)進(jìn)行圖像裁剪,人為縮小了識(shí)別范圍,提高識(shí)別度。
本庫(kù)基于EasyPR_Android。
效果圖:
最后附上demo源碼
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android 線程之自定義帶消息循環(huán)Looper的實(shí)例
這篇文章主要介紹了Android 線程之自定義帶消息循環(huán)Looper的實(shí)例的相關(guān)資料,希望通過(guò)本文能幫助到大家,需要的朋友可以參考下2017-10-10Android實(shí)現(xiàn)九宮格手勢(shì)解鎖
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)九宮格手勢(shì)解鎖的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結(jié)構(gòu)
這篇文章主要為大家介紹了FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結(jié)構(gòu),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10Android進(jìn)階Hook攔截系統(tǒng)實(shí)例化View過(guò)程實(shí)現(xiàn)App換膚功能
這篇文章主要為大家介紹了Android進(jìn)階Hook攔截系統(tǒng)實(shí)例化View過(guò)程實(shí)現(xiàn)App換膚功能詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-01-01Android Gradle依賴管理、去除重復(fù)依賴、忽略的方式
這篇文章主要介紹了Android Gradle依賴管理、去除重復(fù)依賴、忽略的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03Android Intent發(fā)送廣播消息實(shí)例詳解
這篇文章主要介紹了Android Intent發(fā)送廣播消息實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下2017-04-04Android如何判斷當(dāng)前點(diǎn)擊位置是否在圓的內(nèi)部
這篇文章主要為大家詳細(xì)介紹了Android如何判斷當(dāng)前點(diǎn)擊位置是否在圓的內(nèi)部,解析拖動(dòng)圓形控件之內(nèi)響應(yīng)觸摸事件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05