From f455246fde086dda0cb61b92c84a5146a831a2bf Mon Sep 17 00:00:00 2001 From: cirakg Date: Tue, 20 Oct 2026 06:56:58 +0200 Subject: test(codes): compare QR with segno, decode QR dumps and the QR screenshot Co-Authored-By: Claude Opus 5.5 --- tools/check_codes.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tools/check_codes.py') diff --git a/tools/check_codes.py b/tools/check_codes.py index 22d3033..53e30f0 100644 --- a/tools/check_codes.py +++ b/tools/check_codes.py @@ -19,7 +19,9 @@ from pathlib import Path import barcode_ref as ref DUMP = re.compile(r"CODEDUMP (\d+) ([0-9a-f]*) ([01]+)") +QR_DUMP = re.compile(r"QRDUMP (\d+) ([0-9a-f]*) ([0-9a-f]+)") SCALES = (1, 2, 3) +QR_SCALES = (2, 3) # README 12.2: 2D codes use at least 2 px per module def check_log(path: Path) -> tuple[int, list[str]]: @@ -36,6 +38,15 @@ def check_log(path: Path) -> tuple[int, list[str]]: if expected not in got: failures.append(f"symbology {symbology} '{text}' at {scale} px/module: read {got}") checked += 1 + for match in QR_DUMP.finditer(path.read_text(encoding="utf-8", errors="replace")): + size = int(match.group(1)) + text = bytes.fromhex(match.group(2)).decode("utf-8") + packed = bytes.fromhex(match.group(3)) + for scale in QR_SCALES: + got = ref.decode(ref.render_matrix(packed, size, scale, quiet=4), ref.QR) + if text not in got: + failures.append(f"QR size {size} '{text[:30]}' at {scale} px/module: read {got}") + checked += 1 return checked, failures -- cgit v1.2.3