How igorkovbel/anpr works
Purpose and Entry Points
ANPR is a Python service for automatic number-plate recognition across uploaded images, uploaded videos, and live camera streams. The application entry point is app/main.py; it serves the browser interface in templates/index.html and exposes processing/API paths backed by detection, tracking, OCR, and WebRTC modules.
HTTP/API and UI Layer
app/main.py is the orchestration boundary for request handling. It routes image/video submissions into offline processing and connects real-time clients to the WebRTC pipeline. templates/index.html is the client-facing interface for upload and/or camera interaction.
Detection and Recognition Models
Vehicle/plate detection uses a YOLOv10 model, while plate text is recognized with an ONNX OCR model. Model artifacts are packaged with the application at:
• app/models/model.pt
• app/models/VT_ep1500.onnx
• app/models.py
This layer turns frames or images into plate regions and recognized plate strings; model loading/inference utilities are likely centralized in app/models.py.
Image and Video Processing Pipeline
app/processing.py implements the shared media-processing flow: decode input, run detection, crop plate candidates, invoke OCR, and annotate or emit results. For video, detection is performed periodically (per README, every 15 frames) and tracker state fills intervening frames, producing a processed MP4 result such as result.mp4.
Real-Time WebRTC Pipeline
app/webrtc.py adapts the same inference pipeline to incoming browser camera frames. It is the latency-sensitive boundary between WebRTC media transport and GPU/CUDA-backed frame processing, returning processed frames to the client rather than requiring an uploaded file.
Tracking and Third-Party Vision Code
Tracking is supplied by the HiT implementation, reducing detector frequency while maintaining object identity/position between detections. Detector, tracker, and OCR dependencies are vendored or referenced under:
• libs/HiT
• libs/yolov10
• libs/fast
These libraries form the external ML boundary; application modules should keep their APIs behind model/processing abstractions.
Runtime and Deployment Boundaries
The service is Python-based with dependencies declared in requirements.txt and container packaging in Dockerfile. The intended performance profile relies on CUDA/GPU execution for real-time tracking and inference. TLS assets at certs/server.crt and certs/server.key are materially relevant because browser WebRTC camera access commonly requires HTTPS.
Main entry points: main.py Service entry point · models.py Model inference · webrtc.py WebRTC frame pipeline · processing.py Offline media pipeline
Components 14
Application
- Browser UI · Uploads media and connects camera sessions.
templates/index.html - Service entry point · Routes offline jobs and real-time sessions.
app/main.py - Offline media pipeline · Decodes, detects, tracks, OCRs, and annotates images or videos.
app/processing.py - WebRTC frame pipeline · Processes incoming camera frames and returns annotated frames.
app/webrtc.py
ML Pipeline
- Model inference · Centralizes model loading and detection/OCR inference.
app/models.py - YOLOv10 weights
app/models/model.pt - ONNX OCR weights
app/models/VT_ep1500.onnx - HiT tracker · Maintains object identity between periodic detections.
libs/HiT - YOLOv10 library
libs/yolov10 - FAST OCR library
libs/fast
Runtime & Deployment
- Container image · Packages the CUDA-capable Python service.
Dockerfile - Python dependencies
requirements.txt - TLS certificate · Enables secure browser camera access.
certs/server.crt - TLS private key
certs/server.key
Connections 16
- Browser UI → Service entry point: uploads and API requests
- Browser UI → WebRTC frame pipeline: camera media session
- Service entry point → Offline media pipeline: image/video jobs
- Service entry point → WebRTC frame pipeline: real-time session setup
- Offline media pipeline → Model inference: detects and reads plates
- Offline media pipeline → HiT tracker: tracks between detections
- WebRTC frame pipeline → Model inference: per-frame inference
- WebRTC frame pipeline → HiT tracker: real-time tracking
- Model inference → YOLOv10 weights: loads weights
- Model inference → ONNX OCR weights: loads weights
- Model inference → YOLOv10 library: uses detector
- Model inference → FAST OCR library: uses OCR
- Container image → Service entry point: runs service
- Container image → Python dependencies: installs
- Service entry point → TLS certificate: serves HTTPS with
- Service entry point → TLS private key: uses TLS key