A production-ready, modular Edge-AI video analytics pipeline designed for real-time vehicle detection, multi-object tracking, and region-crossing analytics. Built with Python and optimized for Video Management Software (VMS) ecosystems.
- Multi-Class Vehicle Detection: Leverages an optimized YOLOv8 framework to detect and classify urban traffic entities (cars, trucks, buses, motorcycles) with high precision.
- Hardware-Aware Execution: Automatically detects and utilizes NVIDIA CUDA cores if available, falling back to CPU gracefully. Includes a built-in Frame Stride optimizer for low-end edge devices.
- Robust Multi-Object Tracking (MOT): Utilizes the ByteTrack algorithm to maintain consistent unique IDs across frames, handling occlusions and complex overlaps.
- Dynamic Aspect Ratio Handling: Flawlessly processes both traditional CCTV (16:9) and mobile/vertical (9:16) streams without distorting bounding box geometries.
- Privacy-by-Design (GDPR Compliant): Pre-architected with a Real-Time Anonymization Layer that blurs localized sensitive regions to conform strictly with the EU AI Act.
The pipeline is designed to be plug-and-play. You can easily adjust the core mechanics by modifying the configuration block at the top of src/main.py:
# --- USER CONFIGURATION ---
VIDEO_SOURCE = 'data/traffic.mp4' # Supports local paths or RTSP streams
MODEL_TYPE = 'yolov8s.pt' # Choose 'n', 's', or 'm' based on your GPU
FRAME_STRIDE = 1 # Increase to 2 or 3 for CPU optimization
CONFIDENCE = 0.15 # Detection sensitivity threshold
🛠️ Tech Stack & Dependencies
Core Engine: Python 3.10+
Inference & Deep Learning: ultralytics, torch
Computer Vision: opencv-python, numpy
Tracking & Annotations: supervision
🚀 Installation & Quick Start
Clone the Repository:
Bash
git clone [https://github.com/yourusername/smartcity-vision-pipeline.git](https://github.com/yourusername/smartcity-vision-pipeline.git)
cd smartcity-vision-pipeline
Create a Virtual Environment (Recommended):
Bash
python -m venv venv
source venv/bin/activate # On Windows use: venv\Scripts\activate
Install Dependencies:
Bash
pip install -r requirements.txt
Run the Pipeline:
Drop a test video named traffic.mp4 into the data/ folder, then run:
Bash
python src/main.py