【问题标题】:how to set frame for barcode scanner?如何设置条码扫描仪的框架?
【发布时间】:2018-05-16 20:48:26
【问题描述】:

我有一个条码扫描器应用,它使用(使用 Google Mobile Vision API 进行条码检测) 在相机活动中,我想设置一个框架,以便应用程序只读取该框架中的条形码或二维码(就像所有扫描仪应用程序一样) 如何自定义?

这是相机 xml 布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".ScanBarcodeActivity">

    <SurfaceView
        android:id="@+id/cammeraPreview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

【问题讨论】:

  • 谷歌移动视觉 API?你试过了吗?
  • 是的谷歌 API

标签: android android-camera qr-code barcode-scanner


【解决方案1】:

这是一个条形码扫描仪而不是通用的相机预览并没有太大变化。您可以按照answer 在预览表面的“上方”添加一个矩形。请注意,这意味着您的 Activity 的顶级布局是 FrameLayout。

您可以尝试检查已识别条形码的坐标,如果它们与您绘制的矩形不匹配,则忽略它,但 IMO 这对您和最终用户来说都是浪费时间。这不会增加识别的可靠性。

另一方面,视觉指南(您的自定义框架)确实可以改善条码扫描器的用户体验,即使它背后没有程序逻辑。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-01
    • 2012-01-03
    • 1970-01-01
    相关资源
    最近更新 更多