目录
一、介绍
本文使用mlkit进行部署
二、添加依赖
implementation 'com.google.mlkit:barcode-scanning:17.2.0'
三、页面设计
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button0"
android:layout_width="100dp"
android:layout_height="100dp"
android:text="图形识别"
/>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_below="@+id/button0"
/>
<Button
android:id="@+id/album"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@+id/image"
android:text="相册"
/>
<Button
android:id="@+id/camera"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="@+id/image"
android:layout_alignParentRight="true"
android:text="相机📷"
/>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/image"
android:layout_toRightOf="@+id/album"
android:layout_toLeftOf="@+id/camera"
android:scrollbars="vertical"
android:fadeScrollbars="false"
android:text="显示结果:"
/>
</RelativeLayout>
四、二维码识别使用
正确率还说蛮高的