Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Working on Android 11 and 12 #285

Closed
arsallion313786 opened this issue Jun 25, 2022 · 16 comments
Closed

Not Working on Android 11 and 12 #285

arsallion313786 opened this issue Jun 25, 2022 · 16 comments
Labels
Image capture Issues related to image capturing using camera or image_picker plugins InputImage Issues related to InputImage

Comments

@arsallion313786
Copy link

I have added latest google ml kit version in our flutter app its working fine for Android 9 but for higher versions Android 11 and 12 not working even i tested google ml kit example app and same behaviour for Android 11 and 12. I also tried this for IOS and there its working fine. On Android 11 and developer all feature are not working properly.

If any one try google ml kit features for Android 11 and 12 then please share solution or even share their problem

@fbernaly
Copy link
Collaborator

@arsallion313786 : what do you mean with "not working"? which API are you using: face detection, barcode, text recognition, etc? I used a Pixel 4 with Android 12 to test our example app, and so far all the APIs are working. So, could you be more specific what is not working for you Android 12 testing device?
Also, thanks for trying Google's native app, if you are getting the same behavior in Google's native app, then you should open an issue there. We are just consuming and wrapping their APIs in this plugins, doing the same processing they have in their documentation. We won't be able to fix that, but them. If you find that we are consuming and exposing incorrectly their APIs then come and let us know, or contribute with a PR.

@arsallion313786
Copy link
Author

@fbernaly
Thanks to comment. I have Samsung A23 Testing device and i have tested Barcode and Text detection API its working fine on all iOS devices and on Android Devices which they have version upto 9 but same code not working for Android 11 and 12.
I really wonder if all things working fine for all iOS devices and also for Android 9 then why not for Android 11 and 12

@umangsh
Copy link

umangsh commented Jun 27, 2022

Possibly related, google_mlkit_barcode_scanning doesn't work for me on Pixel 3, Android 12. The camera switches on, but nothing happens when pointed at a barcode. Barcode detection works fine on iOS. Flutter logs:

I/Camera (20069): close
W/Camera (20069): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420
I/Camera (20069): startPreview
I/Camera (20069): CameraCaptureSession onConfigured
I/Camera (20069): Updating builder settings
D/Camera (20069): Updating builder with feature: ExposureLockFeature
D/Camera (20069): Updating builder with feature: ExposurePointFeature
I/Camera (20069): closeCaptureSession
D/Camera (20069): Updating builder with feature: ZoomLevelFeature
D/Camera (20069): Updating builder with feature: AutoFocusFeature
D/Camera (20069): Updating builder with feature: NoiseReductionFeature
I/Camera (20069): updateNoiseReduction | currentSetting: fast
D/Camera (20069): Updating builder with feature: FocusPointFeature
D/Camera (20069): Updating builder with feature: ResolutionFeature
D/Camera (20069): Updating builder with feature: SensorOrientationFeature
D/Camera (20069): Updating builder with feature: FlashFeature
D/Camera (20069): Updating builder with feature: ExposureOffsetFeature
D/Camera (20069): Updating builder with feature: FpsRangeFeature
I/Camera (20069): refreshPreviewCaptureSession
I/Camera (20069): refreshPreviewCaptureSession: captureSession not yet initialized, skipping preview capture session refresh.
I/Camera (20069): CameraCaptureSession onClosed
I/Camera (20069): startPreviewWithImageStream
I/Camera (20069): CameraCaptureSession onConfigured
I/Camera (20069): Updating builder settings
D/Camera (20069): Updating builder with feature: ExposureLockFeature
D/Camera (20069): Updating builder with feature: ExposurePointFeature
D/Camera (20069): Updating builder with feature: ZoomLevelFeature
D/Camera (20069): Updating builder with feature: AutoFocusFeature
D/Camera (20069): Updating builder with feature: NoiseReductionFeature
I/Camera (20069): updateNoiseReduction | currentSetting: fast
D/Camera (20069): Updating builder with feature: FocusPointFeature
D/Camera (20069): Updating builder with feature: ResolutionFeature
D/Camera (20069): Updating builder with feature: SensorOrientationFeature
D/Camera (20069): Updating builder with feature: FlashFeature
D/Camera (20069): Updating builder with feature: ExposureOffsetFeature
D/Camera (20069): Updating builder with feature: FpsRangeFeature
I/Camera (20069): refreshPreviewCaptureSession
W/System (20069): A resource failed to call release.
W/System (20069): A resource failed to call release.
D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning...
D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=DEFAULT, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, DEFAULT, 90bzNc) is already scheduled. Returning...
D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning...
D/TransportRuntime.SQLiteEventStore(20069): Storing event with priority=VERY_LOW, name=FIREBASE_ML_SDK for destination cct
D/TransportRuntime.JobInfoScheduler(20069): Upload for context TransportContext(cct, VERY_LOW, 90bzNc) is already scheduled. Returning...

