Android Vision Api-条形码检测如何获取条形码类型? [英] Android Vision Api - Barcode detection how to get type of barcode?

查看:86
本文介绍了Android Vision Api-条形码检测如何获取条形码类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Google Vision API ,并且已经创建了标准的条形码读取器,但是我想检测读取的条形码的类型/格式,即 CODE 39 CODE 128 QR Code ...等.
反正有返回类型吗?

I am working with Android Google Vision API, and have created a standard barcode reader, but I want to detect what type/format of barcode is read i.e. CODE 39, CODE 128, QR Code.... etc.
Is there anyway to return the type?

谢谢

推荐答案

因为我没有找到任何将整数格式转换为文本值的内置函数
我使用了以下自定义方法

Because I does not found any bulid-in function to decode Format integer value to text value
I used following custom method

private String decodeFormat(int format) {
    switch (format){
        case Barcode.CODE_128:
            return "CODE_128";
        case Barcode.CODE_39:
            return "CODE_39";
        case Barcode.CODE_93:
            return "CODE_93";
        case Barcode.CODABAR:
            return "CODABAR";
        case Barcode.DATA_MATRIX:
            return "DATA_MATRIX";
        case Barcode.EAN_13:
            return "EAN_13";
        case Barcode.EAN_8:
            return "EAN_8";
        case Barcode.ITF:
            return "ITF";
        case Barcode.QR_CODE:
            return "QR_CODE";
        case Barcode.UPC_A:
            return "UPC_A";
        case Barcode.UPC_E:
            return "UPC_E";
        case Barcode.PDF417:
            return "PDF417";
        case Barcode.AZTEC:
            return "AZTEC";
        default:
            return "";
    }
}

这篇关于Android Vision Api-条形码检测如何获取条形码类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