capawesome-team / capacitor-mlkit

⚡️ ML Kit plugins for Capacitor. Supports Android and iOS.
https://capawesome.io/plugins/mlkit/
Apache License 2.0
139 stars 38 forks source link

bug: Scan QrCode doesn't work on Samsung A23 #140

Open JamesDAdams opened 5 months ago

JamesDAdams commented 5 months ago

Plugin(s)

Version

5.4.0

Platform(s)

Current behavior

With a Samsung A23 the scan doesn't work (Nothing append)

Expected behavior

qrcode scan work with the Samsung A23

Reproduction

https://github.com/capawesome-team/.capacitor-app

Steps to reproduce

  1. Try to scan a QRcode with a Samsung A23

Other information

My code :

  async scanCode() {
    await BarcodeScanner.requestPermissions();

    const data = await BarcodeScanner.isGoogleBarcodeScannerModuleAvailable();

    if (data.available) {
      const code = await this.startScanner();
      this.importerService.generateDossierFromQRCode(code);
    } else {
      try {
        await BarcodeScanner.installGoogleBarcodeScannerModule();
        const code = await this.startScanner();
        this.importerService.generateDossierFromQRCode(code);
      } catch (e) {
        await this.ui.alertSimple(
          "ERROR"
        );
      }

    }
  }

    async startScanner() {
    const { barcodes } = await BarcodeScanner.scan({
      formats: [BarcodeFormat.QrCode, BarcodeFormat.Ean13]
    });
    return barcodes;
  }

  async requestPermissions(): Promise<boolean> {
    const { camera } = await BarcodeScanner.requestPermissions();
    return camera === 'granted' || camera === 'limited';
  }

Capacitor doctor

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 5.7.4 @capacitor/core: 5.7.4 @capacitor/android: 5.7.4 @capacitor/ios: 5.7.4

Installed Dependencies:

@capacitor/ios: not installed @capacitor/cli: 5.6.0 @capacitor/core: 5.6.0 @capacitor/android: 5.6.0

[success] Android looking great! 👌

Before submitting

JamesDAdams commented 5 months ago

Someone have a same problem with the same phone with another plugin : https://github.com/juliansteenbakker/mobile_scanner/issues/698

JamesDAdams commented 5 months ago

After few test the scan work if the qrcode is not center Ex :

image

JamesDAdams commented 5 months ago

the getMaxZoomRatio doesn't work for my devices

Sending plugin error: {"save":false,"callbackId":"90822309","pluginId":"BarcodeScanner","methodName":"getMaxZoomRatio","success":false,"error":{"message":"There is no active scan session."}}

robingenz commented 5 months ago

Thank you for creating the bug report. Unfortunately, I don't have access to this device. Feel free to submit a PR.

JamesDAdams commented 5 months ago

Thank you for creating the bug report. Unfortunately, I don't have access to this device. Feel free to submit a PR.

There another probleme i have this error for all my phone : There is no active scan session.

Impossible to change the ratio

JamesDAdams commented 5 months ago

For example GetMaxZoomRatioResult work after the qrcode has been scanned...

robingenz commented 5 months ago

Please create a separate issue for that.

Webrow commented 2 months ago

We are running into this issue as well, looking at other threads it might have to do with a couple of things: 1, That phone uses android new image format NV21, 2, People report setting a custom resolution to the underlying controller solves the issue 3, ml-kit repo reports having done a pr which solves this issue.

I am willing to put some work into this, but it looks like this library is just a java wrapper on top of the ml-kit (I am not familliar with it), and the methods show do not have access to setting the resolution.

Steps would be to detect what kind of platform is being used, based on that use BGR888 (ios) or Yuv420/Nv21 (android). I have no background into imageprocessing except for my courses in uni, and I dont know how they are handled on android. If someone can get me some pointers, I am okay with walking the mile.

Ionic seems to have a new plugin as well (or Outsystems). It doesn't seem to be open (but I do see all collaborators are Ionic based). I don't know if they have the same issue yet.

Rdevc commented 2 months ago

After few test the scan work if the qrcode is not center Ex :

image

Do you get the impression that this is caused by the phone using the wrong camera? In the other issue you mentioned, there is talk about 4 cameras. I am not familiar with the code of this plugin, but I can imagine that the zoom level determines which camera is used, hence it seems like the QR code is not centered. What happens if you lower or increase the zoom ratio?

orl99 commented 4 weeks ago

is there any news about this issue?

sake12 commented 4 weeks ago

Probably won't be fixed because the author doesn't have that device, so he cannot reproduce the error. I just switched to the official plugin, works great, superfast, and you don't have to provide additional CSS and HTML to make it work.