@umangsh
Copy link

umangsh commented Jul 1, 2022

From the linked bug, there is likely an issue with some Android 12 devices (emulators are okay) and google_mlkit_barcode_scanning:

  1. Works on emulators - Pixel 3, Pixel5 with Android 12, Pixel 3 with Android 9.
  2. Works on device - lenovo Tab with Android 10.
  3. Works on Samsung Galaxy Tab S6 Lite, Android 12.
  4. Does NOT work on Pixel 3 and Pixel 5 with Android 12.
  5. Does NOT work on Nokia x20, with google services, Android version unknown.

@sorgfal
Copy link

sorgfal commented Jul 2, 2022

From the linked bug, there is likely an issue with some Android 12 devices (emulators are okay) and google_mlkit_barcode_scanning:

  1. Works on emulators - Pixel 3, Pixel5 with Android 12, Pixel 3 with Android 9.
  2. Works on device - lenovo Tab with Android 10.
  3. Works on Samsung Galaxy Tab S6 Lite, Android 12.
  4. Does NOT work on Pixel 3 and Pixel 5 with Android 12.
  5. Does NOT work on Nokia x20, with google services, Android version unknown.

nokia x20 android 12

@mahbubabbas
Copy link

Not working on Vivo Y33T having android 12

@ErrorCode-404
Copy link

I am using this plugin together with the camera plugin to create a barcode scanner. The imageSream on the CameraController delivers CameraImage's which will be used for barcode detection while using the mlkit BarcodeScanner.
On some devices like Pixel 6 everything works good and fast. But on the Pixel 5 the detection doesn't work at all.
I am holding the camera over the barcode but nothing happens.

But I changed something which made it work. Surprisingly it's the "ResolutionPreset" in the CameraController constructor.
First I set it to medium which works on the pixel 6 but not pixel 5. Then I changed it to high and after that it also works on the pixel 5.

Maybe there is some kind of correlation between the resolution of the images and the detector(s).

@rubenferreira97
Copy link

rubenferreira97 commented Jul 14, 2022

But I changed something which made it work. Surprisingly it's the "ResolutionPreset" in the CameraController constructor.
First I set it to medium which works on the pixel 6 but not pixel 5. Then I changed it to high and after that it also works on the pixel 5.

I can confirm that changing the ResolutionPreset results in different behavior. Setting ResolutionPreset to ResolutionPreset.max seems to work, but slows down the camera framerate. Maybe this bug have something to do with the camera package not finding the asked camera resolution and sending wrong metadata or MLKit can't process images with low resolution (setting a low ResolutionPreset).

I don't think this problem is Android Version related since I can reproduce this on Android 10 (Xiaomi Redmi 9S) using ResolutionPreset.medium.

@mahbubabbas
Copy link

mahbubabbas commented Jul 14, 2022 via email

@fbernaly
Copy link
Collaborator

Hi guys, sorry for the delay. Thanks for using our plugin. @bharat-biradar and I have been maintaining this plugin, but sometimes we cannot provide all the support you need. Both of us are busy with school, work and family. We created this plugin as an open source project. We do not have an ETA for this fix, too busy with so many things, but you are welcome to fork our repo, fix whatever is broken and sent the PR. We will review PRs as soon as possible and release a new version.

I think that @rubenferreira97 is right, during my initial testing I found issues with the camera plugin similar to whar @rubenferreira97 reported: issues when changing the resolution.

ML Kit has these guidelines for input image resolution: https://developers.google.com/ml-kit/vision/face-detection/ios#input-image-guidelines

Unfortunately, because most of us are using the camera plugin, some how the out of that plugin does not conform with what ML Kit expects as input image, and therefore our plugin is failing. Basically we are passing the native camera output to Flutter (with camera plugin), then we are sending it back using FlutterMethodChannel to the native layer to be processed by ML Kit, in all that process there is a big delay, also compressing and decompressing issues. A better approach would be something like @mahbubabbas did: capture the image in the native layer and send it directly to ML Kit for processing without passing for Flutter.

