-1

在 onFailure 中获取 FirebaseMLException:执行 Firebase ML 任务时发生内部错误。

    FirebaseVisionBarcodeDetectorOptions options =
            new FirebaseVisionBarcodeDetectorOptions.Builder()
                    .setBarcodeFormats(
                            FirebaseVisionBarcode.FORMAT_QR_CODE,
                            FirebaseVisionBarcode.FORMAT_AZTEC)
                    .build();

    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);


    FirebaseVisionBarcodeDetector detector = FirebaseVision.getInstance()
            .getVisionBarcodeDetector();



    Task<List<FirebaseVisionBarcode>> result = detector.detectInImage(image)
            .addOnSuccessListener(new OnSuccessListener<List<FirebaseVisionBarcode>>() {
                @Override
                public void onSuccess(List<FirebaseVisionBarcode> barcodes) {
                    getInfoFromBarCodes(barcodes);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    // Task failed with an exception
                    Toast.makeText(BarCodeDetectionActivity.this, e.getMessage(),
                            Toast.LENGTH_SHORT).show();
                }
            });

显现

<meta-data
        android:name="com.google.firebase.ml.vision.DEPENDENCIES"
        android:value="face,barcode" />
4

1 回答 1

1

在这里,我通过将位图转换为 Bitmap.Config.ARGB_8888 来解决它,即 Bitmap.Config.RGB_565;

 FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
于 2018-06-01T10:23:22.697 回答