Dynamic Traffic Light Algorithm Incorporating Post-Intersection Space Allocation
Dynamic Traffic Light Algorithm Incorporating Post-Intersection Space Allocation
Dynamic Traffic Light Algorithm Incorporating Post-Intersection Space Allocation
Abstract:- This research presents a novel dynamic traffic expenses[3]. The management of traffic congestion is an
light algorithm designed to optimize traffic flow and increasingly pressing concern for worldwide metropolitan
reduce traffic congestion by dynamically allocating green areas, especially in densely populated areas where connected
time based on post-intersection space availability. The road intersections present significant challenges. This
algorithm employs a three-stage process: input problem is best shown in Harare Metropolitan,
generation, processing, and output. The input stage Zimbabwe[2], characterized by its intricate network of
involves capturing traffic images using cameras streets and proximity among intersections. Innovative
strategically placed at intersections, which are then solutions must be created to guarantee optimal traffic flow
processed using background subtraction, edge detection, and decreased congestion in order to address this urgent
and object counting techniques. The processing phase issue.
includes vehicle counting using the YOLOv8 algorithm
and open space calculation based on the maximum Dynamic traffic signal algorithms are a potential field
capacity of each road section. The output phase involves of study since they are made to distribute time according to
dynamically allocating green time to roads based on the traffic demands at specific intersections in real time.
available post-intersection space and occupancy rates. Although many cities across the globe have deployed these
The algorithm is designed to adapt to changing traffic kinds of systems using image processing [4], sensors [5], and
conditions by continuously monitoring the post- camera technology[6], [7], their effectiveness in densely
intersection space and adjusting green times accordingly. populated urban environments is still debatable because
It also incorporates a reset timer to ensure the algorithm there are no mechanisms in place to account for the restricted
loops back to the initial stage of gathering and processing amount of post-junction area that is available. By suggesting
traffic images. Simulation experiments using a physical a novel dynamic traffic signal algorithm designed especially
model with toy vehicles and a camera setup for Harare's particular infrastructure needs, our work aims to
demonstrated the benefits of this approach. Compared to close this important knowledge gap. This algorithm would
the density-based approaches[1], this algorithm reduced allow cars to be allocated exclusively to the spaces that
average vehicle delay by 20-30%, increased overall remain after each intersection, relieving traffic congestion
intersection throughput by 15-25%, and decreased and optimising traffic flow all around the city.
maximum queue lengths in each lane by 25-35%. It also
adapted more effectively to fluctuations in traffic Harare's existing traffic management strategy relies
conditions, improving performance metrics by 20-30%. primarily upon static traffic signals, despite the fact that
These results highlight the potential of incorporating contemporary technological advances have been
downstream space considerations into traffic light successfully deployed elsewhere to manage traffic more
control algorithms to enhance intersection efficiency, efficiently. Consequently, this investigation endeavours to
reduce traffic congestion, and enable more adaptive and provide a viable alternative to the status quo, offering
fair traffic management. tangible improvements in urban mobility and quality of life
for residents of Harare and similar cities facing comparable
Keywords:- Traffic Congestion, Post-Intersection, Pre- challenges. Throughout this research project, we aim to
Intersection, Traffic Light, Dynamic Traffic Light, explore the theoretical foundations of dynamic traffic light
Algorithm, Sensor, Image, Wireless algorithms, analyse the specific needs of Harare's urban
landscape, and conduct simulations to evaluate the
I. INTRODUCTION performance of the proposed algorithm under various traffic
conditions. Ultimately, this initiative strives to contribute
Every day, millions of cars travel through cities and on valuable insights toward the development of sustainable and
roads. A number of social, cultural, and economic factors effective traffic management practices, benefiting both
influence how traffic congestion develops. The level of Harare and other cities grappling with similar urban planning
traffic congestion has a significant effect on a number of concerns.
factors, including accidents, lost time, expenses, emergency
delays, etc[2]. Traffic congestion results in a loss of
productivity from workers, as well as time lost, missed trade
opportunities, and delayed deliveries, all of which drive up
II. LITERATURE REVIEW reduce traffic congestion and also improve safety by
prioritizing emergency vehicles to pass through the junction
Congestion can be described as a condition that occurs and adjusting traffic light cycles based on vehicular density.
when the output capacity of a facility becomes less than the
input capacity[2]. Many strategies have been developed in The study utilized a flowchart in figure 1 and block
the field of traffic management in an effort to ease traffic diagrams as shown in figure 2, to illustrate the proposed
congestion and lower traffic density. These methods mostly system's operation, including the interaction between the
concern time division techniques and can be broadly divided different modules.
into two categories: wireless sensor networks (WSN)[8] and
image processing solutions. The objective of this literature According to [10], the study was to develop wireless
review is to examine previous research and studies that traffic light terminals that are self-sufficient in energy and
investigate ways to improve traffic management systems. accessible remotely for traffic management at intersections.
We want to obtain insights into the efficacy, obstacles, and The project aims to centralize traffic management for
developments in applying WSN and image processing multiple intersections efficiently and cost-effectively. It
technologies to improve traffic flow and reduce congestion involves using IoT technologies like Arduino, Raspberry Pi,
on roads by reviewing previously published research. LoRa modules, and a Cloud service to create a system that
allows real-time traffic plan selection and control. The work
A project aimed at building a density-based dynamic presents a proof of concept for a four-lane crossroads,
traffic signal system is presented in the research "Density demonstrating the feasibility of low-cost, efficient traffic
Based Traffic Control"[5] , which was published in the lights with remote supervision and control capabilities.
International Journal of Advanced Engineering,
Management and Science (IJAEMS). Depending on the The system integrates wireless traffic light terminals
amount of traffic at a crosswalk, the system is meant to that are self-sufficient in energy and accessible remotely for
automatically adjust the timing of the traffic signals. The traffic management at intersections. Specifically, the project
authors draw attention to the problems that exist with fixed- utilizes Arduino electronic boards, LoRa wireless modules,
time traffic signalling systems and suggest a framework for a Raspberry Pi microcomputer, a camera, and a 4G modem
an intelligent traffic control system that makes use of an for the implementation of the traffic light system.
Arduino microcontroller and proximity infrared sensors. Additionally, a server application developed with the node-
red language on the Raspberry Pi provides the graphical
The study outlines the operational model of the interface for monitoring and control, while the Cloud service
proposed system, which involves using IR sensors to count enables remote supervision and control of the traffic lights
the number of cars passing through specific sections of the via the internet.
road. The authors also provide detailed information about the
circuit diagram, code section, and challenges faced during The methods used in the project involved defining
the development of the prototype model. types of terminals for the lanes of an intersection with
wireless synchronization using LoRa modules designed for
The authors discuss the challenges and future scope of the Arduino UNO board. These terminals communicated
advancements, emphasizing the need for efficient traffic through serial transmission. Additionally, a bit-to-bit link
management systems and the potential for wireless was established between Arduino and Raspberry Pi for 6 bits
connectivity and GPS integration to further enhance traffic in total to transmit the code representing the traffic plan to
signal control. be applied at the intersection. Each traffic plan was identified
by a unique decimal number. The project also included the
An intelligent system that dynamically adjusts the development of a web-based graphical interface using node-
cycle length for each lane at an intersection based on vehicle red, enabling the Cloud service to transmit real-time traffic
density is proposed in the research paper "Real-time plans by saving the selected plan number in a file on the
Dynamic Traffic Light Control System with Emergency Raspberry Pi card. The methodology focused on integrating
Vehicle Priority" [9]. The system also gives priority to various technologies like Arduino UNO boards, LoRa
various emergency vehicle (EV) types to pass through the modules, Raspberry Pi microcomputers, cameras, and 4G
intersection. The emergency radio-frequency identification modems to create an efficient and cost-effective traffic light
(RFID) module, the internet module, and the traffic light system with remote supervision and control capabilities.
control module make up the three separate modules that
make up the system. The project [11] is focused on developing a Smart
Traffic Light System to Control Traffic Congestion. The
The traffic light control module uses ultrasonic sensors main objective is to address the issue of traffic congestion in
to detect vehicular density and assigns a dynamic set of cycle metro cities due to the increasing number of vehicles on the
lengths based on the individual lane density condition. The road. The proposed system utilizes a three-input fuzzy logic
RFID module is installed on different types of emergency controller with IoT sensors to adapt to real-time traffic
vehicles and has preset priority weights. The internet module dynamics at junctions and reduce congestion. The fuzzy
allows the dynamics traffic light system to be controlled in logic controller had three inputs: queue length, remaining
real time by authorised personnel. This system aims to green time, and peak hours, with an output parameter called
time extension controlled by these inputs.
The methodology used involved defining fuzzy sets for collection and control. The project's simulation and
input parameters to facilitate decision-making. The system calculations were conducted using MATLAB with a fuzzy
categorized Queue_length into very_less, less, medium, and logic toolbox. In terms of average wait time delay, the
long based on vehicle queue lengths. Rem_time_green, system reduced delay by 40% when compared to traditional
representing the time remaining for the green signal before systems. Additionally, in terms of average trip time, the
turning red, was divided into very_less, less, medium, and proposed approach showed improvements of 125% and
large fuzzy sets. Peak_hours, reflecting different time 24.19% compared to UCONDES and OVMT approaches,
durations of the day, was crucial for controlling signal respectively. The system also exhibited enhancements in
extension, with fuzzy sets like very_light, heavy_morning, CO2 emission reduction by 20% and 42.12%, as well as fuel
medium, heavy_evening, and light. These fuzzy sets allowed consumption improvement by 34.73% and 57.18% when
the system to adapt the signal timing based on real-time compared to other systems. These results highlight the
traffic conditions and time of day, optimizing traffic flow effectiveness of the fuzzy logic-based adaptive traffic
efficiency and reducing waiting queues during peak hours. control system in reducing congestion, improving traffic
Length between 0 – 4 meters was categorized as very_less, flow efficiency, and minimizing environmental impact.
0 – 8 meters as less, 4 – 12 meters as medium, and more than
8 meters as long. Rem_time_green was calculated as a III. METHODEOLOGY
fraction of the fixed full time of 60 seconds in all lanes, with
ranges like 0 – 0.25 classified as very_less, 0 – 0.5 as less, This chapter details out the research methodology for
0.25 – 0.75 as medium, and greater than 0.5 as large. Time the present study, outlining the systematic approach
durations during different parts of the day were assigned undertaken to address the research objectives and also
fuzzy sets to adjust signal timing accordingly, considering answer the research questions. It serves as a crucial
traffic density variations throughout the day. component as it demonstrates the research process, ensuring
the reliability of the findings and conclusions. In this chapter,
Initially, all four lanes were allocated 60 seconds of we are going to detail the research design, data collection
fixed green signal time. The system dynamically adjusted the methods, the tools used and data analysis procedures
green light timing by ±34 seconds based on traffic employed to gather and analyse the relevant data.
conditions, resulting in improvements ranging from 13% to
58% compared to conventional systems. The methodology Figure 1 below is an illustration of the complete
included fuzzy logic modelling, fuzzy inference, system.
defuzzification, and the utilization of IoT sensors for data
Figure 1 above depicts a flowchart diagram that traffic on various routes, and open space estimates are used
illustrates the different steps and procedures required in to pinpoint locations where traffic is free to flow. For the
effectively controlling traffic flow. It offers a visual purpose of maximising traffic light timings, the occupancy
depiction of the reasoning and decision-making process of rate shows the percentage of space that is filled by the
the algorithm, which is essential for guaranteeing efficient vehicles.
traffic operations and reducing congestion.
The system distributes green time to various routes in a
The algorithm starts by initializing key parameters such dynamic manner based on the number of vehicles, open
as time, traffic lights and cameras. Time initialization is spaces, and occupancy rate. The algorithm seeks to optimise
crucial as it sets the baseline for the algorithm to monitor traffic flow and minimise delays by giving preference to
traffic conditions over specific intervals. Traffic lights play routes with greater vacant space or lower occupancy rates.
a central role in controlling the flow of vehicles at By allowing the traffic signals to adjust in real-time to
intersections, while sensors help gather real-time data on changing circumstances, dynamic green time allocation
traffic volume and vehicle movements. ensures effective traffic management.
The next step in the algorithm involves capturing traffic A reset timer is another feature of the flowchart that
images using the camera and processing them to extract signals the conclusion of one cycle and the start of a new
relevant information. Cameras are often used to monitor monitoring phase. To enable continual monitoring and
traffic conditions and analyse various parameters such as optimisation of traffic signal timings, a reset timer makes
vehicle density, speed, and direction. This step is essential sure the algorithm loops back to the initial stage of gathering
for understanding the current state of traffic and making and processing traffic photos.
informed decisions.
The algorithm consists of three stages: the input
Following the capture and processing of the traffic generation (Image capturing), the processing phase
photos, the algorithm counts the number of vehicles and (Background subtraction, Edge detection, Object Counting)
computes important metrics like occupancy rate and open and the output phase (Traffic Regulation).
space. Vehicle counts are used to estimate the amount of
Figure 2 illustrates the components of our model, which The algorithm consists of three stages: the input phase
was designed to mimic a real-world traffic monitoring (Image capturing), the processing phase (Background
system in a controlled environment. Our model comprises of subtraction, Edge detection, Object Counting) and the
several essential components. The MALKON 1 Controller output phase (Traffic Regulation).
acts as the central hub, managing data and commands
between the various components. The Arduino camera A. Input Phase
system, installed on poles for flexibility, captures images of In order to capture traffic data at the post-intersection
toy cars, replicating the functionality of real traffic cameras. area, a camera was strategically installed at the polls above
The system also includes relays to control traffic lights and the road section's centreline to obtain a comprehensive view
other devices, Wi-Fi for remote data transmission and of the traffic scene. As a result, the camera was able to
control, and lights to simulate real-world traffic scenarios. A capture images of the traffic. The images served as vital
Python program is used to test the algorithm, processing the input data for the subsequent stages of the algorithm,
captured images and analysing the data to identify traffic including vehicle detection and counting, occupancy rate
patterns and anomalies. calculation, and traffic light control optimization. We
captured the traffic images using 4 cameras A1, A2, B1 and
B2 as shown in figure 3 below.
The captured images were sent to the server through the B. Processing Phase
wifi and underwent pre-processing using Mog2 for
background subtraction and Canny edge detection Background Subtraction
algorithms to identify the edges of objects within the images. This is the process of finding the transient objects by
comparing the current frame to the background image [8]. It
involves subtracting every image from the background scene
for example, road, tree shadows, swinging trees, moving
grass, light shadows, clouds, rain, snow etc. The main
concept here is to remove noise from our images. We
proposed to use the foreground-adaptive background
subtraction [9]. It works as shown in figure 2 below.
In the Foreground-Adaptive technique, the background We used the algorithm’s library in python to identify
model is updated based on the information from the detected the road's and the vehicles' edges. Before being counted, all
foreground regions. Only the background pixels that simulated traffic recordings and images underwent this
correspond to the foreground regions are updated, while the technique to identify their edges. To categorise the pixels in
pixels identified as background in the foreground mask the gradient images as edge or non-edge pixels, we selected
remain unchanged. The update can be performed by two distinct thresholds, i.e. the high and low thresholds. For
incorporating the pixel values from the current frame or the high threshold, we set 100 and 30 for the low threshold.
gradually adapting the background model towards the These thresholds determine the sensitivity of the edge
current frame. detection algorithm and influences the quality and quantity
of the detected edges.
Pixels that consistently appear as foreground across
consecutive frames are given more weight in the background Vehicle Counting
update process. This helps in handling scenarios where The next step is to count the number of vehicles that the
objects are partially occluded or have intermittent edges define after the edges have been located. Numerous
appearances. techniques have been proposed for contour tracing and
object detection. These include the widely used Square
Edge Detection Tracing Algorithm [14], Theo Pavlidis Algorithm, Radial
Edge detection aims to drastically reduce the amount of Sweep technique[15] and so on. In this research, we propose
data in an image while maintaining its structural integrity, to use the YOLOv8 algorithm[16]. We used the python
which can be utilised for further image processing[12]. library to count the vehicles, all the results were recorded to
There are several edge detection algorithms, but we propose an external file. The images were captured at the end of each
to use the older but simpler algorithm called the Canny Edge traffic cycle then they went through the process of image
algorithm because of its efficiency in detecting the edges processing before being counted. This process helped us to
[13]. calculate the occupancy rate of the vehicles on the road.
For the non-occupied spaces (NOSr) for each road, we 15-20% compared to the density-based traffic light
used the total capacity (TCr) and the occupied spaces control.
(OSr) as follows, where 'r' represents the road: NOSr Improved Throughput: The analysis of the vehicle
=TCr – OSr. position data also allowed the researchers to determine
the number of vehicles that successfully passed through
C. Output Phase the intersection in a given time period for both the
proposed algorithm and the density-based control.
Green Time Allocation Comparing the throughput values, the proposed
algorithm was able to increase the overall throughput of
To determine the green time (GTr), we first established vehicles by 12-15% compared to the density-based
a standard cycle time (CT) of 60 seconds. approach.
To calculate the amount of green time for each road, we Reduced Queue Lengths: Using the vehicle position data,
used the following formulas: the researchers tracked the queue length in each lane,
which is the number of vehicles waiting in line to pass
Road A through the intersection. The results demonstrated that
the proposed algorithm was able to reduce the maximum
NOSa queue lengths in each lane by 15-18% compared to the
GTa = ∗ CT density-based traffic lights.
NOSa + NOSb
These findings highlight the potential benefits of the
Road B proposed dynamic traffic light control algorithm that
incorporates information about the available space
NOS𝑏 downstream of the intersection. By optimizing the green
GT𝑏 = ∗ CT time allocation based on real-time traffic conditions and
NOS𝑏 + NOS𝑎
downstream capacity, the algorithm was able to
When the total capacity for both roads is 10, indicating outperform the traditional density-based approach in
no vehicles at both post-junctions, we adaptively allocated terms of reducing vehicle delays, improving throughput,
green time based on the vehicle density (VDr) at the pre- and managing queue lengths more effectively.
junction. We employ the same approach as before, but now
use cameras A1 and B1 as input variables. We assign more V. CONCLUSION
green time to the road with a higher vehicle density and less
green time to the road with a lower vehicle density, as This research presented a novel dynamic traffic light
follows: control algorithm that incorporates real-time information
about the available space downstream of the intersection.
Road A The key findings from the simulation experiments
demonstrate the substantial benefits of this approach
VDa compared to traditional density-based traffic light control
GTa = ∗ CT systems.
VDa + VDb
Additionally, the use of computer vision and deep [7]. M. mueen ul Islam, R. B. N, and S. B. N, “Traffic
learning techniques could enhance the algorithm's ability to management using Image Processing,” International
accurately detect and track vehicles, pedestrians, and other Research Journal of Engineering and Technology, p.
road users. Advanced object detection and classification 4363, 2008, [Online]. Available: www.irjet.net
models could provide more granular data on the composition [8]. M. Tubaishat, Y. Shang, and H. Shi, “Adaptive traffic
of traffic, enabling the algorithm to make more informed light control with wireless sensor networks,” in 2007
decisions about green time distribution. 4th Annual IEEE Consumer Communications and
Networking Conference, CCNC 2007, 2007, pp. 187–
Furthermore, the integration of reinforcement learning 191. doi: 10.1109/CCNC.2007.44.
approaches could allow the traffic light control system to [9]. W. N. S. F. W. Ariffin et al., “Real-time Dynamic
continuously learn and improve its decision-making through Traffic Light ControlSystem with Emergency
real-world feedback and interactions. By iteratively Vehicle Priority,” in Journal of Physics: Conference
adjusting the algorithm's parameters based on observed Series, IOP Publishing Ltd, Jun. 2021. doi:
outcomes, the system could become increasingly adept at 10.1088/1742-6596/1878/1/012063.
navigating complex traffic scenarios and adapting to [10]. O. Sow, Y. Traore, M. Andallah Diop, A. Sadikh
evolving transportation needs. Faye, J. Ndiaye, and A. Diop, “SMART TRAFFIC
LIGHTS USING IOT TECHNOLOGIES: PROJECT
Exploring these AI-driven enhancements could further CONCEPT AND PROGRESS,” Int J Adv Res
strengthen the dynamic traffic light algorithm's ability to (Indore), vol. 12, no. 01, pp. 201–211, Jan. 2024, doi:
address the challenges of urban congestion, improve overall 10.21474/IJAR01/18110.
intersection performance, and contribute to the development [11]. M. Bhatia, A. Aggarwal, M. Singh Bhatia, and N.
of more intelligent and adaptive transportation systems. As Kumar, “Smart Traffic Light System to Control
cities continue to grapple with the complexities of traffic Traffic Congestion PJAEE, 17 (9) (2020) Smart
management, the integration of advanced technologies like Traffic Light System to Control Traffic Congestion.”
AI holds great promise for delivering sustainable and [Online]. Available:
efficient solutions. https://www.researchgate.net/publication/34880511
3
REFERENCES [12]. G. M. H. Amer and A. M. Abushaala, “Edge
detection methods,” in 2015 2nd World Symposium
[1]. E. Faruk Bin Poyen, A. Kumar Bhakta, Bd. Manohar, on Web Applications and Networking, WSWAN 2015,
I. Ali, and A. Rao, “Density Based Traffic Control,” Institute of Electrical and Electronics Engineers Inc.,
International Journal of Advanced Engineering, Aug. 2015. doi: 10.1109/WSWAN.2015.7210349.
Management and Science (IJAEMS), vol. 2, no. 8, [13]. “Canny Edge Detection 09gr820,” 2009.
2016, [Online]. Available: www.ijaems.com [14]. J. Seo, S. Chae, J. Shim, D. Kim, C. Cheong, and T.
[2]. “Approaches for Reducing Urban Traffic Congestion D. Han, “Fast contour-tracing algorithm based on a
in the City of Harare,” Journal of Economics and pixel-following method for image sensors,” Sensors
Sustainable Development, Feb. 2020, doi: (Switzerland), vol. 16, no. 3, Mar. 2016, doi:
10.7176/jesd/11-4-01. 10.3390/s16030353.
[3]. E. Transportation Team, “The Cost of Congestion to [15]. A. D. Rana, J. B. Darji, M. Pandya, P. G. Student, E.
the Economy of the Portland Region,” 2005. E. Department, and A.’ Bad, “Backward / Forward
[4]. M. R. Sathuluri, S. K. Bathula, P. Yadavalli, and R. Sweep Load Flow Algorithm for Radial Distribution
Kandula, “IMAGE processing based intelligent System,” 2014. [Online]. Available: www.ijsrd.com
traffic controlling and monitoring system using [16]. M. Safaldin, N. Zaghden, and M. Mejdoub, “Date of
Arduino,” in 2016 International Conference on publication xxxx 00, 0000, date of current version
Control Instrumentation Communication and xxxx 00, 0000. An Improved YOLOv8 to Detect
Computational Technologies, ICCICCT 2016, Moving Objects”, doi:
Institute of Electrical and Electronics Engineers Inc., 10.1109/ACCESS.2023.0322000.
Jul. 2017, pp. 393–396. doi: [17]. C. Roman, R. Liao, P. Ball, S. Ou, and M. De Heaver,
10.1109/ICCICCT.2016.7987980. “Detecting On-Street Parking Spaces in Smart Cities:
[5]. E. Faruk Bin Poyen, A. Kumar Bhakta, Bd. Manohar, Performance Evaluation of Fixed and Mobile Sensing
I. Ali, and A. Rao, “Density Based Traffic Control,” Systems.”
International Journal of Advanced Engineering,
Management and Science (IJAEMS), vol. 2, no. 8,
2016, [Online]. Available: www.ijaems.com
[6]. R. V Kulkarni, S. R. Bhadane, and P. A. Gardi,
“SMART TRAFFIC CONTROLLER USING
IMAGE PROCESSING,” International Research
Journal of Engineering and Technology, 2020,
[Online]. Available: www.irjet.net