I would appreciate if someone takes the time to fork our repo and starts leading that effort. I think we are going to continue seeing this issues related to using camera plugin, until we refactor the plugin to process the camera directly in the native layer.

@Nemasio
Copy link

Nemasio commented Sep 22, 2022

Hey, im having the same issue as you all, on some Android devices face recognition is not working. I did get to make it work on a lot of previusly affected devices by seting the camera quality to "High", sacrificing some performance.
But still i have some devices affected. The list of the ones i know they are directly affected: Xiaomi Redmi 2201117TG, Motorola G71 G5.
I did a lot of development with this Google package, hope it gets fixed soon.

PD: I tryed @mahbubabbas package, and it works fine with this still affected devices. But the integration with my allready developed code would be painfull. For example, im getting a photo from the image stream, to use it after biometrics, without having to use the function "take photo" wich requieres the stream to stop and take a photo ( in wich time a hacker of biometrics could put a photo of the real user, to fake the biometrics). Also i dont have lavel detector, wich i use to detect if user has lenses on or photos wich can affect the biometrics process.

@Nemasio
Copy link

Nemasio commented Oct 31, 2022

Hello, i have a list of devices where the library is NOT working (Ranked from TOP to BOTTOM in amount of devices that have my app, and none of the users with this devices could do face detection.)

motorola, moto g(30) 553
motorola, moto g(9) power 547
motorola, moto g(9) play 545
motorola, moto g51 5G 538
motorola, moto g52 401
motorola, moto e(7) plus 396
samsung, SM-A235M 377
samsung, SM-G975F 157
motorola, motorola one hyper 139
motorola, moto g82 5G 124
lge, LM-X540 116
TCL, T671E 111
motorola, Moto G (5S) Plus 102
samsung, SM-A750G 100
samsung, SM-J701M 92
lge, LM-X525 77
motorola, motorola one 72
samsung, SM-G991B 69
samsung, SM-N975F 66
samsung, SM-J700M 62
lge, LM-X210 57
lge, LM-X430 57
lge, LM-X520 55

Still waiting on a fix for face detection, or for the camera library fix to start detecting faces. Anyone has any news about this ??

@ranulfo
Copy link

ranulfo commented Dec 21, 2022

Hello, i have a list of devices where the library is NOT working (Ranked from TOP to BOTTOM in amount of devices that have my app, and none of the users with this devices could do face detection.)

motorola, moto g(30) 553 motorola, moto g(9) power 547 motorola, moto g(9) play 545 motorola, moto g51 5G 538 motorola, moto g52 401 motorola, moto e(7) plus 396 samsung, SM-A235M 377 samsung, SM-G975F 157 motorola, motorola one hyper 139 motorola, moto g82 5G 124 lge, LM-X540 116 TCL, T671E 111 motorola, Moto G (5S) Plus 102 samsung, SM-A750G 100 samsung, SM-J701M 92 lge, LM-X525 77 motorola, motorola one 72 samsung, SM-G991B 69 samsung, SM-N975F 66 samsung, SM-J700M 62 lge, LM-X210 57 lge, LM-X430 57 lge, LM-X520 55

Still waiting on a fix for face detection, or for the camera library fix to start detecting faces. Anyone has any news about this ??

Hi,
I solved this problem using takePicture instead startImageStream when the device name match with this list.
I take the picture at intervals of 2 in 2 seconds and then i make InputImage with the simple code: var result = InputImage.fromFilePath(file.path); and then i call processImage passing the result.
This process is a bit slower and you might have to worry about deleting the images from the directory afterwards, but it was the only solution I found. I only tested it on Motorola Moto G 30.

@acoutts
Copy link
Contributor

acoutts commented Jan 11, 2023

This sounds related to my issue here: flutter/flutter#118350

@svonidze
Copy link

take a look at flutter/packages#3277, this helped in my case #287

@fbernaly
Copy link
Collaborator

Use NV21 for Android.
In this comment: #287 (comment)
Someone reported that the native apps are using that for MLKit and when doing the same in Flutter solved the issue for Android. That was merged in this PR #454. Update to the latest plugin version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Image capture Issues related to image capturing using camera or image_picker plugins InputImage Issues related to InputImage
Projects
None yet
Development

No branches or pull requests