OUDON / rmqrcode-python

Rectangular Micro QR Code (rMQR Code) Generator in Python
https://pypi.org/project/rmqrcode/
Other
155 stars 16 forks source link

Codes which has two or more types of blocks cannot be recognized by QRQR. #54

Open tkamiya22 opened 2 months ago

tkamiya22 commented 2 months ago

The codes that generated this library with these versions are could not be recognized with QRQR.

to Reproduce

Scan the code generated by the following code:

from src.rmqrcode import rMQR, ErrorCorrectionLevel
from src.rmqrcode.encoder import NumericEncoder
from rmqrcode import QRImage

version = 'R9x139'
e = ErrorCorrectionLevel.M

qr = rMQR(version, e)
qr.add_segment('1', NumericEncoder)
qr.make()

image = QRImage(qr, module_size=8)
image.show()

Versions that could not be recognized

ErrorCorrectionLevel.M

27 43 59 77 99 139
R7 -
R9 - x
R11 x
R13 x x x
R15 - x x
R17 - x

ErrorCorrectionLevel.H

27 43 59 77 99 139
R7 -
R9 - x
R11 x x x
R13 x x x
R15 - x x x
R17 - x x x
tkamiya22 commented 2 months ago

I haven't been able to fix this problem yet, but I've found that the code that QRQR can't recognize has 2 block definitions.

from src.rmqrcode import rMQR, ErrorCorrectionLevel
from src.rmqrcode.format.rmqr_versions import rMQRVersions

def print_table(e: ErrorCorrectionLevel):
    rows = [7, 9, 11, 13, 15, 17]
    cols = [27, 43, 59, 77, 99, 139]

    print('|   |' + '|'.join((f'{i:>3}' for i in cols)) + '|')
    print('|---|' + '|'.join(('---' for i in rows)) + '|')

    for row in rows:
        print(f'|R{row:<2}|', end='')
        for col in cols:
            version = f'R{row}x{col}'
            if not rMQR.validate_version(version):
                print(' - |', end='')
                continue
            b = rMQRVersions[version]['blocks'][e]
            print(f' {len(b)} |', end='')
        print('')

print_table(ErrorCorrectionLevel.M)
print()
print_table(ErrorCorrectionLevel.H)

ErrorCorrectionLevel.M

27 43 59 77 99 139
R7 - 1 1 1 1 1
R9 - 1 1 1 1 2
R11 1 1 1 1 2 1
R13 1 1 1 2 2 2
R15 - 1 1 2 1 2
R17 - 1 1 1 2 1

ErrorCorrectionLevel.H

27 43 59 77 99 139
R7 - 1 1 1 1 1
R9 - 1 1 2 1 1
R11 1 1 2 2 2 1
R13 1 1 1 2 2 2
R15 - 2 1 2 1 2
R17 - 2 1 2 1 2
tkamiya22 commented 2 months ago

https://github.com/OUDON/rmqrcode-python/blob/9dbbc2c6163fde897431a57cad9e475bf1e56e48/src/rmqrcode/rmqrcode.py#L387-L409

line 394,406 : Change break into continue (I'll make a PR after I check some cases.)