Barcode and QR Scanning
Category: Perception | Level: intermediate | Stability: experimental | Version: v1
Description
A barcode or QR code is a machine-readable string with a strict geometry. This skill covers locating candidate code regions in an image, detecting the symbology, decoding the payload, and reporting confidence honestly — including the case where a damaged or partially occluded code decodes to a wrong-but-checksum-valid result.
When to Use
Use when an image contains barcodes or QR codes whose payload drives a decision — inventory labels, ticket validation, payment codes, hardware serials.
Do not treat a successful decode as ground truth without the symbology checksum; low-quality images decode to plausible wrong values more often than they fail outright.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
image |
image |
Yes | The image containing one or more codes |
region |
box |
No | Crop to scan when the code location is known |
expected_formats |
list |
No | Restrict detection to given symbologies |
Procedure
- Locate candidate code regions before decoding — finder patterns for QR codes, quiet-zone and bar geometry for 1D symbologies.
- Detect the symbology from the located region rather than trying every decoder and taking the first success.
- Normalize the region — deskew, binarize, correct perspective — before attempting the decode.
- Decode the payload and verify the symbology checksum; reject codes that fail their check digit.
- Report per-code confidence and symbology together with the payload, and flag damaged regions explicitly.
- Bound the work: cap the number of regions examined per image so pathological images cannot stall the pipeline.
Outputs
| Output | Type | Description |
|---|---|---|
codes |
list |
Decoded payloads with symbology and checksum status |
regions |
list |
Located code regions in image coordinates |
failures |
list |
Regions that failed to decode, with reasons |
Runnable Example
def detect_symbology(samples):
"""samples: 0/1 module values along the top-left finder corner."""
if samples[:5] == [1, 0, 1, 0, 1]:
return "qr"
if all(v == 0 for v in samples[:9]):
return "ean13"
return "unknown"
def decode_region(region):
symbology = detect_symbology(region["samples"])
if symbology == "unknown":
return {"payload": None, "reason": "unrecognized symbology"}
return {"payload": region["raw"], "symbology": symbology, "checksum": region.get("checksum", False)}
print(decode_region({"samples": [1, 0, 1, 0, 1, 1, 0], "raw": "SKILL-042", "checksum": True}))
Failure Modes
| Failure Mode | Cause | Mitigation |
|---|---|---|
| Wrong but valid decodes | Damaged codes decode to checksum-plausible wrong values | Flag low-confidence and damaged regions |
| Missed codes | Codes at angles or small scale are not located | Use rotation-tolerant, multi-scale region detection |
| Unbounded scanning | Pathological images stall detection | Cap regions and modules examined per image |
| Payload taken as fact | A decoded string drives a decision unchecked | Verify the checksum and cross-check the expected format |
| Symbology misclassification | The wrong decoder is applied to a region | Detect symbology from geometry before decoding |
Security and Authority Boundary
Decoded payloads are untrusted input. A QR code can encode a URL or instruction string; payloads must be validated against an expected format before being used to drive navigation, payment, or privileged actions.
Evidence
This skill is grounded in dated public implementation references:
- The pyzbar barcode decoding library project page (https://pypi.org/project/pyzbar/).
- The ZXing barcode image processing library GitHub repository (https://github.com/zxing/zxing).
Honest boundary: these are implementation references, not adoption or demand evidence; this entry was added under the owner-directed corpus expansion recorded in meta/memory/DECISIONS.md, and no demand signal is claimed for it.
Related Skills
- OCR — the text-recognition counterpart for codes without strict geometry.
- Image Understanding — the visual grounding layer that locates code regions.
Changelog
| Date | Version | Change |
|---|---|---|
2026-10 |
v1 | Initial entry added under the owner-directed corpus expansion |