Abstract:
Traffic congestion is a critical challenge in urban environments, particularly in densely populated regions like Pakistan, where static, time-based traffic signals fail to adapt to real-time traffic conditions. These traditional systems lead to increased delays, long vehicle queues, wasted fuel, and elevated emissions. To overcome these issues, Smart Traffic Light System (STLS) utilizes deep learning-based object detection and a dynamic green time algorithm to optimize traffic flow at intersections. Our system focuses on real-time video-based traffic analysis at four-way intersections to dynamically allocate green signal time according to vehicle density. Initially, publicly available datasets were evaluated, but due to limited relevance to local traffic conditions, a custom dataset comprising approximately 3,000 images was collected across various intersections in Rawalpindi and Islamabad. This dataset includes five vehicle classes: car, bike, bus, truck, and van. After pre-processing and annotation, multiple YOLO models were trained on this dataset, achieving detection accuracies between 91% and 93%. A custom green time algorithm was developed to process real-time vehicle counts from each lane and allocate signal time proportionally, eliminating bias and minimizing average vehicle wait times. The complete system was implemented using Raspberry Pi 4 and cameras deployed at intersections to demonstrate low-cost, scalable deployment. The proposed solution significantly improves intersection throughput, reduces idle times, and shows strong potential for adoption in smart city infrastructure. Its adaptability, sustainability, and practical efficiency make it a compelling alternative to legacy traffic control systems in developing countries.