Polyconseil / zbarlight

A simple wrapper for zbar
BSD 3-Clause "New" or "Revised" License
163 stars 37 forks source link

Possible to scan mutiple code types, but no control over it #10

Closed IamTechknow closed 7 years ago

IamTechknow commented 7 years ago

Hi,

I am using zbarlight to be able to scan QR codes, and it does well for that purpose. However the images I am scanning contain QR codes and UPC-A barcodes, and it is possible for the library to successfully scan both codes. I have yet to find how to scan only QR codes successfully.

I looked into how the code type is parsed when initializing the zbar scanner, and I believe this is done correctly. That is, "qrcode" becomes "qrcode.enable" which should only enable QR code scanning and not 1D barcode types, however the barcodes in my images are still being scanned.

Let me know if you need anything such as an image and test case to reproduce this. Thanks for the library and response!

IamTechknow commented 7 years ago

Hi, after I did some investigation on this issue, I found that scanning for some (if not all) codes are enabled by default and need to be explicitly disabled for codes to not be scanned and decoded. I fixed my issue by calling zbar_image_scanner_set_config() for QR Code and all other codes I didn't want scanned. Incidentially my barcodes are detected by ZBar to be EAN-13 instead of UPC-A, but disabling EAN-13 detection prevented the barcode from being decoded.

zbar_image_scanner_parse_config() could also be used to set the image scanner config but only works for one string and thus one config/code at a time, so it does not seem to me that the high level python APIs can change the image scanner configuraion. Would it be possible to modify the API function to parse the desired code formats, set it, and disable anything else explicitly?

fbochu commented 7 years ago

Hi,

Thanks for reporting this bug, I will soon publish a new version of zbarlight which respect the asked code type.

I see the same as you: disabling EAN13 also disable UPC-A, I do not known much of how zbar works internally and the documentation does not help much about that (at least the one I found).

For now, zbarlight will only detect one kind of code but if someone need to detect more than one kind of code at once, it will no be a problem to add this feature in the future.

fbochu commented 7 years ago

Zbarlight 1.2 is now available and should fix your issue !