How tkvmaster/anpr-system works
Project type and purpose
• This is a specialized Computer Vision / Deep Learning pipeline for Automatic Number-Plate Recognition (ANPR).
File structure
• Top‐level scripts and notebooks:
• anpr-system.py – the main inference CLI
• *.ipynb – exploratory and training notebooks (data scraping, YOLOv5 training, post‐processing)
• runs/train/exp – stores training artifacts for YOLOv5: best.pt, last.pt, events, results.csv
• utility_files – logos, demo GIF, and any static assets
• requirements.txt – external dependencies
• README.md – project overview, usage, tech stack
• The absence of a “frontend” folder confirms this is a back-end/CLI pipeline rather than a web app.
Key insights from the README
• Two‐step inference: (1) YOLOv5 detection → (2) PaddleOCR recognition + Norfair tracking
• Data flow: video input → frame extraction → ROI crop → preprocessing → OCR → tracking → outputs
• Training uses PyTorch/YOLOv5; inference uses OpenCV for video I/O, PaddleOCR for text, Norfair for tracking
• Outputs: annotated video and CSV file
Main components and their interactions
1. Data Collection & Preprocessing
– image_scrapping.ipynb → raw images
– License_Plate_Detection.ipynb → labeling/augmentation
2. YOLOv5 Training
– yolov5 repo + custom dataset → runs/train/exp/weights/best.pt
B. Real‐Time Inference Pipeline (core)
1. Video Input
– OpenCV VideoCapture (input MP4 or camera feed)
2. Frame Extraction
– loop each frame
3. License‐Plate Detection
4. ROI Cropping & Preprocessing
– crop plate region → grayscale/threshold ng preprocessing
5. OCR Recognition
– PaddleOCR → produces candidate plate strings
6. Tracking & Aggregation
– Norfair Tracker → associates plate detections across frames → selects best OCR result per track
7. Output Modules
– Annotated Video Writer (OpenCV VideoWriter)
– CSV Logger → append <track_id, timestamp, plate_string>
Architectural patterns and design principles
• Pipeline pattern: sequential modules chained via in-memory objects (numpy arrays / OpenCV mats)
• Modular design: each stage (detection, OCR, tracking) is a self‐contained component
• CLI parameterization: anpr-system.py accepts weights/input/output/csv flags for flexibility
• Offline vs. Online separation: training and inference are clearly decoupled
Detail without overthinking
• Every major script or notebook as an optional “Developer Tools” section if desired