flutter-ml / google_ml_kit_flutter

A flutter plugin that implements Google's standalone ML Kit
MIT License
953 stars 731 forks source link

[Text Recognition] Failed to do OCR while trying to start camera. - Android #91

Closed SebghatYusuf closed 3 years ago

SebghatYusuf commented 3 years ago

I'm using Text Detector and Barcode Detector, I'm able to run the app on several medium & high end devices, but when I'm trying to run on low end devices, when I click on button to open camera, it just stuck to load camera and I get the bottom error:

E/flutter (18569): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(TextDetectorError, com.google.mlkit.common.MlKitException: Waiting for the OCR optional module to be downloaded. Please wait., null, null)

E/flutter (18569): #0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:597
E/flutter (18569): #1      MethodChannel._invokeMethod

package:flutter/…/services/platform_channel.dart:158

E/flutter (18569): <asynchronous suspension>

E/flutter (18569): #2      TextDetector.processImage
package:google_ml_kit/…/vision/text_detector.dart:18

E/flutter (18569): <asynchronous suspension>

Any help would be highly appreciated :)

bharat-biradar commented 3 years ago

@SebghatYusuf Which version of the plugin are you using?

SebghatYusuf commented 3 years ago

@bharat-biradar version 0.6.0

wazini-john commented 3 years ago

@SebghatYusuf How did you implement the ability to download the models from google play ?

SebghatYusuf commented 3 years ago

@wazini-john I don't do anything, I'm just adding the package to my pubspec.yaml file and as described in Readme.md and just start using it. I don't know what other thing is necessary. can you please explain what is needed? before when I was using firebase_ml_vision I was adding the dependencies in AndroidManifest.xml and to app/build.gradle -> dependencies

bharat-biradar commented 3 years ago

@wazini-john I have added info regarding it in the readme's android usage section please go through it once.

bharat-biradar commented 3 years ago

@SebghatYusuf Did your issue resolve, I could not find any info on minimum device spec requirements in google's original documentation, I have added a question on StackOverflow hope someone answers it.

SebghatYusuf commented 3 years ago

@bharat-biradar No the issue still occurs, it's not resolved yet. Thanks for that, can you please share the StackOverflow link with me?

SebghatYusuf commented 3 years ago

@bharat-biradar I just fixed the issue, I just needed to add this

<meta-data android:name="com.google.mlkit.vision.DEPENDENCIES" android:value="ocr" /> to AndroidManifest.xml.

But I have a doubt, why it was working on high end devices?

bharat-biradar commented 3 years ago

@SebghatYusuf According to the log I think it did not actually fail but the model was being downloaded, see here PlatformException(TextDetectorError, com.google.mlkit.common.MlKitException: Waiting for the OCR optional module to be downloaded. Please wait., when you called it for the first time.

But when you added this <meta-data android:name="com.google.mlkit.vision.DEPENDENCIES" android:value="ocr" /> The model was downloaded automatically when the app was installed and hence this error did not occur. That's what I think atleast.

hesmnyn commented 3 years ago

just added the code you said but i still get the same issue :(((

do you know anything else to help me?

wazini-john commented 3 years ago

@bharat-biradar I read the documentation. Just trying to find out how to prevent bundling all together coz excluding models crashes the face detection functionalities.

bharat-biradar commented 3 years ago

@wazini-john Please don't exclude model's if it's crashing. The only way to prevent the bundling altogether is to split the whole plugin into individual API's which we can't afford right now. But if you still want to reduce app size, instead of excluding the whole models try excluding one model at a time, example models/fssd_100_8bit_v1.tflite and if not crashes it's fine otherwise you will have to keep it as it is.