android車牌識別系統(tǒng)EasyPR使用詳解
上篇文章介紹了身份證識別,現(xiàn)在我們來說說關(guān)于車牌識別。
EasyPR是一個開源的中文車牌識別系統(tǒng),gitHub地址
EasyPR有如下特點:
1. 它基于openCV這個開源庫,這意味著所有它的代碼都可以輕易的獲取。
2. 它能夠識別中文。例如車牌為蘇EUK722的圖片,它可以準確地輸出std:string類型的”蘇EUK722”的結(jié)果。
3. 它的識別率較高。目前情況下,字符識別已經(jīng)可以達到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, "換個姿勢試試!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, "識別成功", Toast.LENGTH_SHORT).show(); text.setText(result); } } }); btnShutter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { easyPRPreView.recognize();//開始識別 } }); } }
布局文件
<?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="識別" 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="請將車牌放入框內(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加入攝像機權(quán)限<uses-permission android:name="android.permission.CAMERA" />
app在運行時,有車牌限定框,在框的范圍內(nèi)進行圖像裁剪,人為縮小了識別范圍,提高識別度。
本庫基于EasyPR_Android。
效果圖:
最后附上demo源碼
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android 線程之自定義帶消息循環(huán)Looper的實例
這篇文章主要介紹了Android 線程之自定義帶消息循環(huán)Looper的實例的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-10-10FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結(jié)構(gòu)
這篇文章主要為大家介紹了FFmpeg?Principle分析Out?put?File?數(shù)據(jù)結(jié)構(gòu),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-10-10Android進階Hook攔截系統(tǒng)實例化View過程實現(xiàn)App換膚功能
這篇文章主要為大家介紹了Android進階Hook攔截系統(tǒng)實例化View過程實現(xiàn)App換膚功能詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-01-01Android Gradle依賴管理、去除重復(fù)依賴、忽略的方式
這篇文章主要介紹了Android Gradle依賴管理、去除重復(fù)依賴、忽略的方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03