flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [firebase_ml_vision] no recognizedLanguages on Android

Open rohrz4nge opened this issue 5 years ago • 3 comments

Bug report

Describe the bug When using TextScanner on Android the recognizedLanguages list is always empty. The same code works on iOS.

Steps to reproduce

Steps to reproduce the behavior:

  1. Clone the ml vision example project
  2. Add statements inside detector_painters.dart to print the recognized languages Screen Shot 2020-12-06 at 5 55 30 PM
  3. Load an image with text in PictureScanner
  4. See the empty list

Expected behavior

When using the same images, the recognizedLanguages list should be equivalent on Android and iOS.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
[✓] Flutter (Channel stable, 1.22.3, on Mac OS X 10.15.7 19H15, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
[✓] Android Studio (version 4.0)
[✓] Connected device (2 available)

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.11.0-213.1.beta
Flutter SDK 1.23.0-18.1.pre
firebase_ml_vision_example 0.0.0

dependencies:
- camera 0.5.8+7 [flutter]
- cupertino_icons 0.1.3
- firebase_core 0.4.2+2 [firebase_core_platform_interface flutter meta]
- firebase_ml_vision 0.9.10 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- image_picker 0.5.4+3 [flutter]

dev dependencies:
- e2e 0.2.4+4 [flutter flutter_test]
- flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypt
o fake_async matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]
- path 1.8.0-nullsafety.1
- path_provider 0.5.0+1 [flutter]
- pedantic 1.10.0-nullsafety.2
- test 1.16.0-nullsafety.5 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace strea
m_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core]

transitive dependencies:
- _fe_analyzer_shared 7.0.0 [meta]
- analyzer 0.39.17 [_fe_analyzer_shared args charcode cli_util collection convert crypto glob html meta package_config path pub_semver source_span watcher yaml]
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- cli_util 0.2.0 [path]
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- coverage 0.13.11 [args logging package_config path source_maps stack_trace vm_service]
- crypto 2.1.5 [collection convert typed_data]
- csslib 0.16.2 [source_span]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- file 6.0.0-nullsafety.2 [meta path]
- firebase_core_platform_interface 1.0.4 [flutter meta plugin_platform_interface quiver]
- fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file matcher meta path platform pub_semve
r source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver]
- glob 1.2.0 [async collection node_io path pedantic string_scanner]
- html 0.14.0+3 [csslib source_span]
- http 0.12.2 [http_parser path pedantic]
- http_multi_server 2.2.0 [async]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- io 0.3.4 [charcode meta path string_scanner]
- js 0.6.3-nullsafety.2
- json_rpc_2 2.2.2 [stack_trace stream_channel]
- logging 0.11.4
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.4
- mime 0.9.7
- node_interop 1.1.1 [js]
- node_io 1.1.1 [node_interop path]
- node_preamble 1.4.12
- package_config 1.9.3 [path charcode]
- platform 3.0.0-nullsafety.2
- plugin_platform_interface 1.0.3 [meta]
- pool 1.5.0-nullsafety.2 [async stack_trace]
- process 4.0.0-nullsafety.2 [file path platform]
- pub_semver 1.4.4 [collection]
- quiver 2.1.5 [matcher meta]
- shelf 0.7.9 [async collection http_parser path stack_trace stream_channel]
- shelf_packages_handler 2.0.0 [path shelf shelf_static]
- shelf_static 0.2.8 [convert http_parser mime path shelf]
- shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel]
- sky_engine 0.0.99
- source_map_stack_trace 2.1.0-nullsafety.3 [path stack_trace source_maps]
- source_maps 0.10.10-nullsafety.2 [source_span]
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.2 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- sync_http 0.2.0
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- test_core 0.3.12-nullsafety.5 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher
 test_api]
- typed_data 1.3.0-nullsafety.3 [collection]
- vector_math 2.1.0-nullsafety.3
- vm_service 4.2.0 [meta]
- vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel]
- watcher 0.9.7+15 [async path pedantic]
- web_socket_channel 1.1.0 [async crypto stream_channel]
- webdriver 2.1.2 [archive matcher path stack_trace sync_http]
- webkit_inspection_protocol 0.7.3 [logging]
- yaml 2.2.1 [charcode collection string_scanner source_span]

rohrz4nge avatar Dec 06 '20 17:12 rohrz4nge

Reproducible on the latest master 1.25.0-5.0.pre.91 with firebase_ml_vision: ^0.9.10 when scanning the same picture (screenshot of this).

api 'com.google.android.gms:play-services-vision:20.1.2'
api 'com.google.android.gms:play-services-vision-common:19.1.2'
flutter doctor -v
[√] Flutter (Channel master, 1.25.0-5.0.pre.91, on Microsoft Windows [Version 10.0.19041.630], locale et-EE)
    • Flutter version 1.25.0-5.0.pre.91 at C:\Development\flutter_master
    • Framework revision 7dade22f25 (20 hours ago), 2020-12-06 21:34:04 +0530
    • Engine revision 6491c7518f
    • Dart version 2.12.0 (build 2.12.0-120.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2020.3)
    • IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\203.5981.155
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (5 available)
    • SM G950F (mobile)           • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 arm (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)           • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.630]
    • Chrome (web)                • chrome             • web-javascript • Google Chrome 87.0.4280.88
    • Edge (web)                  • edge               • web-javascript • Microsoft Edge 87.0.664.47

• No issues found!

Android

I/flutter ( 7454): []
I/chatty  ( 7454): uid=10387(com.nevercode.triage) 1.ui identical 1 line
I/flutter ( 7454): []
I/flutter ( 7454): []
I/flutter ( 7454): []
I/chatty  ( 7454): uid=10387(com.nevercode.triage) 1.ui identical 223 lines
I/flutter ( 7454): []

iOS

flutter: [Instance of 'RecognizedLanguage']
flutter: [Instance of 'RecognizedLanguage']
flutter: []
flutter: []
flutter: [Instance of 'RecognizedLanguage']
flutter: [Instance of 'RecognizedLanguage']
flutter: []
flutter: [Instance of 'RecognizedLanguage']
flutter: [Instance of 'RecognizedLanguage']
flutter: []
flutter: []
flutter: [Instance of 'RecognizedLanguage']
flutter: [Instance of 'RecognizedLanguage']
flutter: []
flutter: [Instance of 'RecognizedLanguage']
flutter: [Instance of 'RecognizedLanguage']
...

markusaksli-nc avatar Dec 07 '20 12:12 markusaksli-nc

I can also reproduce this issue for on-device text recognition. iOS: languages are recognized (for block- and line- levels, not detected for element- level) Android: no languages are recognized (recognizedLanguage is empty on all levels)

bmvkrd avatar Jan 13 '21 21:01 bmvkrd

Hey, :wave:, the firebase_ml_vision package is now discontinued since its APIs have been deprecated and removed from the Android & iOS Firebase SDKs.

I'd recommend switching to the alternatives now;

  • for on-device vision APIs; switch to Google's standalone ML Kit library via google_ml_kit
  • for cloud vision APIs; the recommended approach now is to use Firebase Authentication and Functions, which gives you a managed, serverless gateway to the Google Cloud Vision APIs. For an example Functions project see the vision-annotate-images sample project. You'd deploy this project for example and then call the cloud function from your app with your image data to get the annotation result.

Apologies for any inconvenience here and best of luck switching over the the new APIs. firebase_ml_custom is not affected by this deprecation.

Thanks

Salakar avatar May 10 '21 14:05 Salakar