Guides · Architecture
How license plate recognition works: detection, reading and the limits of OCR.
A plain explanation of ANPR: finding the plate, cleaning the image, reading characters with OCR, validating the format and where it fails.
Key takeaways
- Plate recognition has three stages: find the plate, read its characters and check the result.
- Accuracy depends on camera angle, light, motion, dirt and plate style.
- Always let a person correct the result. Treat OCR as a suggestion.
- Plates are personal data in many contexts, so collect and store them with care.
The pipeline
1. Capture. A camera takes a photo or video frame of the vehicle.
2. Detect the plate. Software finds the rectangle that holds the plate. Older systems looked for rectangles with edge detection. Modern ones use a trained object detector.
3. Prepare the image. The plate region is cropped, rotated and enlarged, then contrast is adjusted. Perspective correction helps when the camera sees the plate at an angle.
4. Read the characters. Optical character recognition (OCR) converts the pixels to text. Some systems use general OCR. Others use models trained specifically on plates.
5. Clean and validate. The result is checked against known patterns, for example the state code, digits and letters in the expected positions. Confusable characters such as 0 and O, or 1 and I, get corrected by position rules.
6. Present or store. The app displays the text, and usually allows an attendant to confirm or edit it.
What makes it hard
- Lighting. Glare, shadows and night conditions reduce contrast.
- Motion blur. A moving vehicle or shaky phone smears text.
- Angle and distance. Small or skewed plates have fewer pixels.
- Dirt and damage. Mud, stickers and bent plates hide characters.
- Plate styles. Different fonts, sizes, two-line plates and decorative text confuse models.
- Look-alike characters.
8andB,5andS.
On-device or server
Running recognition on the phone means it works offline and sends no images over the network, but limits model size. Running on a server allows heavier models but needs connectivity and handles more private data. A parking gate with unreliable network points toward on-device processing. See building an offline-first app.
Improving accuracy in practice
- Guide the user to frame the plate with an on-screen box.
- Capture several frames and choose the most consistent reading.
- Validate against the expected format and ask for correction when it fails.
- Allow manual entry, always.
- Test on real plates, in your real lighting, not only clean sample images.
Design the workflow around mistakes
An app that depends on perfect recognition will frustrate staff. A good workflow shows the reading, highlights uncertain characters and lets the attendant fix it in a few taps. Log corrections to learn where it fails.
Privacy and rules
Number plates can identify people. Collect only what you need, tell users what you do with it, restrict access, delete data when it is no longer needed and follow the laws that apply to you. This article is not legal advice.
Related technology
Object detection models, such as YOLO, are commonly used for the detection step. See how YOLO object detection works.
Frequently asked questions
Can a phone camera read plates?
Often yes, in good light and with a steady hand, but not perfectly.
Is it free to build?
There are open-source OCR and detection tools. Training and tuning for your plates still takes work.
How accurate is it?
It varies widely. Measure accuracy on your own data before relying on it.
A parking app of mine includes an on-device plate scanner.
See the parking app