Closed ruippoliveira closed 3 years ago
Hi ruippoliveira,
To help use debug this, could you help provide a bit more information.
Thanks
I have the same issue on a OnePlus 7T Pro with Oxygen OS 10.0.9.HD01BA Other features working fine with CameraX.
LivePreviewActivity ![Screenshot_20201021-104119](https://user-images.githubusercontent.com/9072378/96697610-65d8fa80-138c-11eb-9014-60545b8058cc.jpg) CameraXLivePreviewActivity ![Screenshot_20201021-103923](https://user-images.githubusercontent.com/9072378/96697628-68d3eb00-138c-11eb-8b5d-5f799ed63296.jpg)
Hi Steve,
Samsung SM-T500 , Android 10, Camera X
Samsung SM-T500 , Android 10, Live Preview
Samsung SM-T585, Android 8, Camera X
Hi mikkelvp and ruippoliveira,
With the images you provided, I cannot reproduce the issue.
We still need more information to debug this:
I also looped in more teammates to help take a look at this issue.
Thanks.
If possible, could you help attach a bug report as well? https://developer.android.com/studio/debug/bug-report
Also, can you try using same resolution in LivePreviewActivity and CameraXLivePreviewActivity, and then compare? It can be set from the Settings page (gear icon at the right top corner)
Changing resolution does not change output.
Hi steven,
Thanks.
Hi zhouyiself,
The app never crash. It simply doesn't return any barcode information. I changed the resolutions and the problem persists.
Thanks
Hi all,
We got some clue and keep investigating on it. Will keep you posted.
Thanks!
Same issue after libraries update. Tried on OnePlus 6T / Android 10
Is working with:
implementation "androidx.camera:camera-core:1.0.0-beta07"
implementation "androidx.camera:camera-camera2:1.0.0-beta07"
implementation "androidx.camera:camera-view:1.0.0-alpha14"
implementation "androidx.camera:camera-extensions:1.0.0-alpha14"
implementation "androidx.camera:camera-lifecycle:1.0.0-beta07"
Is not working with:
implementation "androidx.camera:camera-core:1.0.0-beta11"
implementation "androidx.camera:camera-camera2:1.0.0-beta11"
implementation "androidx.camera:camera-view:1.0.0-alpha18"
implementation "androidx.camera:camera-extensions:1.0.0-alpha18"
implementation "androidx.camera:camera-lifecycle:1.0.0-beta11"
I'm also facing the same issue.
As for workaround. I'm converting ImageProxy to bitmap, then passing it to the detector.
We are facing this issue in our app as well. Confirmed devices from our user reports:
The last working cameraX version is 1.0.0-beta-07,
using a newer version does not produce barcode results for the mentioned devices. We have a One Plus 6 where we can reproduce the issue, let me know if we can support debugging in any way.
As for workaround. I'm converting ImageProxy to bitmap, then passing it to the detector.
@callmemaxi Could you share the details of how you are creating the bitmap? I tried your workaround by creating a Bitmap as described here but still don't get any results.
Hi @looploooop,
I'm creating the bitmap using getBitmap(ImageProxy image)
method from mlkit samples.
Then converting the bitmap to InputImage
using
val image = InputImage.fromBitmap(bitmap!!, 0)
Can confirm this issue, happening on my OnePlus 7T Pro (Android 10). I was going crazy trying to understand why it was not working! Using the lib versions suggested by @omarmiatello solved it, barcode scanning is now working.
Hi, BarcodeScanning with CameraX input may not work on some devices with the latest CameraX library. You can use an earlier version(pre camera-camera2:1.0.0-beta08) of camera-camera2 to bypass this issue. We will soon publish this in the Known issue session of our dev site as well. The fix for this issue will be shipped with the next mlkit barcode sdk release in Mid Dec 2020.
@cs-googler do you know if the fix was already released? I am trying latest 1.0.0-rc01 and latest com.google.mlkit:barcode-scanning:16.1.0, which is not working and there isn't any update regarding this issue on the https://developers.google.com/ml-kit/known-issues Thank you. I believe, that we should re-open this issue until fixed?
@cs-googler is there any update? I don't think this issue is resolved.
@polivmi1 the issue was solved for me when I update barcode scanning to version "16.1.0"
@ruippoliveira I have tried with that and with 16.1.1, but after the update I wasn't able to scan: https://i.pinimg.com/originals/25/1d/93/251d93a54dc555a11e2971b23db3fe74.jpg Before with Camera 1.0 instead of CameraX it worked. With some other barcodes I have no problem even after upgrade.
@polivmi1 Could you help to check whether the images returned by CameraX ImageAnalysis has problem or not? You can use YuvToRgbConverter.kt to convert the image and save it as Bitmap. That possibly can help us to clarify the issue happened in CameraX side or the afterward bar-code analysis. Could you please also provide which resolution was run okay with Camera1 and which resolution was run failed with CameraX? If the resolutions are different, you might also try to interchange the resolutions to know whether this issue only happens on specific resolution on the device.
@CharcoalChen Thanks! With Camera 1 I used the google default sample CameraSource, which has preview resolution of 1280x960. With CameraX using the default FILL_CENTER, the default 640x480. I am not able to set resolution on the LifecycleCameraController to check different and will have to rewrite the code to use the previous classes which allow it. Is that still being implemented? Related article https://dev-victor-cold.medium.com/wow-this-is-really-what-i-was-missing-in-camerax-f618804daedd The saved image looks fine (is rotated, but I do rotate it based on imageInfo before processing).
I can confirm that using the older API that allows setting camera target resolution and setting it to the same as used with Camera 1 works. I think that the default resolution with LifecycleCameraController should be fixed or allowed custom, because otherwise the barcodes won't be recognized.
@polivmi1 Thanks for providing the information. As you mentioned in the previous two comments, the saved image looks fine, therefore, the image provided by LifecycleCameraController's ImageAnalysis should have no problem. But the barcode inside it can't be recognized. This part of issue might still need to be clarified in mlkit side.
About the article you mentioned above, there has been a response and also a doc CameraX: Learn how to use CameraController for it. LifecycleCameraController is a high-level, all-in-one API that provides a way to easily access and manipulate core camera features. But not all settings API are included. Otherwise, it might make the API become complicated. I guess if the bar code inside the 640x480 image can be recognized successfully, then, the LifecycleCameraController's resolution setting might not be a problem for your application any more. If you still need the target resolution setting API to be included in LifecycleCameraController, please submit a feature request on here. Thanks.
@polivmi1 this might be a different issue as we have many developers confirmed that this issue was solved with the latest barcode scanning sdk. Could you provide more details for MLKit to fix your specific issue?
If there is a bug/something we can do better in ML Kit, we will need to reproduce your issue on our side in order to fix it for you.
@cs-googler
Thanks! @polivmi1 From your description, it seems to be a cameraX not being flexible enough issue to me. For Barcode scanning and other ML vision features, we do require resolution number for the image to be recognized. Check the general guidance here. I will try to file this as an internal feature request to the camerax team.
@cs-googler Why not a public issue so we can follow it instead?
https://github.com/orlandev/qr-scanner-module
In this module I use CameraX and MlKit to read the Qr code and use them in the applications I work on. Until version 9 of Android it works correctly but from version 10 it starts to fail.
W/System.err: java.io.IOException: There is no back-facing camera. 2022-05-27 17:14:35.612 8666-8666/com.ondev.qrscanner W/System.err: at com.ondev.qrscannermodule.camera.CameraSource.createCamera(CameraSource.kt:176) 2022-05-27 17:14:35.612 8666-8666/com.ondev.qrscanner W/System.err: at com.ondev.qrscannermodule.camera.CameraSource.start$qrscanner_debug(CameraSource.kt:92) 2022-05-27 17:14:35.612 8666-8666/com.ondev.qrscanner W/System.err: at com.ondev.qrscannermodule.camera.CameraSourcePreview.startIfReady(CameraSourcePreview.kt:67) 2022-05-27 17:14:35.612 8666-8666/com.ondev.qrscanner W/System.err: at com.ondev.qrscannermodule.camera.CameraSourcePreview.access$startIfReady(CameraSourcePreview.kt:32) 2022-05-27 17:14:35.612 8666-8666/com.ondev.qrscanner W/System.err: at com.ondev.qrscannermodule.camera.CameraSourcePreview$SurfaceCallback.surfaceCreated(CameraSourcePreview.kt:133)
I'm trying tu use this demo do test the Barcode Scanning on a Samsung Tablet with Android 10. The app read the QrCode at LivePreviewActivity, but if i chose the CameraX option the app don't return anything. I tested the same code on a Samsung tablet with Android 8 and this bug don't happens.
My log is filled with:
Accessing hidden method Lsun/misc/Unsafe;->putInt(Ljava/lang/Object;JI)V (greylist, linking, allowed)