micjahn / ZXing.Net

.Net port of the original java-based barcode reader and generator library zxing
Apache License 2.0
2.7k stars 666 forks source link

Decoding fails for specific QR code generated by Powershell Modules.QRCodeGenerator #483

Open JonasCz opened 1 year ago

JonasCz commented 1 year ago

I'm using https://github.com/TobiasPSP/Modules.QRCodeGenerator to generate some QR codes, however I'm finding that some of them (around 0.1%) are not recognized. I generate the code with the following command:

New-QRCodeText -Text "1668" -OutPath "code.png" -Width 14

...which gives the following file:

QR code

Scanning it with .\CommandLineDecoder.exe "code.png" gives "No barcode found"

Scaling, different dimensions, added text, crop, --try_harder all makes no difference. https://zxing.org/w/decode.jspx doesn't work either. Most other QR codes generated by same Powershell library are properly recognized. What does work for the above though, is --pure_barcode.

But, it again doesn't work with or without --try_harder (nor with scaling, --pure_barcode, etc) once I try the actual QR data I want to use, which looks like this:

out-002268

However, scanning either of these off the screen with various different phone apps does work correctly. (including BinaryEye which uses ZXing C++). Other values than "1668" do work correctly, both in the source PNG (PNG with or without --pure_barcode) and in the actual data (without --pure_barcode)

Is this a bug in the library that it generates broken codes, or a problem in ZXing.NET, or I just need more error correction setting?

micjahn commented 1 year ago

In some cases, the library won't find the correct position of the finder patterns. At the moment I have no idea how to fix this. Interestingly if you rotate the image by 90 degrees counter-clockwise the code can be decoded successfully.

axxel commented 7 months ago

Since BinaryEye / zxing-cpp has been mentioned above: there is now a .NET wrapper for that c++ library available.