简体   繁体   English

Firebase ML 套件无法准确识别语言(英语或其他)

[英]Firebase ML kit does not recognize the language accurately (English or other)

I am developing a text recognizer app for android using firebase ML Kit.我正在使用 firebase ML Kit 为 android 开发文本识别器应用程序。 The issue when I capture the text image is not getting the actual result of the image why??.我捕获文本图像时的问题没有得到图像的实际结果,为什么?。 I think my app does not identify the language well.我认为我的应用程序不能很好地识别语言。 How can I solve this issue?我该如何解决这个问题?

#I am new to android Pls help me in this regard #我是android新手请在这方面帮助我

Example例子相机拍摄的图像

捕获图像的结果

Dependency I have used我用过的依赖

implementation 'com.google.firebase:firebase-ml-vision:20.0.0'

Recognize Text & Process Text code识别文本和处理文本代码

/**
 * This method is used to extract the text from the image
 * @param image
 */
private void recognizeText(FirebaseVisionImage image){
    FirebaseVisionTextRecognizer detector = FirebaseVision.getInstance()
            .getOnDeviceTextRecognizer();
    detector.processImage(image)
            .addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
                @Override
                public void onSuccess(FirebaseVisionText firebaseVisionText) {
                    processText(firebaseVisionText);
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    e.printStackTrace();
                    Toast.makeText(getActivity(), "No text found", Toast.LENGTH_SHORT).show();
                }
            });
}

/**
 * This method is used to process the text and send the result (text) to ResultLayout fragment
 * @param firebaseVisionText
 */
private void processText(FirebaseVisionText firebaseVisionText) {
    if(firebaseVisionText.getTextBlocks().isEmpty()){
        Toast.makeText(getActivity(), "No text found or Text may not be clear", Toast.LENGTH_LONG).show();
    }
    else {
        String text = "";
        for (FirebaseVisionText.TextBlock block : firebaseVisionText.getTextBlocks()){
            text = text + block.getText() + " ";
        }

        String tag = ((MainActivity)getActivity()).getTag_ResultLayout();
        ResultLayout fragment = (ResultLayout)getActivity().getSupportFragmentManager()
                .findFragmentByTag(tag);
        fragment.setResult(text);
        ((MainActivity)getActivity()).openResultLayout();
    }

I am ready to provide more information in this regard我准备提供这方面的更多信息

Could you share your AndroidManifest.xml?你能分享你的 AndroidManifest.xml 吗?

If you want to achieve better results, you can try to use multiple models like this:如果你想获得更好的结果,你可以尝试使用多个模型,如下所示:

  <application ...>
      ...
      <meta-data
          android:name="com.google.firebase.ml.vision.DEPENDENCIES"
          android:value="ocr" />
      <!-- To use multiple models: android:value="ocr,model2,model3" -->
  </application>

More info on this can be found in the official documentation here: https://firebase.google.com/docs/ml-kit/android/recognize-text更多信息可以在官方文档中找到: https : //firebase.google.com/docs/ml-kit/android/recognize-text

we made some changes to Firebase ML Kit for Firebase to better distinguish the on-device APIs from cloud based APIs.我们对 Firebase 的 Firebase ML Kit 进行了一些更改,以更好地区分设备上的 API 和基于云的 API。 "ML Kit"(without firebase branding), contains all the on-device APIs. “ML Kit”(不带 firebase 品牌),包含所有设备上的 API。 Here's the migration guide from firebase mlkit to mlkit.这是从 firebase mlkit 到 mlkit 的迁移指南。

This issue might be resulted in a misformatted image.此问题可能会导致图像格式错误。 Could you try to refer to the sample here for constructing a InputImage from different sources?您可以尝试参考此处的示例构建来自不同来源的 InputImage 吗?

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

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