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

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

Open
b-fab-michael opened this issue Oct 31, 2023 · 9 comments

Comments

@b-fab-michael
Copy link

b-fab-michael commented Oct 31, 2023

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
Copy link
Owner

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

@b-fab-michael
Copy link
Author

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
Copy link

ozkayas commented Nov 8, 2023

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

@khoren93
Copy link
Owner

khoren93 commented Jan 7, 2024

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

@frankmer
Copy link
Contributor

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
Copy link

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

@U-WHY
Copy link

U-WHY commented Jun 7, 2024

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

@alejandrogiubel
Copy link

Any update on this?

@frankmer
Copy link
Contributor

Any update on this?

currently i am using this code and it works super good.

  final DecodeParams params = DecodeParams(
     imageFormat: zxing.ImageFormat.rgb,
     format: Format.any,
     tryHarder: tryHarder,
     tryInverted: tryInverted,
     isMultiScan: false,
   );
   final text = (await zx.readBarcodeImagePath(file, params)).text;

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

7 participants