khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
97 stars 56 forks source link

Unable to recognize the QR code from the image, the Codes are empty strings on Android and iOS #115

Open b-fab-michael opened 11 months ago

b-fab-michael commented 11 months ago

Please fix this issue as soon as possible, otherwise I'll have to add another image QR code recognition library for this.
Device:Xiaomi 13、iPhone 14 Pro

`I/flutter (30296): [E] zx.readBarcodeImagePathString : code==null --> false

I/flutter (30296): [E] zx.readBarcodeImagePathString : code.text -->

I/flutter (30296): [E] zx.readBarcodeImagePathString : code.text.length --> 0`

khoren93 commented 11 months ago

Hello @b-fab-michael, could you kindly share the demo image required to replicate your problem? Thank you.

b-fab-michael commented 11 months ago

Hello @b-fab-michael, could you kindly share the demo image required to replicate your problem? Thank you.

` void _onPicTap() async { final res = await ImagePickerUtils.pickerPaths( galleryMode: GalleryMode.image, selectCount: 1, showGif: false, compressSize: 5120, ); File file = File(res[0].path ?? ''); Code? qrcode = await zx.readBarcodeImagePathString(file.path); LogUtil.e('zx.readBarcodeImagePathString : code==null --> ${qrcode==null}'); LogUtil.e('zx.readBarcodeImagePathString : code.text --> ${qrcode?.text}'); LogUtil.e('zx.readBarcodeImagePathString : code.text.length --> ${qrcode?.text?.length}'); if (qrcode != null) { OXNavigator.pop(context, qrcode.text); } else { CommonToast.instance.show(context, "str_invalid_qr_code".commonLocalized()); } }

`

This is my code. Please tell me. Is there anything else I need to improve?

ozkayas commented 11 months ago

@khoren93 I am also getting always isValid = false and empty result from scanned images.

khoren93 commented 9 months ago

@b-fab-michael @ozkayas please check the v1.5.2. Thanks!

frankmer commented 8 months ago

Doesn't work with any QR code image I've tried. I've using version 1.5.2.

For testing purposes, I created a QR with an online tool from the string "Test123" and selected it with the file_selector package.

Inside of the same widget:

@OverRide void initState() { zx.startCameraProcessing(); super.initState(); }

@OverRide void dispose() { zx.stopCameraProcessing(); super.dispose(); }

My Code: final XFile? file = await openFile(); if (file == null) return; log('Selected file: ${file.path}'); log('FileBytes: ${(await file.readAsBytes()).length}'); final result = await zx.readBarcodeImagePath(file); log('ResultDuration: ${result.duration}'); log('ResultError: ${result.error}'); log('ResultFormat: ${result.format}'); log('ResultIsInverted: ${result.isInverted}'); log('ResultIsMirrored: ${result.isMirrored}'); log('ResultIsValid: ${result.isValid}'); log('ResultPosition: ${result.position}'); log('ResultRawBytes: ${result.rawBytes}'); log('ResultText: ${result.text}');

Output: [log] Selected file: content://com.android.providers.media.documents/document/image%3A1000000179 [log] FileBytes: 26487 [log] ResultDuration: 23 [log] ResultError: [log] ResultFormat: 0 [log] ResultIsInverted: false [log] ResultIsMirrored: false [log] ResultIsValid: false [log] ResultPosition: Instance of 'Position' [log] ResultRawBytes: null [log] ResultText:

mayurd2019 commented 5 months ago

It there any solution yet as I am also facing same issue. Not able to scan qr code from gallery image

U-WHY commented 3 months ago

Same issue and I can't find any solution for that. There is my code & image, i test it in android api 34 & 29

Future _decodeQrCode() async { final XFile? file = await ImagePicker().pickImage(source: ImageSource.gallery); final DecodeParams params = DecodeParams( imageFormat: ImageFormat.rgb, format: Format.any, tryHarder: false, tryInverted: false, isMultiScan: false, ); final Code result = await zx.readBarcodeImagePath(file!,params); if (result.isValid) { print(result.text!); } else { print('WTFWTF!!'); } }

20240607110753 20240607110759