نظام ذكي لعدّ المركبات حسب المسارات باستخدام الذكاء الاصطناعي
AI-Based Vehicle Lane Counting System
A real-time vehicle detection and lane counting system powered by YOLO and
Supervision. The system tracks vehicle movement across lanes, counts vehicles
crossing virtual boundary lines or polygon zones, and generates annotated
video output for traffic analytics and monitoring.
Project Description
This project implements an intelligent vehicle lane counting system using
YOLO-based object detection and Supervision tracking utilities. It accurately
detects, tracks, and counts vehicles crossing defined lanes or zones in real
time, making it ideal for traffic flow analysis and smart transportation
systems.
The system applies ByteTrack-based tracking to maintain persistent object IDs
and prevent duplicate counts. Visual annotations such as bounding boxes, lane
lines, and counters are rendered using Supervision, while annotated videos are
saved for later review.
Core Objectives
- 🚗 Detect and track multiple vehicles using YOLO deep learning models.
- 📊 Count vehicles crossing virtual lane lines or polygon zones.
- 🔁 Ensure accurate counting using persistent ByteTrack IDs.
- 🧩 Support multiple configurable detection zones.
- 💾 Save annotated video outputs for documentation.
- ⚙️ Enable modular configuration via
config.yaml.
Key Features
- ✅ Real-time vehicle detection using YOLO.
- ✅ Smart lane and zone-based counting.
- ✅ Support for custom polygon regions.
- ✅ Accurate tracking with ByteTrack.
- ✅ Visual overlays using Supervision annotators.
- ✅ Automatic annotated video recording (.mp4).
- ✅ Fully configurable via YAML files.
System Architecture
- Input video from camera or video file.
- YOLO detects vehicles in each frame.
- ByteTrack assigns persistent IDs.
- Zone analysis counts vehicles crossing lanes.
- Supervision annotates boxes, lines, and counters.
- Annotated video is saved and optionally displayed.
Technologies Used
- 🧠 Python 3.x
- 🧠 YOLO (Ultralytics)
- 🧠 ByteTrack (via Supervision)
- 🧠 OpenCV & NumPy
- 🧠 Supervision
- 🧠 YAML Configuration
Use Cases
- 🚦 Traffic flow and lane density analysis.
- 🛣️ Highway toll and gate monitoring.
- 🏙️ Smart city traffic systems.
- 🧾 Traffic data logging and reporting.
- 🧠 Academic and research applications.
Possible Enhancements
- ☁️ Live dashboards with Flask or Streamlit.
- 📊 CSV / database logging of counts.
- 🛰️ IoT and cloud analytics integration.
- 🔊 Traffic anomaly alerts.
- 🧩 Multi-class vehicle differentiation.
- 📡 Web-based remote monitoring.
Conclusion
The Vehicle Lane Counting System using YOLO and Supervision delivers an
accurate and scalable solution for real-time traffic monitoring. By combining
deep learning detection, persistent tracking, and zone-based analytics, it
enables smart transportation insights for cities, highways, and research
environments.