Building a Smart ALPR Dashboard: Real-Time Vehicle Tracking with Flask and YOLOv8
Computer Vision Project
Automated License Plate Recognition (ALPR) is no longer reserved for high-budget municipal infrastructure. With the convergence of YOLOv8 for object detection and PaddleOCR for text extraction, developers can now deploy sophisticated tracking systems on standard hardware.
This guide explores a Flask-based ALPR system designed for real-time monitoring, direction estimation, and historical data logging.
The Architecture: How It Works
The system operates on a multi-stage computer vision pipeline that transforms raw video frames into actionable metadata.
Vehicle Detection: A YOLOv8 model identifies vehicle bounding boxes.
Plate Localization: A secondary, specialized model zooms in to find the license plate within the vehicle's coordinates.
OCR Processing: PaddleOCR converts the visual plate into a string of text.
Directional Logic: By tracking the centroid movement across a static "trigger line," the system determines if a vehicle is Entering (IN) or Exiting (OUT).
Persistence: Data is cached in a CSV for lightweight logging, while snapshots are saved as visual evidence.
Core Features
Dual-Model Precision: Using separate weights for vehicles (
car_model.pt) and plates (plate_model.pt) reduces false positives and improves accuracy in crowded frames.Live Web Dashboard: A Flask frontend allows users to input RTSP streams (for IP cameras) or local webcam IDs to start monitoring instantly.
Intelligent Search: A built-in historical log viewer to filter detections by plate number, date ranges, or movement direction.
Automated Evidence: Every detection triggers an image save to
static/detections/, ensuring you have visual proof to back up the OCR data.
Technical Implementation
Prerequisites & Setup
You will need Python 3.8+ and a few heavy-hitting libraries. Install them via terminal:
Bash
pip install flask pandas opencv-python ultralytics paddlepaddle paddleocr
Directory Structure
A clean structure is vital for Flask to serve static assets and templates correctly:
app.py: The Flask server handling routing.pipeline.py: The "brain" containing the CV logic.templates/: UI files (index.html,search.html).static/detections/: Storage for captured plate images.

Critical Evaluation & Assumptions
While this architecture is robust for a "Smart Dashboard," there are several technical hurdles and potential biases to keep in mind:
The "Static Line" Assumption: Directional logic based on a static line assumes a fixed camera angle. If the camera vibrates or is repositioned, the "IN/OUT" logic may invert or fail.
Hardware Bottlenecks: Running two YOLO models plus OCR in real-time is computationally expensive. On a standard CPU, you may experience significant latency (frame lag). To achieve "Real-Time" status, CUDA-enabled GPU acceleration is practically mandatory.
OCR Sensitivity: PaddleOCR is highly accurate but can struggle with skewed angles or poor lighting. A "Confidence Threshold" should be implemented to discard low-certainty reads before they hit your database.
