当前位置: 移动技术网 > IT编程>移动开发>Android > android车牌识别系统EasyPR使用详解

android车牌识别系统EasyPR使用详解

2019年07月31日  | 移动技术网IT编程  | 我要评论

纯情犀利哥作品集,步步惊心bt下载,瑞士军刀男 下载

上篇文章介绍了身份证识别,现在我们来说说关于车牌识别。

easypr是一个开源的中文车牌识别系统,github地址

easypr有如下特点:

1. 它基于opencv这个开源库,这意味着所有它的代码都可以轻易的获取。
2. 它能够识别中文。例如车牌为苏euk722的图片,它可以准确地输出std:string类型的”苏euk722”的结果。
3. 它的识别率较高。目前情况下,字符识别已经可以达到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="请将车牌放入框内"/>
  <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加入摄像机权限<uses-permission android:name="android.permission.camera" />
app在运行时,有车牌限定框,在框的范围内进行图像裁剪,人为缩小了识别范围,提高识别度。
本库基于easypr_android

效果图:

最后附上demo源码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网