Blog - APNR — automatic plate recognition from video
How an APNR/ANPR pipeline works: plate localization, matched filters, template OCR, and temporal fusion.
- Author
- 2code
- Published
- Tags
- APNR
- ANPR
- OpenCV
- CV
APNR (Automatic Plate Number Recognition, also ANPR) is a classic vision problem: extract a readable license plate from video. Below is a practical Qt + OpenCV-style pipeline: localize → OCR → fuse over time.
Why video instead of a single frame?
One frame is often blurry, angled, or reflective. Across a sequence we can:
- find plate candidates on many frames,
- recognize characters with varying confidence,
- merge results over time (best character wins).
That is what a detectedframe / detectedplate layer does: match by location and frame index, then update characters by score.
Pipeline
…
Plate localization
A typical path:
- Sobel (aperture, order, threshold) — boosts character edges,
- a matched filter tuned to plate geometry (bright band, darker sides),
- rectangle selection by area and aspect ratio .
The matched-filter row profile can be written as side Gaussians plus a center lobe:
After correlation, bands with plate-like proportions stand out.
OCR: templates, not deep learning
Characters are compared against bitmap patterns (0–9, A–Z) via image matching. A Polish-plate detail: alphabet subsets:
- district/region characters (often 2–3 letters) — a different set (incl. B, D, I, O, Z),
- vehicle-distinctive characters — digits + letters without confusing variants.
Each character stores — glyph and score. Plate confidence:
Temporal fusion
When the same plate reappears (ROI overlap + small ):
- update the bounding box,
- on character conflicts keep the higher ,
- maintain the “divider” (space after the region code), typically after the 2nd or 3rd character.
A one-frame OCR glitch no longer ruins the read.
Production takeaways
- APNR ≠ OCR alone — localization and tracking are harder than reading a glyph.
- Domain rules matter — region codes, length 7–8, alphabet constraints lift precision.
- Time is a feature — cross-frame fusion is the cheapest ensemble.