Traffic Density Estimation Using Image Frames in Python

Year : 2026 | Volume : 13 | Issue : 02 | Page : 38 45
By

Hamid Boshara,

Awab Mohamed,

Mohammad Shoaib Khan,

Anurag Dwivedi,

  1. , Student, Department of Electrical & Electronic Engineering, Galgotias University, Greater Noida, Uttar Pradesh, India, ,
  2. , Student, Department of Electrical & Electronic Engineering, Galgotias University, Greater Noida, Uttar Pradesh, India, ,
  3. , Student, Department of Electrical & Electronic Engineering, Galgotias University, Greater Noida, Uttar Pradesh, India, ,
  4. , Assistant Professor , Electrical & Electronic Engineering, Galgotias University, Greater Noida, Uttar Pradesh, India, ,

Abstract

Traffic congestion is a critical challenge in modern urban environments, leading to significant delays, environmental pollution, and increased accident rates. With the rapid growth of vehicle populations in metropolitan areas worldwide, the need for intelligent and automated traffic monitoring systems has become increasingly urgent. Traditional monitoring approaches, such as inductive loop detectors and manual surveillance, are limited in scalability, deployment cost, and adaptability to dynamic traffic scenarios. This paper presents a real-time Traffic Density Estimation System that leverages Artificial Intelligence (AI) and Computer Vision (CV) techniques to address these limitations effectively. The proposed system processes traffic video streams frame by frame, employs the YOLOv8 deep learning model for vehicle detection, counts detected vehicles in each frame, and classifies observed traffic conditions into three distinct levels: Low, Medium, and High. The system provides live visual analytics including bounding boxes, vehicle counts, and density classifications overlaid directly on the processed video feed. The methodology encompasses seven sequential stages: video input collection, frame extraction, vehicle detection via the YOLOv8 nano model, vehicle counting, density estimation through predefined thresholds, traffic condition classification, and real-time overlay rendering using OpenCV. The system is implemented entirely in Python, utilizing widely available open-source libraries, and requires no specialized hardware infrastructure, making it accessible for deployment in resource-constrained smart city environments. The classification framework assigns one of three color-coded condition labels—green for Low, yellow for Medium, and red for High—enabling immediate human interpretation of traffic states. Experimental results demonstrate that the system accurately detects vehicles of multiple classes—including cars, trucks, buses, and motorcycles—in real time, with vehicle detection confidence scores frequently exceeding 0.70. The system exhibits robust performance across diverse traffic scenarios, from open highway conditions to dense urban intersections. These findings confirm that the integration of deep learning-based object detection with lightweight threshold-based classification offers a viable and scalable solution for smart city traffic monitoring and management applications.

Keywords: Traffic density estimation, computer vision, YOLO, OpenCV, vehicle detection, smart city, deep learning

[This article belongs to Trends in Transport Engineering and Applications ]

How to cite this article: Hamid Boshara, Awab Mohamed, Mohammad Shoaib Khan, Anurag Dwivedi. Traffic Density Estimation Using Image Frames in Python. Trends in Transport Engineering and Applications. 2026; 13(02):38-45.
How to cite this URL: Hamid Boshara, Awab Mohamed, Mohammad Shoaib Khan, Anurag Dwivedi. Traffic Density Estimation Using Image Frames in Python. Trends in Transport Engineering and Applications. 2026; 13(02):38-45. Available from: https://journals.stmjournals.com/ttea/article=2026/view=257917

References

  1. Zanella A, Bui N, Castellani A, et al. Internet of things for smart cities. IEEE Internet of Things Journal. 2014; 1(1): 22–32p.
  2. Redmon J, Divvala S, Girshick R, et al. You only look once: Unified, real-time object detection. In: Proceedings IEEE/CVF CVPR; 2016: 779–788p.
  3. Jocher G, Chaurasia A, Qiu J. Ultralytics YOLOv8. Version 8.0.0. Ultralytics Inc.; 2023.
  4. Bradski G. The OpenCV Library. Dr. Dobb’s Journal of Software Tools. 2000; 25(11): 120–125p.
  5. Roess RP, Prassas ES, McShane WR. Traffic Engineering. 4th Edn. Pearson Education; 2011.
  6. Wang CY, Bochkovskiy A, Liao HYM. YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors. In: Proceedings IEEE/CVF CVPR; 2023: 7464–7475p.
  7. Lin TY, Goyal P, Girshick R, et al. Focal loss for dense object detection. In: Proceedings IEEE/CVF ICCV; 2017: 2980–2988p.
  8. Wojke N, Bewley A, Paulus D. Simple online and realtime tracking with a deep association metric. In: Proceedings IEEE ICIP; 2017: 3645–3649p.
  9. Treiber M, Kesting A. Traffic Flow Dynamics: Data, Models and Simulation. Springer; 2013.
  10. Zhang J, Wang FY, Wang K, et al. Data-driven intelligent transportation systems: A survey. IEEE Transactions on Intelligent Transportation Systems. 2011; 12(4): 1624–1639p.

Regular Issue Subscription Original Research
Volume 13
Issue 02
Received 13/06/2026
Accepted 03/07/2026
Published 06/07/2026
Publication Time 23 Days


Login

My IP

PlumX Metrics

Support