micjahn / ZXing.Net

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

Aztec code - not readable in all cases #355

Open andrzejlisek opened 2 years ago

andrzejlisek commented 2 years ago

I am testing the ZXing.net (version for .NET 4.5) with random character sequence:

The character set is (inclucing space):

 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

There are all possible characters, which are allowed in any data file encoded using Quoted-printable algorithm.

The single test case is following:

  1. Generate random sequence consisting of 40 characters from the set described above.
  2. Create the Aztec code using (it generates one pixel per code module) with parameters:
    • Margin=0
    • Width=1
    • Height=1
    • PureBarcode=true
  3. Create new bitmap, which consists generated coded stretched to 10 pixels per module and margin 50 pixels.
  4. Read the code with parameters:
    • AutoRotate = true
    • TryInverted = true;
    • Options.PureBarcode = true;
    • Options.TryHarder = true;
    • Options.PossibleFormats - consists only the AZTEC barcode format
  5. Compare read sequence with original sequence.

The single test result can be one of following:

  1. Read sequence equals to original sequence - good and wanted result.
  2. Read sequence does not equal to original.
  3. Other error - code not generated or unreadable.

For 1000000 (one million) cases, there are about 5-10 cases, in which there are generated unreadable code. I tried encoding and decoding with also WindowsFormsDemo client and the code seems be also unreadable. I repeated this experiment several times and in every case there are from 5 to 10 generated and unreadable codes. In every other cases (all million excluding mentioned cases), the code is readable and equals to original sequence.

I attach 6 cases in Test.zip, in which codes are unreadable. The text file consists of two lines:

  1. Encoded sequence (the EOF or BOM marks are not included).
  2. Code format.

The PNG file consists of code image, which is prepared to read.

Test.zip

micjahn commented 2 years ago

The detector fails to find the correct bull's eye corners for these 6 cases. I think it is because of the top left corner. But I don't know the aztec code good enough to find a correct fix for it.

axxel commented 5 months ago

In case using a .NET wrapper for the native c++ library zxing-cpp would be an option, then here is a fix for you: https://www.nuget.org/packages/ZXingCpp/