Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tkamiya22 opened this issue Jul 9, 2024 · 2 comments · May be fixed by #56
Open

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

tkamiya22 opened this issue Jul 9, 2024 · 2 comments · May be fixed by #56

Comments

@tkamiya22
Copy link

tkamiya22 commented Jul 9, 2024

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
Copy link
Author

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
Copy link
Author

tkamiya22 commented Jul 10, 2024

# Add data codewords
# The last block always has the most codewords.
for i in range(blocks[-1].data_length()):
for block in blocks:
try:
data_codeword = block.get_data_at(i)
except IndexError:
break
else:
final_codewords.append(data_codeword)
self._logger.debug(f"Put QR data codeword {i} : {data_codeword}")
# Add ecc codewords
# The last block always has the most codewords.
for i in range(blocks[-1].ecc_length()):
for block in blocks:
try:
ecc_codeword = block.get_ecc_at(i)
except IndexError:
break
else:
final_codewords.append(ecc_codeword)
self._logger.debug(f"Put RS data codewords {i} : {ecc_codeword}")

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant