Case study 10 · Computer vision · OCR

Read the platethe camera blurred

A licence-plate pipeline for footage that is out of focus, shot at night, or washed out by glare. It finds the plate, straightens it, restores it and reads it, and every step is saved as an image so you can see where a reading went right or wrong.

Python · OpenCV · OCR22 before/after cards · 7 defect types

The trickOne frame is often not enough. Aligning several video frames before reading them turned an 80% read into a 100% read.

4Pipeline stages
7Defect types tested
99.5%Best plate confidence
80→100%Character match, multi-frame ECC
Data flow · how a record moves

Blurred frame to a readable plate

For video, several frames are aligned with sub-pixel ECC and median-composited before enhancement, which is what fixed the misread characters. Click a stage to read what happens there.

01 · Restore

From smear to string

Drag the slider to walk a blurred plate through the four stages. The reading below changes as the image gets clearer.

TN 21 AT 0492
plate
1 Detect2 Rectify3 Enhance4 OCR
OCR read

Illustration · CSS blur stands in for real defocus. The final read and 99.5% match the README result for this plate.

Modulesdetect.py, enhance.py, ocr_engine.py, metrics.py, pipeline.py.

02 · Results

Confidence on real plates

OCR confidence on four test plates after the full pipeline. On one of them the baseline reader missed the state code entirely.

OCRRapidOCR on ONNX Runtime with a Tesseract fallback. Candidates from several enhancement variants are ranked as an ensemble.

03 · Video

More frames, fewer mistakes

A single blurred frame read KA05MZ7788 as KA05427788. Aligning the frames with sub-pixel ECC and taking a temporal median composite fixed it.

Single image
0%KA05427788
Video · ECC aligned
0%KA05MZ7788

Scored byLevenshtein character accuracy, so 80% means 8 of 10 characters right.

04 · Defects

Built for bad footage

Seven defects in the synthetic suite: motion blur, defocus, low resolution, night noise, glare, perspective skew and camera shake. Defocus (DL8CAF5566) and low-light (TN10CX9012) plates were read exactly in both image and video modes; the glare plate (GJ01HN3344) was read exactly from video.

01DetectSobel edge density, morphology and an aspect-ratio check find the plate.
02RectifyPerspective correction to a flat, front-on crop.
03EnhanceWiener deblur, CLAHE, non-local-means denoising and super-resolution.
04ScorePSNR, SSIM, Laplacian sharpness and character accuracy, saved to result.json.
PythonOpenCVOCRECC alignmentCLAHERapidOCRTesseract

DataReal plates from the Indian Vehicle Dataset plus a synthetic suite with known ground truth.