Real Time Adaptive Traffic Control System Black Book
Real Time Adaptive Traffic Control System Black Book
(MUMBAI)
A Project Report on
Real Time Adaptive Traffic Signal Control System
Submitted by:
Certified that the project report entitled Real Time Adaptive Traffic Signal Control
With deep sense of gratitude, we would like to thanks all the people who have lit our
path with their kind guidance. We are very grateful to these intellectuals who did their best to
help during our project work.
It is our proud privilege to express deep sense of gratitude to Prof. P. T. Kadave,
Principal, K. K. Wagh Polytechnic, Nashik for his comments and kind permission to complete
this project. We remain indebted to Ms. M. S. Karande, Head of Information Technology
Department for her timely suggestion and valuable guidance.
The special gratitude goes our Internal Guide Mrs. S. S. Pathare, staff members,
technical staff members, of Information Technology Department for his expensive, excellent
and precious guidance in completion of this work. We thanks to all the class colleagues for their
appreciable help for our working project.
With various industry owners or lab technicians to help, it has been our endeavor to
throughout our work to cover the entire project work.
We also thankful to our parents who providing their wishful support for our project
completion successfully. Lastly we thanks to our all friends and the people who are directly or
indirectly related to our project work.
Name Of Student
1) Yash. R. Gulave
2) Shantanu. P. Nikumbh
3) Om. B. Thube
4) Roshan. R. Zope
INDEX
Sr.No Name Of Chapter Page no.
.
1 Abstract I
2 Introduction 1
1.1. Introduction
1.2. Background
1.3. Problem Statement
3 Literature Survey 3
7 Result 27
8 Testing 30
7.1. Introduction
7.2. Testing Methodologies
7.2.1. Unit Testing
7.2.2. Integration Testing
7.2.3. System Testing
7.3. Results and Observations
9 Costing of the Project 35
8.1. Project Type Classification
8.2. Effort Estimation
8.3. Development Time Estimation
8.4. Cost Estimation
10 Application 38
11 Conclusion 40
12 Future Scope 41
13 References 42
14 Appendix 43
List of the figures:
Fig. No. Name of figure Page no.
4.1 System Architecture of Real Time Adaptive Traffic 11
Control
4.2 Activity Diagram for “Real Time Adaptive Traffic Control 13
System”
ABSTRACT
Traffic congestion is a significant challenge in urban areas, leading to increased pollution, wasted
time, and stress for commuters. Traditional traffic control systems often lack the flexibility to adapt
dynamically to varying traffic conditions. This project presents an AI-based traffic control system
designed to optimize traffic flow and reduce congestion by leveraging real-time data and advanced
machine learning algorithms.
The system integrates data from multiple sources, including traffic cameras and sensors, to monitor
traffic density at intersections. Using AI algorithms, it analyses this data to predict traffic patterns and
dynamically adjust signal timings. This approach allows for more efficient traffic management, reducing
delays and minimizing fuel consumption. By continuously learning and adapting to changing traffic
conditions, the AI-based system provides a smart solution for modern cities looking to enhance their
traffic infrastructure.
The project's findings demonstrate that the implementation of AI in traffic management has the potential
to significantly improve road efficiency, reduce environmental impact, and contribute to safer, more
sustainable urban mobility.
Keywords:
AI-based traffic control, dynamic signal timing, real-time traffic monitoring, congestion prediction,
adaptive traffic signals, traffic density analysis, smart traffic infrastructure, sustainable urban
mobility
=========================================================================
K. K. Wagh Polytechnic, Nashik I
…………………………………………………Real Time Adaptive Traffic Signal Control.…...……
CHAPTER 1
INTRODUCTION
1.1 Introduction
Traffic congestion is a growing challenge in urban areas, leading to increased travel time, fuel
consumption, and environmental pollution. Traditional traffic signal systems operate on pre-
programmed timings that do not adapt to real-time traffic conditions, resulting in inefficient traffic flow
and unnecessary delays. With the advancement of Artificial Intelligence (AI) and computer vision
technologies, there is a need for an intelligent traffic management system that can dynamically adjust
traffic signals based on real-time traffic density.
This project, Real-Time Adaptive Traffic Signal Control, aims to optimize traffic flow by
implementing an AI-based system that analyses live traffic data using YOLO-based vehicle detection.
The system dynamically adjusts signal durations based on the number of vehicles at an intersection,
reducing congestion and improving road efficiency. By leveraging machine learning algorithms and real-
time data processing, this approach ensures a more efficient, adaptive, and intelligent traffic control
mechanism, addressing the limitations of traditional fixed-time signals.
1.2 Background
Traditional traffic control systems rely on fixed-time signal operations or sensor-based actuated
signals that do not efficiently respond to fluctuating traffic volumes. These systems are often inadequate
for handling unpredictable congestion patterns, especially in densely populated urban areas where traffic
conditions change rapidly. As a result, prolonged waiting times at traffic signals lead to increased fuel
consumption, carbon emissions, and commuter frustration.
To overcome these challenges, researchers have explored AI-driven solutions that use computer vision
and deep learning to monitor and manage traffic flow dynamically. The integration of YOLO (You
Only Look Once) object detection enables real-time vehicle detection, eliminating the need for costly
physical sensors. By processing live video feeds from traffic cameras, the system can detect vehicle
density at intersections and adjust traffic light timings accordingly.
This project proposes an AI-based approach that enhances traffic signal efficiency without requiring
additional infrastructure changes, making it a cost-effective and scalable solution. The system runs on a
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 1| 44
Page8
…………………………………………………Real Time Adaptive Traffic Signal Control.…...……
laptop, eliminating the need for embedded hardware like Raspberry Pi, and provides an efficient method
to manage urban traffic congestion using AI-powered decision-making.
Traffic congestion in urban areas is a persistent issue that affects transportation efficiency, increases
fuel consumption, and contributes to environmental pollution. Traditional traffic management systems
operate on fixed signal timings that do not account for real-time traffic fluctuations, leading to
prolonged waiting times and inefficient road usage. Existing solutions, such as sensor-based traffic
systems, often require high maintenance costs and infrastructure modifications.
This project aims to develop a real-time adaptive traffic signal control system that dynamically adjusts
signal durations based on live traffic data. By utilizing AI-driven vehicle detection and machine
learning algorithms, the system will optimize traffic flow, reduce congestion, and enhance urban
mobility. This approach provides a cost-effective and scalable solution that can be easily integrated
into existing traffic management frameworks without the need for significant infrastructure changes.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 1| 44
Page8
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
CHAPTER 2
LITERATURE SURVEY
Research Paper 1 - Deep Learning-Based Smart Traffic Light System Using Image
Processing with YOLO v7.
Authors Name: Avinash Padmakar Rangari, Ashwini Ravindra Chouthmol, Chaitanya Kadadas,
Prashant Pal, Shashank Kumar Singh.
Published in: 2022 4th International Conference on Circuits, Control, Communication, and
Computing (I4C-2022).
Description: This paper explores the application of advanced deep learning techniques, particularly
YOLO v7, to enhance traffic signal control systems. The primary focus of the research is to tackle the
persistent issue of traffic congestion by dynamically adjusting traffic lights based on real-time vehicle
detection. The YOLO v7 algorithm is employed for its high-speed and accuracy in detecting vehicles,
allowing for efficient traffic flow management.
The system integrates image processing and object detection to continuously monitor intersections,
count vehicles, and optimize signal timings. By leveraging YOLO v7’s capabilities, the proposed
solution offers a significant improvement over traditional fixed-time or sensor-based traffic light
systems, which lack real-time adaptability. The system reduces idle times at intersections and enhances
road safety, aligning with smart city infrastructure goals. The study demonstrates the effectiveness of
combining deep learning and real-time image processing for intelligent traffic control, offering a scalable
and cost-effective approach to modern traffic management challenges.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 3 | 44
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
reduced waiting times at signals. This adaptive system marks an improvement over traditional timer-
based traffic control, which is often inefficient in managing varying traffic conditions.
The research highlights the benefits of integrating AI-based solutions in traffic management,
particularly through the use of object detection algorithms like YOLOv4. The system optimizes green
light intervals based on vehicle density, improving overall traffic flow. The results show that YOLOv4,
with its fast and precise detection capabilities, enhances the vehicle throughput at intersections compared
to conventional systems. This approach helps alleviate congestion, reduces emissions, and enhances
urban mobility.
Published in: International Journal of Computer Applications (0975 – 8887) Volume 75– No.7,
August 2013
Description: The Smart Traffic Management System paper addresses the issue of urban traffic
congestion and proposes using Radio Frequency Identification (RFID) technology as a cost-effective
solution. This system involves installing RFID tags in vehicles and RFID controllers at traffic signals.
The controllers detect vehicle density and dynamically adjust traffic lights to prioritize high-traffic roads,
reducing congestion. The approach offers advantages over traditional methods, such as video analysis
and infrared sensors, by being less costly and more reliable. Additionally, the system can monitor traffic
patterns, detect speed violations, and automate toll collection. The authors highlight the system's
potential for improving traffic flow and reducing economic and environmental impacts of congestion.
Proposed Solution:
To address the challenges of urban traffic congestion, this project proposes an AI-based real-time
adaptive traffic signal control system that dynamically adjusts signal timings based on traffic density.
The solution leverages YOLO-based vehicle detection to analyze live traffic feeds from cameras placed
at intersections. The AI model processes real-time data to detect vehicle counts and predict traffic
patterns, enabling an adaptive control mechanism that optimizes signal durations.
The key components of the proposed solution include:
Real-time Vehicle Detection: Using YOLO to detect and count vehicles at intersections,
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 4 | 44
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
ensuring accurate traffic density estimation.
Dynamic Signal Adjustment: AI-based algorithms analyze traffic data and adjust signal timings
dynamically to reduce congestion and minimize waiting times.
Machine Learning Integration: The system continuously learns from traffic patterns to
improve decision-making and optimize signal durations over time.
Laptop-based Processing: The AI model runs on a laptop, eliminating the need for costly
embedded hardware while ensuring efficient computation.
Scalability and Cost-effectiveness: The solution can be integrated into existing traffic control
systems without requiring significant infrastructure modifications, making it a feasible option for
urban traffic management.
By implementing this AI-driven approach, the system enhances road efficiency, reduces fuel
consumption, lowers emissions, and improves overall urban mobility. This innovative traffic
management solution provides a smarter and more sustainable alternative to traditional fixed-time traffic
signals.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 5 | 44
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
CHAPTER 3
SOFTWARE AND HARDWARE REQUIREMENT
The software components played a critical role in ensuring accurate vehicle detection, real-time
decision-making, and efficient control of traffic signals. The development process involved the
integration of several advanced tools and technologies.
Programming Language: Python 3.x was chosen for development due to its extensive
support for AI, machine learning, and computer vision libraries.
Computer Vision Library: OpenCV was utilized for image processing and analyzing
traffic video feeds.
AI and Machine Learning Frameworks: YOLO (You Only Look Once) was implemented
for real-time object detection.
Traffic Signal Control: The Arduino IDE was used to program the microcontroller
responsible for controlling the traffic lights.
Data Processing and Storage: NumPy were used to handle traffic data and optimize AI
models.
Real-Time Processing: The system required multi-threading and asynchronous processing to
ensure efficient analysis of traffic data.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 6 | 44
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
To support real-time vehicle detection and traffic signal control, appropriate hardware components were
selected and integrated.
Processing Unit: A high-performance laptop with a dedicated GPU was required to handle AI-
based computations efficiently.
Traffic Cameras: High-resolution CCTV or IP cameras were installed at intersections to capture
live video feeds of traffic conditions.
Traffic Control Unit: An Arduino board was utilized for controlling the traffic lights based on
AI-driven decisions.
Traffic Signal Lights: LED-based traffic lights were used in both simulation and implementation
to indicate red and green signals.
Power Supply: A stable power source was ensured for all hardware components, including the
Arduino board and cameras.
The specific requirements for our Real Time Adaptive Traffic Control Signal are as followed:
Functional Requirements:
The system was designed to fulfill several key functional requirements to ensure smooth
operation and intelligent traffic management.
Real-Time Vehicle Detection: The system was capable of detecting vehicles accurately
using AI-based object detection techniques.
Traffic Density Analysis: The AI model analyzed traffic flow and measured vehicle counts
at intersections.
Dynamic Signal Adjustment: The green light duration was dynamically adjusted based on
the detected traffic density.
Machine Learning Adaptation: The AI model continuously learned from traffic patterns
to improve decision-making over time.
System Integration: The solution was designed to be compatible with existing traffic
control infrastructure without requiring significant modifications.
Fail-Safe Mechanism: Backup control mechanisms were incorporated to prevent system
failures in case of hardware or software malfunctions.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 7 | 44
…………………………………………………... Real Time Adaptive Traffic Signal Control.…...……
Non-Functional Requirements:
In addition to functional requirements, several non-functional aspects were considered to
enhance system performance and usability.
Performance: The system ensured real-time processing of video feeds and traffic data with
minimal delays.
Scalability: The architecture was designed to be scalable, allowing integration across
multiple intersections and future AI model upgrades.
Cost Efficiency: The implementation was cost-effective, as it relied on existing camera
infrastructure instead of expensive sensor-based systems.
User Experience: An intuitive dashboard or interface was considered for real-time
monitoring and manual adjustments.
Reliability: The AI model and hardware components were optimized to function reliably
under diverse urban conditions.
Security: Data integrity and security measures were enforced to prevent unauthorized
access and ensure system robustness.
Feasibility Analysis:
1. Technical Feasibility: The project leverages existing AI technologies, including YOLO for
vehicle detection, and does not require new infrastructure installations, making it technically
feasible.
2. Economic Feasibility: The system is cost-effective as it eliminates the need for additional
sensors or embedded hardware, relying instead on existing camera networks and a laptop for
processing.
3. Operational Feasibility: The project can be integrated with existing traffic management
systems with minimal modifications, ensuring ease of adoption.
4. Legal Feasibility: The system complies with traffic management regulations and does not
infringe on privacy laws as it does not collect personally identifiable information.
5. Environmental Feasibility: By optimizing traffic flow, the system reduces fuel consumption
and carbon emissions, contributing to a more sustainable urban environment.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 8 | 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
CHAPTER 4
SYSTEM DESIGN
Our traffic management system integrates multiple technologies to dynamically control traffic
signals based on real-time vehicle detection. Below is a detailed description of the key
technologies used in the project:
1. Python
Python is the primary programming language used in this project due to its extensive libraries,
ease of use, and strong support for machine learning and computer vision tasks. Python
facilitates:
Machine learning-based object detection using YOLO (You Only Look Once).
OpenCV is an open-source computer vision and image processing library that allows us to:
Perform image preprocessing such as grayscale conversion, filtering, and edge detection.
OpenCV helps in real-time traffic monitoring and improves object detection accuracy.
YOLO is a state-of-the-art deep learning-based object detection model that helps detect and
classify vehicles. We use YOLO because:
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 9 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
It identifies vehicle types (cars, buses, trucks, motorcycles) and their counts.
The system uses this information to analyze traffic density and adjust signal timings
dynamically.
The model is trained on a dataset containing images of vehicles in various traffic conditions to
improve detection efficiency.
4. Arduino Board
An Arduino board is used to control traffic lights based on data received from the Python
program. We use an Arduino Uno (or similar) microcontroller to:
Receive traffic light duration commands from the laptop (running the YOLO model).
Arduino programming is done using C++ (Embedded C) in the Arduino IDE. The code:
PySerial is a Python library that allows communication between the laptop (running YOLO)
and the Arduino board via a serial port (USB/UART). It enables:
Fig. 4.5 System Architecture of Real Time Adaptive Traffic Control System
This system architecture diagram represents a traffic management system using YOLO-based vehicle
detection to optimize traffic light timings dynamically.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 11 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
2️. Processing Layer (AI Processing Unit)
This layer processes the traffic footage and determines optimal traffic signal durations. The process
consists of the following steps:
1. Frame Extraction: Extracts individual frames from the video feed.
2. Preprocessing: Enhances image quality for better detection accuracy.
3️. Control Layer (Signal Adjustment - Arduino & Traffic Light Controller)
Arduino Controller: Receives the optimized signal timings from the Processing Layer.
Traffic Light Controller: Controls the actual traffic lights based on the commands received
from the Arduino Controller.
Data Flow: The system sends signal commands to update the traffic lights dynamically.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 12 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
4.2 Activity Diagram:
Fig 4.2 Activity Diagram for “Real Time Adaptive Traffic Control System”
The "Real-Time Adaptive Traffic Signal Control" activity diagram represents how an AI-based
system adjusts traffic signals based on real-time vehicle density detection. The process is divided into
three swim lanes, each representing a different component of the system:
o Sends the signal timing decision to the Arduino Controller for implementation.
Key Takeaways:
The system works in a continuous loop, where real-time footage is processed to dynamically
control traffic signals.
The AI unit is the decision-making center, analyzing congestion and sending timing updates.
The Arduino Controller acts as the executor, applying the changes to traffic lights.
This system helps optimize traffic flow and reduce congestion in urban areas.
Fig. 4.3 Sequence Diagram for Real Time Adaptive Traffic Control System
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 14 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
This UML sequence diagram represents the interaction between different components in a Real-Time
Adaptive Traffic Signal Control System. Here's a brief explanation:
1. Actors & Objects:
o Traffic Camera: Captures real-time traffic footage.
o AI Processing Unit: Analyzes the footage to determine traffic density and decides the
optimal signal timing.
o Arduino Controller: Controls the traffic lights based on the AI’s decision.
2. Loop Condition:
o The system operates in a loop as long as traffic monitoring is required.
3. Flow of Interactions:
o The Traffic Camera continuously sends real-time footage to the AI Processing Unit.
o The AI Processing Unit processes the footage and determines the optimal signal timing.
o It then sends the signal timing adjustments to the Arduino Controller.
Fig. 4.4.1 Level-0 DFD for Real Time Adaptive Traffic Control System
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 15 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
Fig. 4.4.2 Level-1 DFD for Real Time Adaptive Traffic Control System
Fig. 4.4.3 Level-2 DFD for Real Time Adaptive Traffic Control System
This diagram represents the Data Flow Diagram (DFD) Level 2 of your AI-driven Traffic Signal
Management System using YOLO for vehicle detection. Below is a breakdown of the components and
their roles:
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 16 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
1️. External Entities
Traffic Camera: Captures real-time traffic footage and sends it to the system.
Traffic Lights: Receives new signal timings from the system and updates red/green durations
accordingly.
Arduino Controller: Receives control commands and updates traffic light durations.
5. The AI Processing Unit receives the processed frames and sends them to Object Detection
(YOLO).
6. YOLO detects vehicles and their positions in each lane.
7. This data is then used in Count Vehicles, which determines the number of vehicles per lane.
8. The vehicle count is passed to Calculate Traffic Density, which determines congestion levels.
9. The congestion level is sent to Decide Signal Timing, which calculates the best traffic light
duration.
10. The optimized traffic light duration is sent to Generate Control Command, which converts it into
a format understandable by the Arduino controller.
11. The signal timing adjustments are sent to the Arduino Controller, which updates the traffic light
settings.
12. The Arduino Controller sends the new timing for lights to Update Traffic Signals, which modifies
red/green light durations.
13. Finally, the Traffic Lights receive the updated duration and adjust accordingly.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 17 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
3️. Key Takeaways
1. No database is used—only real-time data processing.
2. YOLO-based AI detects vehicles and calculates congestion levels.
3. Arduino Controller directly updates traffic lights.
4. Adaptive Traffic Signal Timing optimizes flow based on real-time conditions.
5.
4.5. Use-Case Diagram
Fig 4.1 Use-Case Diagram for “Real Time Adaptive Traffic Signal Control”
The diagram represents a Real-Time Adaptive Traffic Signal Control System, showing interactions
between different actors and system functions.
Actors & Their Roles:
1. Traffic Camera – Captures real-time traffic data.
2. Traffic Officer – Monitors traffic and can override signals manually.
3. AI Processing Unit – Detects vehicle density and analyzes traffic data.
4. Arduino Controller – Adjusts traffic signal timing based on AI decisions.
Key Use Cases:
Capture Traffic Camera → Collects real-time traffic images.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 18 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
Detect Vehicle Density → AI processes images to determine congestion levels.
Analyze Traffic Data → AI calculates the required signal adjustments.
Adjust Signal Timing → The system dynamically changes signal duration.
Monitor Traffic Condition & Override Signal Manually → The traffic officer can intervene if
needed.
System Purpose:
The system optimizes traffic flow by automatically adjusting signal timings based on real-time vehicle
detection, reducing congestion and improving efficiency.
This UML state diagram represents the state transitions of the traffic management system. It describes
how the system moves between different states during its operation.
Fig. 4.6. State Diagram for Real Time Adaptive Traffic Control System
This state diagram represents the operational flow of Real Time Adaptive Traffic Control system, which
dynamically adjusts traffic light timings based on real-time vehicle detection. Below is an explanation
of each state:
States and Transitions
1. Start State:
o The system begins its operation.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 19 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
2. Idle State:
o The system is waiting for new traffic data.
o If the system needs to stop, it transitions to the End State.
3. Processing State:
o Once traffic data is received (e.g., vehicle detection from YOLO), the system processes
the captured footage.
4. Decision-Making State:
o The system analyzes the density of vehicles at each signal.
o It determines the optimal timing for traffic signals based on congestion.
Flow Explanation
1. The system starts and enters the Idle State.
2. It moves to the Processing State when new traffic footage is available.
3. The system analyzes traffic density in the Decision-Making State.
4. It updates the traffic signal timings in the Signal Update State.
5. After updating, the system returns to the Idle State to continue the process.
6. If required, the system stops operation and transitions to the End State.
7.
4.7. Imported Modules:
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 20 of 44
……………………………………………………Real Time Adaptive Traffic Signal Control …...……
Explanation of Imported Modules
1. time – Provides functions for handling time-related tasks like delays and timestamps.
2. numpy – A powerful library for numerical computing, handling arrays and mathematical
operations.
3. ultralytics (YOLO) – Used for object detection with YOLO (You Only Look Once) models.
4. cv2 (OpenCV) – A computer vision library for image and video processing.
5. cvzone – Simplifies OpenCV tasks, making object tracking and detection easier.
6. math – Provides mathematical functions like trigonometry, logarithms, and power calculations.
7. sort – Likely refers to the Simple Online and Realtime Tracker (SORT), used for object tracking.
8. serial – Enables communication with serial ports, useful for interfacing with microcontrollers
like Arduino
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 21 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CHAPTER 5
PROJECT CODE
import time
import numpy as np
import cv2
import cvzone
import math
import serial
cap = cv2.VideoCapture(0)
cap.set(3, 1280)
cap.set(4, 720)
model = YOLO("../Yolo-Weights/yolov8n.pt")
# Tracking Instance
active_ids = {}
total_count = 0
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 22 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
# Class Names
classNames = ["person", "bicycle", "car", "motorbike", "aeroplane", "bus", "train", "truck", "boat"]
signal_time = min(count * 4 + BASE_TIME, 60) # Convert count to signal duration with base time
print(f"Lane {lane}: Sending signal duration: {signal_time} seconds to Arduino") # Debug print
def process_camera():
signal_active = False
signal_start_time = 0
while True:
if not success:
break
# Process frame
for r in results:
boxes = r.boxes
cls = int(box.cls[0])
current_class = classNames[cls]
else:
results_tracker = tracker.update(detections)
current_ids = set()
current_ids.add(obj_id)
total_count += 1
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 24 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
active_ids[obj_id] = 0
else:
active_ids[obj_id] = 0
inactive_ids = [id_ for id_, frames in active_ids.items() if id_ not in current_ids and frames > TTL]
del active_ids[id_]
active_ids[id_] += 1
if signal_active:
if (current_lane == 1) :
else :
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 25 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
if not signal_active:
signal_active = True
print(f"Signal time over for Lane {current_lane}, switching to next lane.") # Debug print
break
# Start processing
process_camera()
# Release resources
cap.release()
cv2.destroyAllWindows()
arduino.close()
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 26 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CHAPTER 6
Result
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 27 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 29 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CHAPTER 7
TESTING
7.1 Introduction
Testing is a crucial phase in the development of any system to ensure that it functions as intended. This
chapter discusses the various testing methodologies applied to the AI-Powered Traffic Signal
Management System, ensuring its accuracy, reliability, and efficiency. The testing process includes unit
testing, integration testing, system testing, and validation testing to verify the performance of each
component.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 30 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
1. Analyze
vehicle density. Green light
2. Adjust green duration
should be Signal timings
Traffic Signal light duration
TC003 adjusted changed as Pass
Control
accordingly. dynamically expected.
based on
3. Change traffic.
signals based on
real-time data.
1. Send signal
commands to
Arduino
Arduino. should receive Signals
Communication 2. Verify LED commands changed as
TC005 Pass
with Arduino and change per system
signal response. signals commands.
3. Confirm real- accordingly.
time
synchronization.
1. Stop the
YOLO model. System should
shut down System shut
System 2. Disconnect
TC006 gracefully down Pass
Shutdown
Arduino safely. without successfully.
errors.
3. Power down
the system.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 31 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
7.2.3 System Testing
System testing was conducted to evaluate the overall performance and functionality of the system in a
real-world scenario. The following aspects were examined:
Performance Testing: Measured the time taken to process images and adjust signals.
Stress Testing: Tested the system under high traffic conditions.
Reliability Testing: Ensured the system consistently detected and responded to traffic changes.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 32 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
TC003 Traffic Light 1. Simulate Green light Signal Pass
Control different duration timings
Based on vehicle dynamically changed as
Vehicle densities at adjusts based on expected.
Count intersections. vehicle count.
2. Verify that Red light
green light activates when
duration is no vehicles are
adjusted detected
accordingly.
3. Check if red
light is
activated for
low or no
traffic.
TC004 System 1. Measure YOLO processes Responds Pass
Response YOLO frames in real- within
Time and processing time (>15 FPS acceptable
Latency time per frame recommended). delay
(FPS). Traffic lights
2. Calculate the respond within
delay in signal an acceptable
changes after delay (<2 sec).
vehicle Model loads
detection. within an
3. Evaluate acceptable delay
overall system at initial state
performance (<120 sec)
under high No crashes or
traffic excessive delays
conditions.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 33 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
TC005 System 1. Simulate a System System restart Pass
Resilience to power failure restarts and initialize
Failures and restart the without data correctly
system.
loss or without
2. Check if
crashes. crashes.
YOLO and
YOLO and
Arduino
Arduino
reinitialize
reinitialize
properly.
3. Verify system correctly.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 34 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CHAPTER 8
COSTING OF THE PROJECT
COCOMO Model-Based Cost Estimation for Real Time Adaptive Traffic Control
System
The COCOMO (Constructive Cost Model) classifies software projects into three types:
Since the project involves real-time vehicle detection and dynamic traffic control, it falls under the
Embedded category.
2. Effort Estimation
E = a × (KLOC)b
where:
E = Effort in person-months
Based on the project scope, the estimated size is 200 lines of code.
E = 3.6 × (200/1000)1.20
E = 3.6 × 0.1648
E = 0.59328 person-months
E ≈ 1️ person-months
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 35 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
T = c × (E)d
where:
T = 2.5 × (0.59328)0.32
T = 2.5 × 0.8461
T = 2.1152 Months
T ≈ 3️ Months
4. Cost Estimation
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 36 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
Resistors (1️kΩ, 1️kΩ, 2️2️0Ω (Carbon Film 10 pcs ₹2️ per ₹2️0
2️2️0Ω, etc.) Resistors) resistor
Breadboard 830 Tie-Point Solderless 1 ₹2️00 ₹2️00
Breadboard
USB Cable for Type A to B (for 1 ₹1️00 ₹1️00
Arduino programming)
Logitech Camera USB Webcam (720p or 1 ₹1️2️00 ₹1️2️00
higher)
Mini Traffic Signal Small prototype for demo 1 ₹500 ₹500
Model
Total Cost ₹2️,970
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 37 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CHAPTER 9
1. Real-Time Traffic Control: Adjusts green light durations dynamically based on vehicle density,
reducing congestion.
2. Urban Traffic Optimization: Enhances traffic flow in busy city areas by prioritizing lanes with
higher vehicle density.
3. Smart City Integration: Can be integrated into a broader smart city infrastructure for data-driven
traffic management.
4. Fuel and Emission Reduction: Reduces idle time at signals, lowering fuel consumption and
vehicle emissions.
5. Public Transport Efficiency: Can improve bus and taxi travel times by dynamically managing
traffic flow.
6. Accident Prevention: Reduces the risk of accidents caused by unnecessary waiting times and
sudden signal changes.
1. Efficient Traffic Flow: Minimizes waiting time by dynamically adjusting green light durations.
2. No Need for Physical Sensors: Uses YOLO-based vehicle detection via cameras, reducing
hardware costs.
4. Adaptable to Different Locations: Can be used in different cities by adjusting detection models
and timing rules.
5. Data-Driven Decision Making: Can collect and analyze traffic data for future planning and
improvements.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 38 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
6. Scalable and Expandable: Can be integrated with AI-based traffic prediction models for better
long-term traffic management.
1. Dependence on Camera Quality: Poor-quality cameras or bad weather conditions (fog, rain) may
reduce detection accuracy.
3. Latency Issues: Processing video feeds in real-time may introduce delays, affecting traffic flow
decisions.
4. Limited to Camera Coverage Areas: Vehicles outside the camera's field of view will not be
detected, reducing efficiency in some cases.
5. Power and Internet Dependency: Requires a stable power supply and internet connection if
cloud-based data processing is used.
6. Initial Setup Cost: Requires installation of cameras, proper calibration, and software setup, which
can be costly for large-scale deployment.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 39 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
CONCLUSION
The Real Time Adaptive Traffic Control System successfully demonstrates an intelligent approach to
reducing urban traffic congestion by dynamically adjusting signal durations based on real-time vehicle
detection. By utilizing computer vision instead of traditional sensors, the system offers a cost-effective,
scalable, and adaptable solution for modern cities.
This project highlights the potential of AI-driven traffic control, minimizing unnecessary waiting times,
improving fuel efficiency, and reducing pollution. The system can be further enhanced by integrating
machine learning models for predictive traffic analysis, incorporating IoT-based connectivity, or
expanding to handle emergency vehicle prioritization.
Although challenges such as hardware limitations, weather conditions, and real-time processing delays
exist, continuous advancements in AI and computing power can further refine the system’s performance.
Overall, this project serves as a significant step towards developing a smarter, more efficient, and
sustainable urban traffic management system.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 40 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
FUTURE SCOPE
The Real Time Adaptive Traffic Control System has significant potential for future enhancements,
making it a key component of smart city infrastructure. One major improvement could be the integration
of advanced AI algorithms, including deep learning and reinforcement learning, to analyze historical
traffic data and predict congestion trends. Additionally, incorporating IoT-enabled traffic sensors and
V2I (Vehicle-to-Infrastructure) communication would enhance real-time traffic monitoring and
management. The system can also be expanded to prioritize emergency vehicles such as ambulances and
fire trucks, ensuring they receive green signals when needed. A mobile and web-based dashboard for
real-time monitoring by traffic authorities would further improve control and decision-making.
To enhance scalability, the system can be expanded to manage multiple intersections simultaneously,
creating a city-wide intelligent traffic network. Hardware optimization using edge computing devices
like Raspberry Pi or NVIDIA Jetson could reduce dependency on high-power systems, making the
solution more cost-effective and deployable in various locations. Furthermore, incorporating weather-
resistant detection techniques, such as infrared cameras or LiDAR sensors, would enable effective
operation in low-visibility conditions like fog and heavy rain.
Another crucial enhancement is traffic violation detection, where the system can identify rule violations
such as signal jumping, wrong-way driving, and overspeeding, integrating with automated fine
collection systems using license plate recognition. Additionally, the collected traffic data can assist urban
planners in designing better road infrastructure, optimizing highway expansions, flyovers, and
alternative routes. With these advancements, the YOLO-Based Traffic Management System can
significantly contribute to efficient urban mobility, reduced congestion, lower fuel consumption, and
improved road safety, making it an essential technology for the future of smart cities
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 41 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
REFERENCES
[1] Avinash Padmakar Rangari, Ashwini Ravindra Chouthmol, Chaitanya Kadadas, Prashant Pal,
Shashank Kumar Singh – “Deep Learning-Based Smart Traffic Light System Using Image
Processing with YOLO v7-2022” - 4th International Conference on Circuits, Control,
Communication, and Computing (I4C-2022).
[2] Boppuru Rudra Prathap, Boppana Venkateswarlu, and Sriharsha Tippa – “AI-Based YOLO V4
Intelligent Traffic Light Control System” - Journal of Automation, Mobile Robotics & Intelligent
Systems (JAMRIS), Volume 16, Issue 4, 2022.
[3] Ninad Lanke, Heetal Koul – “Smart Traffic Management System pp: 06” –
International Journal of Computer Applications (0975 – 8887) Volume 75– No.7, August 2013
Bibliography:
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 42 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
Appendix
A. System Specifications
Hardware Requirements:
o Laptop with minimum Intel i5/i7 processor, 16GB RAM, and NVIDIA GPU (RTX
2060 or higher preferred)
Software Requirements:
o Python 3.9+
Model Training: Pre-trained YOLOv8 model fine-tuned with real-world traffic data
3. Traffic Signal Control: Arduino integrated with a laptop to control signals based on YOLO’s
vehicle count.
4. Testing & Optimization: System tested in simulated environments and optimized for real-time
performance.
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 43 of 44
…………………………………………………Real Time Adaptive Traffic Control System…...……
D. Challenges Faced
AI – Artificial Intelligence
=========================================================================
K. K. Wagh Polytechnic, Nashik Page 44 of 44