googlesamples / mlkit

A collection of sample apps to demonstrate how to use Google's ML Kit APIs on Android and iOS
Apache License 2.0
3.5k stars 2.92k forks source link

[BarcodeScanner] CameraX poor performance vs Camera1 #425

Open garciacastano09 opened 2 years ago

garciacastano09 commented 2 years ago

Hi all,

First, thank you for the great sample app, it really accelerates learning.

I was running the sample app with the barcode scanner, and I noticed that the LivePreviewActivity has a much better performance than the CameraXLivePreviewActivity. I'm interested on implementing a similar barcode scanning approach, and I'm concerned about using the CameraX library, given the poor performance. Here are a couple screenshots from a Samsung Galaxy S8 running both activities against the same image.

What's the reason behind the performance difference? Is it a bug in the sample app or is it a performance gap between Camera1 and CameraX libraries?

Thank you, Jorge

zhouyiself commented 2 years ago

Thanks for the feedback!

Which barcode scanning dependency version you're testing (com.google.mlkit:barcode-scanning:17.0.1 ?)?

I tested them locally and the performance looks similar. (resolutions are a little bit different than yours though due to the device capability, but it shouldn't mater much)

LivePreviewActivity 3stvZpXiEBRjwvx CameraXLivePreviewActivity

5943Ad4SBCVZzjT

garciacastano09 commented 2 years ago

Yes, I'm using com.google.mlkit:barcode-scanning:17.0.1, I didn't change any dependency from the master branch. Leaving here some data on the OS I have in the device.

Screenshot_20220115-110541_Settings

AlexTrotsenko commented 2 years ago

I have tested the sample app on my Pixel 5 using the QR codes which I have found in the internet (http://qrcode.meetheed.com/qrcode_examples.php)

Unfortunately I have noticed slight, but constant performance difference between Camara1 and CamaraX api as well. https://photos.app.goo.gl/Y4XnPyi9w32psBtm8

peerless2012 commented 2 years ago

I have the same issue with [Vision Module].

I run the vision demo on xiaomi CC 9E soc: Qualcomm snapdragon 665

LivePreviewActivity: image

CameraXLivewPreviewActivity: image

So what's wrong with CameraX?

dreamchaser96 commented 2 years ago

Have anyone figured out what was wrong with CameraX setup?

0xsimulacra commented 1 year ago

Any news on this ? I'm getting consistently lower performance on CameraX vs Camera1 on barcode scanning and text recognition.