简体   繁体   English

使用相机和Firebase ML套件在Android设备上进行文字识别不准确

[英]Text Recognition not accurate on Android device using camera and Firebase ML Kit

I am using Firebase ML Kit on Android device for text recognition using a camera without clicking image. 我在Android设备上使用Firebase ML Kit,使用相机进行文本识别,无需单击图像。 I am using it by receiving frames and getting bitmaps from the frames. 我通过接收帧并从帧中获取位图来使用它。 Then passing the Bitmaps into the Text Recognition method. 然后将位图传递给文本识别方法。 But the text recognized is not accurate. 但承认的文字并不准确。 Also, it is constantly changing but never giving accurate results. 此外,它不断变化,但从未给出准确的结果。 Please let me know what I am doing wrong. 请让我知道我做错了什么。

getting frames and Bitmaps: 获取帧和位图:

  public void onSurfaceTextureUpdated(SurfaceTexture surface) {
            frame = Bitmap.createBitmap(textureView.getWidth(), textureView.getHeight(), Bitmap.Config.ARGB_8888);
            textureView.getBitmap(frame);

            Bitmap emptyBitmap = Bitmap.createBitmap(textureView.getBitmap(frame).getWidth(), textureView.getBitmap(frame).getHeight(), textureView.getBitmap(frame).getConfig());
            if (textureView.getBitmap(frame).sameAs(emptyBitmap)) {
                // myBitmap is empty/blank
                System.out.println(" empty !!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            } else {
                System.out.println(" bitmap");


                        bitmap = textureView.getBitmap(frame);
                                runTextRecognition();
            }

text recognition: 文字识别:

private void runTextRecognition() {
    System.out.println(" text recognition!!!");
    FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
    FirebaseVisionTextRecognizer recognizer = FirebaseVision.getInstance().getOnDeviceTextRecognizer();
    recognizer.processImage(image).addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
        @Override
        public void onSuccess(FirebaseVisionText texts) {
            System.out.println("Text recognized ::: " + texts);
            textRecognized = true;
            processTextRecognitionResult(texts);

        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            e.printStackTrace();
        }
    });

}

You can try Mobile Text Vision API for OCR (Optical Character Recognition) in Android. 您可以在Android中尝试使用Mobile Text Vision API进行OCR(光学字符识别)。

Refer to this Google code lab for implementation details https://codelabs.developers.google.com/codelabs/mobile-vision-ocr/index.html?index=..%2F..index#0 有关实施详情,请参阅此Google代码实验室https://codelabs.developers.google.com/codelabs/mobile-vision-ocr/index.html?index=..%2F..index#0

Especially creating OcrDetectorProcessor step. 特别是创建OcrDetectorProcessor步骤。

The text I was trying to recognize was MRZ. 我试图认识的文字是MRZ。 I contacted Firebase Support, they themselves performed tests and concluded that ML Kit API isn't capable of reading MRZ type text and that they might incorporate it in future. 我联系了Firebase支持,他们自己进行了测试并得出结论,ML Kit API无法读取MRZ类型的文本,并且他们可能会在将来合并它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM