Skip to content

Hung4865/Realtime-Traffic-Violation-Detection-System

Repository files navigation

Intelligent Transportation System

A real-time data engineering pipeline for wrong-way vehicle detection.

System Architecture

Architecture Diagram

Vehicle Detection

YOLOv8 Detection

Algorithm

The system uses a straightforward vector-based approach to efficiently detect wrong-way driving without heavy computational overhead:

Tracking Movement: The object tracker continuously monitors a vehicle's position across consecutive frames to determine its actual direction of travel.

Reference Direction: Each lane on the road is configured with a predefined direction representing the legal flow of traffic.

Direction Comparison: The algorithm continuously compares the vehicle's actual movement direction against the road's valid direction by calculating the angle between them.

Violation Trigger: * If the vehicle's direction roughly aligns with the reference direction, it is traveling safely.

If the vehicle's movement significantly opposes the correct direction (e.g., driving backward or making an illegal U-turn), the system instantly flags it as a wrong-way violation.

This lightweight logical approach is perfectly optimized for the Apache Flink processing layer, ensuring ultra-low latency for the real-time streaming pipeline.

Tech Stack

  • Ingestion: MQTT, Apache NiFi
  • Message Broker: Apache Kafka
  • Processing & Computer Vision: Apache Flink, YOLOv8
  • Storage: TimescaleDB, MinIO
  • DevOps & Visualization: Docker, Grafana

Data Flow

Fog Stream Processing Layer: At the Fog Stream Processing Layer, raw data is continuously acquired from cameras, Raspberry Pi devices, and other edge components. This layer captures the initial visual feeds and immediately pushes the payloads into an MQTT transmission stream for downstream ingestion.

Data Orchestration Layer: The Data Orchestration Layer utilizes Mosquitto, Apache NiFi, and Apache Kafka to manage the massive data flow. These technologies work seamlessly together to reliably ingest, validate, orchestrate, and distribute the high-throughput event payloads across the architecture.

Real-time Data Processing Layer: Within the Real-time Data Processing Layer, YOLO and Apache Flink are deployed to consume the orchestrated data. This layer executes centralized computer vision tasks to detect vehicles and applies stateful stream processing to generate actionable traffic metrics for continuous monitoring.

Data Storage Layer: The Data Storage Layer is purposefully designed to handle different data modalities efficiently. TimescaleDB is implemented to persist structured time-series data such as traffic metrics, while MinIO serves as a scalable object store to securely archive unstructured image evidence.

Data Visualization Layer: Finally, the Data Visualization Layer employs Grafana to provide comprehensive operational oversight. By continuously querying the storage engines, this layer renders intuitive monitoring dashboards that display live traffic conditions and metrics in real-time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors