Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android setBarcodeFormats(条形码.QR_码)不起作用_Android_Qr Code_Google Vision - Fatal编程技术网

Android setBarcodeFormats(条形码.QR_码)不起作用

Android setBarcodeFormats(条形码.QR_码)不起作用,android,qr-code,google-vision,Android,Qr Code,Google Vision,我正在使用Google Play Vision API检测二维码。我对其他格式不感兴趣,所以我尝试使用该API调用来加快检测速度。如果我将其称为setBarcodeFormats(Barcode.ALL\u FORMATS),它可以检测到格式为256(qr\u code)的二维码,但是如果我将其初始化为setBarcodeFormats(Barcode.qr\u code),它不会检测到任何东西。以下是一些代码片段: override fun onCreate(savedInstanceStat

我正在使用Google Play Vision API检测二维码。我对其他格式不感兴趣,所以我尝试使用该API调用来加快检测速度。如果我将其称为
setBarcodeFormats(Barcode.ALL\u FORMATS)
,它可以检测到格式为256(qr\u code)的二维码,但是如果我将其初始化为
setBarcodeFormats(Barcode.qr\u code)
,它不会检测到任何东西。以下是一些代码片段:

override fun onCreate(savedInstanceState: Bundle?) {
    ...
    barcodeDetector = BarcodeDetector.Builder(applicationContext).setBarcodeFormats(Barcode.ALL_FORMATS).build()
    ...


private inner class ImageReaderOnImageAvailableListenerImpl : ImageReader.OnImageAvailableListener {
    override fun onImageAvailable(reader: ImageReader) {
        val image = reader.acquireNextImage()
        val buffer = image.planes[0].buffer;
        val bitmap: Bitmap? = if (buffer.hasArray()) {
            BitmapFactory.decodeByteArray(buffer.array(), buffer.arrayOffset(), buffer.remaining(), null);
        } else {
            val byteArray = ByteArray(buffer.remaining())
            buffer.get(byteArray)
            BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size, null);
        }

        val barcodes = barcodeDetector.detect(Frame.Builder().setBitmap(bitmap).build())
        image.close()
        this@QrCodeCaptureActivity.imageView.setImageBitmap(bitmap)

        if (barcodes.size() > 0) {
            for (index in 0 until barcodes.size()) {
                val barcode = barcodes.valueAt(index)
                logd("barcode $index: ${barcode.format} ${barcode.valueFormat} ${barcode.rawValue}")
            }
        } else {
            logd("no barcodes (${image.width}x${image.height})")
        }
    }
}

我也注意到了这一点,我认为这是一个错误。我刚和allI去了我也注意到了这一点,我想这是一个错误。最后我和所有人都去了