zbarimg failes to decode QR code while zbarcam and others succeed
Status: Beta
Brought to you by:
spadix
Hi
I am using zbar 0.10 on Windows 7. I have some QR codes (example is attached in file qrschweiz5.png) that cannot be decoded by zbarimg.
The report says "scanned 0 barcodes from 1 images" (see attachment zbarimg_call.png).
However, if print the image on a piece of paper and hold it infront of the camera, zbarcam is able to decode it (see attachment zbarcam_call.png). Other decoders like ZXing Decoder Online also successfully decode the image.
Any ideas on that?
Regards
Axel
I forgot to attach the output of zbarimg and zbarcam. See in this post.
Sorry for that.
I was able to dive a bit more deeper into it (but sure without having any idea how to solve the problem).
I compiled zbar on ubuntu and used the example scan_image.c to process the qr code. I managed to activate the QR debugging (QR_DEBUG, DEBUG_SVG) and also added some debugging output to some c files.
I found out, that rs_correct (in rs.c) returns a value of -1 for the qr code, what in turn causes the decoding failure. The reason for the negative return code is that rs_modified_berlekamp_massey returns a value of 15 for the qr code but rs_find_roots only finds one single location.
Due to QR debugging, a set of six additional files are produced: debug.png and debug.svg contain data, while binary.png, undistorted_hom.png, grid.png and undistorted_aff.png are empty.
I attached both debug.png and debug.svg.
BTW: debug.png can be decoded with various qr code readers. If I print out debug.png and use zbarcam on windows, everything works great.
Especially the latter confuses me. How can zbarcam decode something that zbarimg or the example code cannot? I would suppose they use the same routines behind the curtain.
Has anyone an idea what I should try next?
hI ALL?
I have the same problem with this image extract form a pdf produced bu six.Has someone fiding a solution to this problem ? Thnaks in davance
Hi there - I had done some awk wrapper around zbarimg to extract these payment slip QR codes last year, based on the samples they provided at the time. I now find that with the latest samples most of these aren't recognized, but some are. Maybe we can figure out what the issue is by comparing the working with the non-working ones? The samples can be found at:
https://www.paymentstandards.ch/dam/downloads/muster-qr-zahlteile-de.zip
These ones do get recognized & decoded by zbarimg:
Uhm - I think it's the "swiss cross" in the middle that's tripping it. I've painted either a black or white bar over it on images that fail to be recognized and then it gets detected fine. It might be messing with the error correction? Is that something we can adjust in zbar?
General comment: Depending on size of the QR code, alignment patterns get embedded. Purpose is to detect image distortion.
Inspecting toto2.png I discover 5 instead of 6. Alignment patterns are squares with modul size 3, black border, black center and white square between. 4 get positioned as a cross. One in the middle between the two upper search patterns, one in the middle between the left search patterns, right and bottom ones mirrored at the diagonal from top right to lower left corner. The fifth is position near the right bottom edge and the sixth missing one should be in the center.
From a formal point the swiss cross in the center invalidates these QR codes. Error correction codes should made decoding possible anyway. At least if enough redundancy is left after reading.
To be honest I don't have any idea why zbarimage and zbarcam behave different.
Checking Simons samples:
Just guessing: the working qr codes are quite large, that means contain more redundancy relative to the data loss provided by the center swiss cross. Although scaling of the qr code varies on amount of data, swiss cross in the center has fixed size. That means it produces a larger data loss on "small" qr codes compared with "large" ones.
QR codes use Reed Solomon Code for error correction. ISO/IEC 18004 defines four different levels of redundancy: L=7%, M=15%, Q=25%, H=30%.
Hi all,
Zebra Crossing (ZXing) is another open source project implementing 1d and 2d barcode decoders. I did use it's online offer to scan images either accessible online or by upload on all of Simon Rupfs samples and ALL have been decoded successfully with these comments:
Axel Miller mentioned in his Post that he did find out that function rs_correct in rs.c (implementation of read solomon encoder/decoder) returns -1 if detection fails. From description of rs_correct: returns the number of errors corrected if successful, or a negative number if the message could not be corrected because too many errors were detected.
IMHO:
Thank you for your suggestion. Indeed I could decode almost all of the samples (except Nr. 18") using it. I have switched my little shell script to use zxing.
I have now also found an online validator - for those not concerned about the privacy implications, it can be found at https://www.swiss-qr-invoice.org/validator/. It decodes all of the samples provided in this ticket.
FYI: zbar has moved to https://git.linuxtv.org/zbar.git/