简体   繁体   English

谷歌文本识别错误 Android Studio

[英]Google Text Recognition Error Android Studio

I am developing an app in which I am implementing google text recognition.我正在开发一个应用程序,我在其中实现谷歌文本识别。 This is the link that I am following: https://developers.google.com/ml-kit/vision/text-recognition/android这是我关注的链接: https://developers.google.com/ml-kit/vision/text-recognition/android

I have done everything described there but still I am getting error.我已经完成了那里描述的所有事情,但仍然出现错误。

This is what I have in my gradle file:这就是我的 gradle 文件中的内容:

implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.0'

I have these lines too in my manifest file:我的清单文件中也有这些行:

<uses-permission android:name="android.permission.INTERNET"/>

<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version"/>
<meta-data
    android:name="com.google.mlkit.vision.DEPENDENCIES"
    android:value="ocr" />

I am performing a click on a button OCR and then I am calling below lines of code:我正在单击一个按钮OCR ,然后我在下面的代码行中调用:

InputImage inputImage = InputImage.fromBitmap(bitmap, 0);
            TextRecognition.getClient().process(inputImage).addOnSuccessListener(new OnSuccessListener<Text>() {
                @Override
                public void onSuccess(Text text) {
                    string = text.getText();
                    success = true;
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    e.printStackTrace();
                    success = false;
                }
            });

Error is thrown as soon as I Click on OCR button.一旦我单击OCR按钮,就会引发错误。 Following is the stack trace:以下是堆栈跟踪:

W/DynamiteModule: Local module descriptor class for com.google.android.gms.vision.dynamite.ocr not found.
E/LibraryVersion: Failed to get app version for libraryName: text-recognition
I/DynamiteModule: Considering local module com.google.android.gms.vision.dynamite.ocr:0 and remote module com.google.android.gms.vision.dynamite.ocr:0
D/TextNativeHandle: Cannot load feature, fall back to load dynamite module.
W/scanner.camsca: Unsupported class loader
W/scanner.camsca: Skipping duplicate class check due to unsupported classloader
I/DynamiteModule: Considering local module com.google.android.gms.vision.ocr:0 and remote module com.google.android.gms.vision.ocr:1
    Selected remote version of com.google.android.gms.vision.ocr, version >= 1
V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
I/DynamiteLoaderV2: [71] VisionOcr.optional
W/scanner.camsca: Unsupported class loader
I/native: start_ocr_856638336_langid.cc:33 StartOcr with label: latin_script_gmvapi_android
    jni_helper.cc:115 Loading model config /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/semanticlift_rpn_lstm_engine_tfmini.bincfg
I/native: region_proposal_text_detector.cc:1976 Compute manager Max in flight region detector: 1
    common_util.h:39 Removing Thread Pool: ocr_region
    tensor_detector_client.cc:1643 Compute manager Max in flight detector: 1
I/native: common_util.h:35 Resizing Thread Pool: ocr_det to 4
I/native: tfmini_model_interface.cc:124 Loaded weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_rpn_detector_space_to_depth_gray_quantized_v2_model.data
    timer.cc:71 PhotoOcrEngine::Init (detector): 3.72583 ms (elapsed)
    assist_recognizer.cc:94 Initializing nugget matcher with /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/nugget_stats_1.0.dat
I/native: timer.cc:71 PhotoOcrEngine::Init (assist recognizer): 0.262136 ms (elapsed)
I/native: timer.cc:71 LanguageIdMutator: 4.42141 ms (elapsed)
    timer.cc:71 BeamSearch::Init (mutator): 4.58203 ms (elapsed)
I/native: common_util.h:35 Resizing Thread Pool: ocr_segm to 4
I/native: tfmini_model_interface.cc:102 Loaded fp16 weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_latin_conv_model.data_fp16
I/native: tfmini_model_interface.cc:102 Loaded fp16 weights from /data/user/0/com.scanner.camscan/cache/vision/ocr/data/models/tfmini_latin_lstm_model.data_fp16
    timer.cc:71 PhotoOcrEngine::Init (recognizer): 8.83693 ms (elapsed)
    timer.cc:71 Init: 13.0749 ms (elapsed)
I/native: start_ocr_856638336_langid.cc:42 StartOcr success

How can I rectify this error.我该如何纠正这个错误。 Thank you谢谢

I have faced a similar problem before.我以前也遇到过类似的问题。

These are not actual errors.这些不是实际错误。 They are just warnings and messages.它们只是警告和信息。 You can ignore them.你可以忽略它们。 What I guess is, you are putting true in the boolean variable success on onSuccess and false on onFailure and performing further actions based on its value.我猜是,您在boolean变量中输入 true onSuccess 和 false onFailure 并根据其值执行进一步的操作。

Just directly call further methods from onSuccess after string = text.getText();只需在 string = text.getText(); 之后直接从 onSuccess 调用其他方法;

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

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