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

bug: barcode EAN13 wrong scan #205

Closed
5 of 11 tasks
anthony-bernardo opened this issue Nov 8, 2024 · 1 comment
Closed
5 of 11 tasks

bug: barcode EAN13 wrong scan #205

anthony-bernardo opened this issue Nov 8, 2024 · 1 comment

Comments

@anthony-bernardo
Copy link

anthony-bernardo commented Nov 8, 2024

Plugin(s)

  • Barcode Scanning
  • Face Detection
  • Face Mesh Detection
  • Selfie Segmentation
  • Translation

Version

6.1.0

Platform(s)

  • Android
  • iOS
  • Web

Current behavior

When I scan some ean code, I get wrong result

4a642a1f-b8b0-4999-96b3-61b8b4136015

Example this one is giving me 2100455101009 instead of 2100455010109

Expected behavior

Expected the have the right result (2100455010109)

Reproduction

none

Steps to reproduce

import { BarcodeScanner, BarcodeFormat } from "@capacitor-mlkit/barcode-scanning";

export const startScan = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] startScan");
    return;
  }

  // The camera is visible behind the WebView, so that you can customize the UI in the WebView.
  // However, this means that you have to hide all elements that should not be visible.
  // You can find an example in our demo repository.
  // In this case we set a class `barcode-scanner-active`, which then contains certain CSS rules for our app.
  document.querySelector("body")?.classList.add("barcode-scanner-active");

  // Add the `barcodeScanned` listener
  const listener = await BarcodeScanner.addListener("barcodeScanned", async (result) => {
    console.log(result.barcode);
  });

  // Start the barcode scanner
  await BarcodeScanner.startScan();
};

export const stopScan = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return;
  }

  // Make all elements in the WebView visible again
  document.querySelector("body")?.classList.remove("barcode-scanner-active");

  // Remove all listeners
  await BarcodeScanner.removeAllListeners();

  // Stop the barcode scanner
  await BarcodeScanner.stopScan();
};

export const scanSingleBarcode = async (formats: BarcodeFormat[]) => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] scanSingleBarcode !!!!!!!!!");
    return new Promise((resolve) => {
      // resolve("https://www.ceres24.app/w8lgYJXUgFDDfAGi6R9u/u66pPRkRv8IcA4vtZIcJ");
      resolve({
        rawValue: "2100455101009",
      });
    });
  }

  return new Promise(async (resolve) => {
    const el: HTMLElement | null = document.querySelector("#scan-page");
    el?.style.setProperty("--background", "transparent");

    document.querySelector("body")?.classList.add("barcode-scanner-active");

    const listener = await BarcodeScanner.addListener("barcodeScanned", async (result) => {
      await listener.remove();
      document.querySelector("body")?.classList.remove("barcode-scanner-active");
      await BarcodeScanner.stopScan();
      resolve(result.barcode);
    });

    await BarcodeScanner.startScan({ formats: formats });
  });
};

export const scan = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] scanSingleBarcode");
    return new Promise((resolve) => {
      resolve("https://www.ceres24.app/w8lgYJXUgFDDfAGi6R9u/u66pPRkRv8IcA4vtZIcJ");
    });
  }

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

export const isSupported = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return true;
  }

  const { supported } = await BarcodeScanner.isSupported();
  return supported;
};

export const enableTorch = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return;
  }

  await BarcodeScanner.enableTorch();
};

export const disableTorch = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return;
  }

  await BarcodeScanner.disableTorch();
};

export const toggleTorch = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return;
  }
  await BarcodeScanner.toggleTorch();
};

export const isTorchEnabled = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] stopScan");
    return false;
  }
  const { enabled } = await BarcodeScanner.isTorchEnabled();
  return enabled;
};

export const isTorchAvailable = async () => {
  const { available } = await BarcodeScanner.isTorchAvailable();
  return available;
};

export const setZoomRatio = async () => {
  await BarcodeScanner.setZoomRatio({ zoomRatio: 0.5 });
};

export const getZoomRatio = async () => {
  const { zoomRatio } = await BarcodeScanner.getZoomRatio();
  return zoomRatio;
};

export const getMinZoomRatio = async () => {
  const { zoomRatio } = await BarcodeScanner.getMinZoomRatio();
  return zoomRatio;
};

export const getMaxZoomRatio = async () => {
  const { zoomRatio } = await BarcodeScanner.getMaxZoomRatio();
  return zoomRatio;
};

export const openSettings = async () => {
  await BarcodeScanner.openSettings();
};

export const isGoogleBarcodeScannerModuleAvailable = async () => {
  const { available } = await BarcodeScanner.isGoogleBarcodeScannerModuleAvailable();
  return available;
};

export const installGoogleBarcodeScannerModule = async () => {
  await BarcodeScanner.installGoogleBarcodeScannerModule();
};

export const checkPermissions = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] scanSingleBarcode");
    return new Promise((resolve) => {
      resolve("granted");
    });
  }

  const { camera } = await BarcodeScanner.checkPermissions();
  return camera;
};

export const requestPermissions = async () => {
  if (import.meta.env.VITE_APP_MOCK_CAPACITOR_PLUGINS) {
    console.log("[MOCK] scanSingleBarcode");
    return new Promise((resolve) => {
      resolve("granted");
    });
  }

  const { camera } = await BarcodeScanner.requestPermissions();
  return camera;
};

Other information

No response

Capacitor doctor

[warn] The bundledWebRuntime configuration option has been deprecated. Can be safely deleted.
💊 Capacitor Doctor 💊

Latest Dependencies:

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

Installed Dependencies:

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

[success] iOS looking great! 👌
[success] Android looking great! 👌

Before submitting

  • I have read and followed the bug report guidelines.
  • I have attached links to possibly related issues and discussions.
  • I understand that incomplete issues (e.g. without reproduction) are closed.
@anthony-bernardo anthony-bernardo added bug/fix Something isn't working needs: triage labels Nov 8, 2024
@anthony-bernardo anthony-bernardo changed the title bug: bug: barcode EAN13 wrong scan Nov 8, 2024
@robingenz
Copy link
Member

Hi @anthony-bernardo, thank you for your issue. The ML Kit library is responsible for analyzing the scanned barcodes. This plugin is only a wrapper and therefore has no effect on the result. For this reason, I am closing the issue.

@robingenz robingenz closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants