capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
437 stars 169 forks source link

Barcode is not scanning #222

Closed kumarjitendra-epic closed 1 year ago

kumarjitendra-epic commented 1 year ago

Hi, We are using capacitor plugin for barcode scanning. We are able to scan qrcodes but barcodes are not getting scanned. QRcodes are working all OK. Any hint will be really appreciated. Thanks in advance

scanIT() { async checkPermission() { return new Promise(async (resolve, reject) => { const status = await BarcodeScanner.checkPermission({ force: true }); if (status.granted) { resolve(true); } else if (status.denied) { alert('Give access to camera'); } else { resolve(false); } }); } async stopScan(){ BarcodeScanner.stopScan(); } async prepareScan(){ await BarcodeScanner.prepare({targetedFormats:['EAN_13']}) } async onScan() { await this.checkPermission(); await BarcodeScanner.hideBackground(); document.querySelector('body').classList.add('scanner-active'); const result = await BarcodeScanner.startScan({cameraDirection: "back" }); console.log('After Start Scan ' + result.content); await BarcodeScanner.showBackground (); document.querySelector('body').classList.remove('scanner-active'); }

thegnuu commented 1 year ago

@kumarjitendra-epic unfortunately the current implementation of this plugin was never good in scanning 1D barcodes. Depending on the devices and the cameras the results may vary, but in general the results are quite bad and detection only works (sometimes) if the code is horizontally centred in the viewport.

There ist not much you can do with the current AVFoundation/ZXing implementation, we are working on a new version using ml-kit which should provide way better results, but I cannot give you an ETA for this change.

kumarjitendra-epic commented 1 year ago

hi, thanks for the prompt reply. Do you think using ml-kit may work, I can try integrating this(not sure how far can I go). Any leads from you?

JanMisker commented 1 year ago

Hi @kumarjitendra-epic you are more than welcome to make your own fork and clone it to your local machine. Then you can checkout the branch and test by installing the plugin locally, see the Capacitor guide for more info how to do that. https://capacitorjs.com/docs/plugins/workflow#local-testing

levarberry commented 1 year ago

I would assume for 1D barcodse then we'd need to use the phonegap plugin until there is a better capacitor version?

JanMisker commented 1 year ago

@levarberry I think the ml-kit branch is already good for use, next week we are releasing an app that uses that branch. Workflow is to clone this repository, switch to the ml-kit branch, install the plugin locally (see Capacitor docs how to do that).

Do note that the API changed.

kumarjitendra-epic commented 1 year ago

@JanMisker , by any chance the new plugin has been released that you are discussing about?

thegnuu commented 1 year ago

@kumarjitendra-epic unfortunately not, due to unforeseen issues in my own project I had no time this week.

Hopefully I can find time next week to finish things up.

kumarjitendra-epic commented 1 year ago

Also, I am trying to use cameradirection as back, it works fine when run in browser but as soon as I use the apk on mobile, it stops working

JanMisker commented 1 year ago

@JanMisker , by any chance the new plugin has been released that you are discussing about?

you'd have to clone this repository locally and switch to the ml-kit branch.

thegnuu commented 1 year ago

@kumarjitendra-epic you can check out v5.0.0-beta.1