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

[mlkit-barcode-detection] detectWithStillImage does not detect barcode #34

Open
kyao-Frndz opened this issue Oct 14, 2022 · 11 comments
Open

Comments

@kyao-Frndz
Copy link

I am using the detectWithStillImage to detect QR codes from local Image sources on android. The image is seen as a Bitmap but returns no response or error.

my implementation code:

import { DetectionEvent, DetectionType, detectWithStillImage, StillImageDetectionOptions } from "@nativescript/mlkit-core";

const image = ImageSource.fromFile(imagePath);

detectQRCode(image: any) {
    const options: StillImageDetectionOptions = {
      detectorType: DetectionType.Barcode,
      barcodeScanning: {
        barcodeFormat: [BarcodeFormats.QR_CODE],
      },
    };

    detectWithStillImage(image, options)
      .then((image) => {
        console.log(image);
      })
      .catch((error) => {
        console.log(error);
      });
  }

Any assistance on this will be appreciated, thanks.

@triniwiz
Copy link
Member

ImageSource.fromFile should return a promise,so you will need to wait on that to resolve or you can use ImageSource.fromFileSync

@kyao-Frndz
Copy link
Author

@triniwiz thanks for your response.
I have changed the code to wait and resolve but still no response

ImageSource.fromFile(selectedImage.toString()).then((image) => {
      detectQRCode(image);
    });

@triniwiz
Copy link
Member

Are you using a picker by chance ?

@kyao-Frndz
Copy link
Author

Yes I am using @prabudevarrajan/filepicker

@triniwiz
Copy link
Member

The fromFile call resolved ?

@kyao-Frndz
Copy link
Author

kyao-Frndz commented Oct 14, 2022

Yes it resolves to

{
  "android": {},
  "_rotationAngle": 0
 }

but still no response or error from the detectStillImage function

@kyao-Frndz
Copy link
Author

kyao-Frndz commented Oct 14, 2022

@triniwiz any progress on the issue

@DanielDent
Copy link

When debugging #33, one of the things I started looking at was https://developers.google.com/ml-kit/vision/barcode-scanning/android - it's unclear to me how to configure the plugin to statically link vs download dynamically models from Google Play Services, and I'm unsure which it is doing. When using runtime download of the model, an issue I have seen before in testing is that sometimes the model hasn't yet been downloaded from Google Play Services,

@kyao-Frndz
Copy link
Author

Thanks a bunch, @DanielDent for the assist... I ended up using a different library (@nativescript/firebase by Eddy) taking into account your insight during your debugging.

@triniwiz
Copy link
Member

@triniwiz
Copy link
Member

Please give it a try with 1.0.7 and LMK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants