Description
The detection model merges adjacent barcodes with the MRZ zone into a single detection region. When a PDF417 or similar 2D barcode is positioned directly above or below the MRZ (common in passports from Yemen, and potentially other countries), the heatmap treats both as one continuous region instead of isolating the MRZ.
Reproduction
Document: Yemeni passport (Republic of Yemen) — the PDF417 barcode sits directly above the two MRZ lines with minimal vertical gap.
Observed behavior:
- The heatmap activates across the entire barcode + MRZ area as one blob
- The detected polygon covers both the barcode and the MRZ
- After warping, the recognizer receives an image containing barcode noise on top of the actual MRZ text
- Recognition produces garbage instead of valid MRZ lines
Expected behavior:
- The detection polygon should cover only the MRZ zone
- Recognition should return 2 clean TD3 lines
What we tried (post-processing level)
None of these work because the model gives equally high confidence to both regions:
- Progressive thresholding on the heatmap — both barcode and MRZ have similarly high values, so raising the threshold doesn't separate them
- Morphological operations (vertical erosion/opening) — the blob is fully connected with no thin bridge to break
- Polygon filtering by aspect ratio — only one polygon exists (the merged blob), so there's nothing to filter
Suggested fix
Add barcode augmentation to the synthetic training data pipeline. Placing synthetic PDF417 / Code128 / QR barcodes near generated MRZ zones during training would teach the model to suppress barcode regions in the heatmap. Post-processing heuristics cannot fix regions that the model scores with equal confidence — this needs to be learned.
Environment
mrzscanner latest (detection cfg 20250222, recognition cfg 20250221)
- Backend: CPU (ONNX)
Description
The detection model merges adjacent barcodes with the MRZ zone into a single detection region. When a PDF417 or similar 2D barcode is positioned directly above or below the MRZ (common in passports from Yemen, and potentially other countries), the heatmap treats both as one continuous region instead of isolating the MRZ.
Reproduction
Document: Yemeni passport (Republic of Yemen) — the PDF417 barcode sits directly above the two MRZ lines with minimal vertical gap.
Observed behavior:
Expected behavior:
What we tried (post-processing level)
None of these work because the model gives equally high confidence to both regions:
Suggested fix
Add barcode augmentation to the synthetic training data pipeline. Placing synthetic PDF417 / Code128 / QR barcodes near generated MRZ zones during training would teach the model to suppress barcode regions in the heatmap. Post-processing heuristics cannot fix regions that the model scores with equal confidence — this needs to be learned.
Environment
mrzscannerlatest (detection cfg20250222, recognition cfg20250221)