android車牌識(shí)別系統(tǒng)EasyPR使用詳解
上篇文章介紹了身份證識(shí)別,現(xiàn)在我們來說說關(guān)于車牌識(shí)別。
EasyPR是一個(gè)開源的中文車牌識(shí)別系統(tǒng),gitHub地址
EasyPR有如下特點(diǎn):
1. 它基于openCV這個(gè)開源庫,這意味著所有它的代碼都可以輕易的獲取。
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();//開始識(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í)別度。
本庫基于EasyPR_Android。
效果圖:

最后附上demo源碼
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Android基于hover組件實(shí)現(xiàn)監(jiān)控鼠標(biāo)移動(dòng)事件的方法
這篇文章主要介紹了Android基于hover組件實(shí)現(xiàn)監(jiān)控鼠標(biāo)移動(dòng)事件的方法,結(jié)合實(shí)例形式分析了hover組件監(jiān)控鼠標(biāo)光標(biāo)在view上變化的操作技巧,需要的朋友可以參考下2017-02-02
Android listview與adapter詳解及實(shí)例代碼
本文主要介紹Android listview與adapter的知識(shí)詳解,這里整理了相關(guān)資料及實(shí)現(xiàn)代碼和實(shí)現(xiàn)效果圖,有興趣的小伙伴可以參考下2016-09-09
Android LayoutInflater.inflate源碼分析
這篇文章主要介紹了Android LayoutInflater.inflate源碼分析的相關(guān)資料,需要的朋友可以參考下2016-12-12
android 自定義圓角button效果的實(shí)例代碼(自定義view Demo)
這篇文章主要介紹了android 自定義圓角button(自定義View Demo),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12
解決Bitmap通過getWidth和getHeight獲取尺寸不符的問題
這篇文章主要介紹了解決Bitmap通過getWidth和getHeight獲取尺寸不符的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-08-08
Android RecycleView添加head配置封裝的實(shí)例
這篇文章主要介紹了Android RecycleView添加head配置封裝的實(shí)例的相關(guān)資料,這里提供實(shí)例幫助大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-08-08
Android中使用Canvas繪制南丁格爾玫瑰圖(Nightingale rose diagram)
這篇文章主要介紹了Android中使用Canvas繪制南丁格爾玫瑰圖(Nightingale rose diagram),本文直接給出實(shí)現(xiàn)代碼和運(yùn)行效果圖,需要的朋友可以參考下2015-03-03
android 仿QQ動(dòng)態(tài)背景、視頻背景的示例代碼
本篇文章主要介紹了android 仿QQ動(dòng)態(tài)背景、視頻背景的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-03-03
Android開發(fā)之搜索框SearchView用法示例
這篇文章主要介紹了Android開發(fā)之搜索框SearchView用法,結(jié)合實(shí)例形式分析了Android搜索框SearchView的基本功能、用法及相關(guān)操作注意事項(xiàng),需要的朋友可以參考下2019-03-03

