openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
791 stars 272 forks source link

Upgrade the barcode scan to flutter 3.7 #3712

Closed monsieurtanuki closed 1 year ago

monsieurtanuki commented 1 year ago

What

Steps to reproduce the behavior

  1. Use the latest version of flutter.
  2. Run the app in debug mode
  3. The barcode scan does not work

Expected behavior

The barcode scan is supposed to work.

Why

The barcode scan is a key feature of Smoothie.

Additional context

Icing on the cake would be to refactor the barcode scan:

monsieurtanuki commented 1 year ago

@MKCOOL142 (OnePlus 7Pro), @teolemon (Pixel 6), @thestarsahil (Redmi Note 8 pro), @natrius (Xiaomi Mi 9 with Android 10), @M123-dev (Samsung galaxy s21), @raphael0202 (Oneplus 7T), @chk1 (Sony Xperia 10 IV), @monsieurtanuki (Samsung Galaxy Core Prime SM-G360F), @CharlesNepote (???), @g123k (ZFlip3), @stephanegigandet (Samsung Galaxy S8)

Guys, the current develop version of Smoothie now includes the "new" barcode scanner. Please test it as much as possible, in real life conditions. If something strange happens it's better to know asap so we can fix it. If you don't know how to install the develop version of the app, I don't either, but I guess @M123-dev does know.

Mattis142 commented 1 year ago

@monsieurtanuki i am confused on where to select which of the two (Zxing MLkit) to use for scanning, I found nothing in the settings mby I overlooked it

thestarsahil commented 1 year ago

@MKCOOL142 (OnePlus 7Pro), @teolemon (Pixel 6), @thestarsahil (Redmi Note 8 pro), @natrius (Xiaomi Mi 9 with Android 10), @M123-dev (Samsung galaxy s21), @raphael0202 (Oneplus 7T), @chk1 (Sony Xperia 10 IV), @monsieurtanuki (Samsung Galaxy Core Prime SM-G360F), @CharlesNepote (???), @g123k (ZFlip3), @stephanegigandet (Samsung Galaxy S8)

Guys, the current develop version of Smoothie now includes the "new" barcode scanner. Please test it as much as possible, in real life conditions. If something strange happens it's better to know asap so we can fix it. If you don't know how to install the develop version of the app, I don't either, but I guess @M123-dev does know.

Still Facing the same Autofocus problem

monsieurtanuki commented 1 year ago

@MKCOOL142 @thestarsahil @natrius Be sure to use the latest develop version - well, 4.6.0 is the latest published version.

If you're familiar with flutter, you can

I'm currently trying to create an apk; I'll keep you posted.

thestarsahil commented 1 year ago

@MKCOOL142 @thestarsahil @natrius Be sure to use the latest develop version - well, 4.6.0 is the latest published version.

If you're familiar with flutter, you can

  • flutter upgrade # should be something like flutter 3.7 / dart 2.19
  • get the latest smooth_app code
  • cd smooth-app/packages/smooth_app
  • flutter run -t lib/entrypoints/android/main_google_play.dart # for mlkit (to be deployed in almost all play store)
  • flutter run -t lib/entrypoints/android/main_fdroid.dart # for zxing (to be deployed only on FDroid)

I'm currently trying to create an apk; I'll keep you posted.

Thanks for the update men

monsieurtanuki commented 1 year ago

@thestarsahil Do you mean it finally works?

I'm currently trying to create an apk; I'll keep you posted.

Unfortunately I don't seem to be able to create that stupid apk. There are tons of thing I ignore about compiling - and I intend to keep it that way.

M123-dev commented 1 year ago

(Re-opening for the discussion in here)

Here a build apk ready to test, not for looks but for functionality. You can now switch the scanning engine (mlkit and zxing) in the dev settings (how to enter it)

https://drive.google.com/file/d/1R2b_rbQuq9Lv-vGErU-8xdvmumQYwhcz/view?usp=sharing

Mattis142 commented 1 year ago

mhhh so I did some testing with ML Kit and it is more prone to scanning incorrectly (these screenshots are both from the same bar code) Screenshot_20230318-130019_SystemUI Screenshot_20230318-130049_OpenFoodFacts

thestarsahil commented 1 year ago

@thestarsahil Do you mean it finally works?

I'm currently trying to create an apk; I'll keep you posted.

Unfortunately I don't seem to be able to create that stupid apk. There are tons of thing I ignore about compiling - and I intend to keep it that way.

Not working properly Have some time to update

monsieurtanuki commented 1 year ago

@MKCOOL142 Possible reasons/fixes:

monsieurtanuki commented 1 year ago

Not working properly Have some time to update

@thestarsahil Could you please be a little more specific about what works and what does not work, and with mlkit and zxing?

thestarsahil commented 1 year ago

Not working properly Have some time to update

@thestarsahil Could you please be a little more specific about what works and what does not work, and with mlkit and zxing?

Actually, When we try to scan the barcode the scanner couldn't recognize that information from the product So Update on the camera feature! That Camera Focusing focuses on the object barcode

chk1 commented 1 year ago

(Re-opening for the discussion in here)

Here a build apk ready to test, not for looks but for functionality. You can now switch the scanning engine (mlkit and zxing) in the dev settings (how to enter it)

https://drive.google.com/file/d/1R2b_rbQuq9Lv-vGErU-8xdvmumQYwhcz/view?usp=sharing

Test on Sony Xperia 10 IV:

MLKIT:

Zxing:

monsieurtanuki commented 1 year ago

Thank you @chk1 for your positive feedback! About the red snackbar, it's being dealt with in #3782 #3787. The only problem seems to be the initial non-display of the scanner after onboarding: I'll have a look at it again.

monsieurtanuki commented 1 year ago

@chk1 Could not reproduce the "no scanner after onboarding" bug with the latest code, with mlkit as default. Perhaps it's a side effect of the new (and temporary) mlkit/zxing test switch. I'll keep that bug in mind, hoping (?) I will reproduce it.

raphael0202 commented 1 year ago

I just installed the new version (4.6.0) using internal release on my cellphone (OnePlus 7T), it works really well using MLKit, scanning is superfast, good job! :tada:

monsieurtanuki commented 1 year ago

@raphael0202 Sounds good but unfortunately there's a possible confusion with versions, so please test with https://drive.google.com/file/d/1R2b_rbQuq9Lv-vGErU-8xdvmumQYwhcz/view?usp=sharing

juliansteenbakker commented 1 year ago

Hi all, as the developer of the mobile_scanner package i am happy to help with any issues regarding the package.

A quick note about some people having trouble getting the correct barcode from a scan: The MLKit framework decides which resolution is used for an image to be analyzed, and i have found out that this can be to low on some devices.

I'm currently trying to find a solution by using some kind of 'quality presets', so we can improve scan accuracy on all devices.

monsieurtanuki commented 1 year ago

I'm currently trying to find a solution by using some kind of 'quality presets', so we can improve scan accuracy on all devices.

Thank you @juliansteenbakker! If you could make it optional we'll have a better assessment of the actual impact of that fine-tuning.

monsieurtanuki commented 1 year ago

This issue is closed now: we do have 2 barcode scanners (mlkit and zxing) working on flutter 3.7. Changes and improvements can be dealt with in different issues.