Google Text Recognition Error Android Studio

Viewed 1108

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

I have done everything described there but still I am getting error.

This is what I have in my gradle file:

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:

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. 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

1 Answers

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.

Just directly call further methods from onSuccess after string = text.getText();

Related