I was testing the performance of various QR code detection libraries using "perfect" version 1-H QR codes generated by segno, and I noticed that some of these codes could not be detected. In particular, the following 192 values failed to be detected when testing exhaustively in the range $[0, 10^6]$:
This issue was not exclusive to pyzxing, and other tested libraries such as OpenCV and BoofCV also had issues with some payloads (although for different values), which are confirmed as a bug due to false positives in the finder pattern (which may or may not be the same issue in this case) - see lessthanoptimal/PyBoof#23. Please note that there is also an identified bug in segno in which the padding is malformed for 4-digit payloads - see heuer/segno#123, although this does not seem to affect pyzxing as I'm assuming you ignore the padding bits (which seems to be a strategy employed by many detector libraries).
Steps to reproduce
import cv2
import segno
from pyzxing import BarCodeReader
TEST_FILE = 'qr_test.png'
reader = BarCodeReader()
bad_detections = []
for i in range(0, 100000):
qrcode = segno.make(i, version=1)
assert qrcode.error == 'H'
qrcode.save(TEST_FILE, scale = 5)
img = cv2.imread(TEST_FILE)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
img = cv2.resize(img, (88, 88))
barcodes = reader.decode_array(img)
assert len(barcodes) == 1
if 'raw' not in barcodes[0]:
print(f"Unable to detect {i}")
bad_detections.append(i)
else:
assert barcodes[0]['raw'].decode("utf-8") == str(i), f"Mismatch between detected value {barcodes[0]['raw'].decode("utf-8")} and input {x}"
print(f"Unable to detect the following data payloads:\n{bad_detections}")
System Information
Operating System: Ubuntu 22.04 Python version: 3.10.6
.venv dump (
pip freeze
) - also contains other QR detection libraries which were tested:Detailed description
I was testing the performance of various QR code detection libraries using "perfect" version 1-H QR codes generated by
segno
, and I noticed that some of these codes could not be detected. In particular, the following 192 values failed to be detected when testing exhaustively in the range $[0, 10^6]$:This issue was not exclusive to pyzxing, and other tested libraries such as
OpenCV
andBoofCV
also had issues with some payloads (although for different values), which are confirmed as a bug due to false positives in the finder pattern (which may or may not be the same issue in this case) - see lessthanoptimal/PyBoof#23. Please note that there is also an identified bug insegno
in which the padding is malformed for 4-digit payloads - see heuer/segno#123, although this does not seem to affect pyzxing as I'm assuming you ignore the padding bits (which seems to be a strategy employed by many detector libraries).Steps to reproduce