Mini Project Report 1
Mini Project Report 1
BELAGAVI, KARNATAKA-590018
BACHELOR OF ENGINEERING
In
ELECTRONICS AND COMMUNICATION ENGINEERING
Submitted by
ARUN KUMAR D P [4MG21EC004]
PAVAN B M [4MG21EC021]
PRAJWAL C J [4MG21EC024]
PRAJWAL M P [4MG21EC025]
Under the guidance of
Mr. Hemanth Kumar M S
Assistant Professor
Dept. of ECE, GMIT
2023-24
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
2023-24
CERTIFICATE
Certified that the Project work entitled “Traffic Signal Control Based on Vehicle Density” is
carried out by, Arun Kumar D P(4MG21EC004), Pavan B M (4MG21EC021), Prajwal C J
(4MG21EC024), Prajwal M P(4MG21EC025). Bonafide students of G MADEGOWDAINSTITUTE
OF TECHNOLOGY, Bharathinagara in partial fulfillment for the award of Bachelor of Engineering in
ELECTRONICS AND COMMUNICATION ENGINEERING of the Visvesvaraya Technology
University, Belagavi, during the year 2023- 2024. It is certified that all corrections/suggestion indicated
for Internal Assessment have been incorporated in the Report deposited in the departmental library. The
project report has been approved as satisfies the academic requirements in respect of project work
prescribed for the Bachelor of Engineering Degree.
2
ACKNOWLEDGEMENT
Any Project work completed successfully gives a great sense of achievement and
satisfaction. It would remain incomplete if the people who made it possible and whose
constant guidance and encouragement to without mention.
First and foremost, First and foremost, I would like to express my sincere gratitude
to our beloved Principal, Dr. CHANDAN B R for providing us a congenial environment
for engineering studies and constant support.
We express our heart filled thanks to, Dr. NUTHAN A C, Associate Professor and
Head of the Department of Electronics and communication Engineering GMIT,
Bharathinagara, Mandya, whose guidance and support goes beyond works.
We gratefully acknowledge the help & cooperation offered by all the teaching and
non- teaching staff members of Department of Electronics and Communication, GMIT,
Bharathinagara, Mandya.
Above all, we would like to thank our parents and friends for their cooperation and
God, the Almighty, for his blessings and strength.
Managing the increasing number of vehicles in urban areas presents a persistent challenge.
Traffic narrowing disrupts daily routines, elevates stress levels, and contributes to higher
carbon emissions, impacting the environment. With the rise in population, megacities need to
catch up on transportation activities. An intelligent traffic management system is essential to
monitor traffic density continuously and take proactive measures. Although there are
designated lanes for different vehicle types, wait times at traffic signals remain unchanged. To
address this, we propose leveraging artificial intelligence to gather real-time images from
signals and improve the current system. Our methodology uses the YOLO image processing
technique to assess traffic density accurately. YOLO is brilliant in detecting multiple vehicles,
enhancing the system's effectiveness in managing traffic jams. Intelligent monitoring
technology integrates a signal-switching algorithm at intersections to optimize time distribution
and mitigate traffic congestion. This approach aims to reduce vehicle waiting times, improving
overall traffic flow.
CONTENTS
1. INTRODUCTION ...................................................................................................... 1
3.2 Requirements............................................................................................................... 12
3.3 Implementation............................................................................................................ 13
4.3 Conclusion…………………………………………………………………………… 25
4.4 References…………………………………………………………………………… 27
LIST OF FIGURES
CHAPTER 1
1. INTRODUCTION
Traffic congestion is a widespread issue in urban areas, contributing to increased travel times, higher
fuel consumption, and elevated air pollution levels. The root of this problem often lies in the
inefficiencies of traditional traffic signal systems, which operate on fixed time intervals. These
systems fail to adapt to the fluctuating real-time traffic conditions, resulting in suboptimal traffic flow
and prolonged waiting times at intersections. The need for a more intelligent and adaptive traffic
management solution has never been more pressing.
Conventional traffic signal systems follow preset timing schedules that do not consider the actual
traffic volume at any given time. These fixed schedules can lead to significant inefficiencies,
particularly during peak hours when traffic volumes are high. Vehicles often experience long waiting
times at red lights, even when the crossroad is relatively empty. Conversely, during off-peak hours,
green lights may remain active longer than necessary, contributing to unnecessary idling and
increased emissions. The consequences of traffic congestion extend beyond just driver frustration.
Prolonged idling times result in higher fuel consumption, leading to increased costs for drivers and
more significant emissions that harm the environment. Additionally, traffic congestion can impede the
timely delivery of goods and services, negatively impacting economic productivity. The overall
quality of life for urban residents can also suffer due to the stress and time lost in traffic jams.
To address these challenges, there is a growing need for smart traffic control systems that can
dynamically adjust signal timings based on real-time traffic conditions. These systems leverage
advanced technologies such as image processing, machine learning, and the Internet of Things (IoT)
to gather and analyse data from various sources, including cameras, sensors, and GPS devices. A
traffic signal control system that adapts to the density of vehicles can significantly improve traffic
flow and reduce congestion. By using real-time data, these systems can make informed decisions
about signal timings, ensuring that green lights are allocated where they are most needed. This
adaptability helps in minimizing idle times at intersections, reducing fuel consumption, and lowering
emissions. Moreover, smoother traffic flow can enhance the overall commuting experience, making
urban travel more efficient and less stressful.
schedules or rudimentary sensing methods, which can lead to suboptimal traffic flow, increased travel
times, and environmental impact.
In Paper [2] Mohammad Shahab Uddin, Ayon Kumar Das, Md. Abu Taleb, describes A Review on
Traffic congestion is a daily occurrence in most urban areas of Bangladesh now a day. In the last 10
years the scenario has worsen due to rapid increase of vehicles and insufficient roads to accommodate
them. This paper describes a method of real time area-based traffic density estimation using image
processing for intelligent traffic control system. Area occupied by the edges of vehicles will be
considered to estimate vehicles density. Calculating the areas of different live roads, the system will
automatically estimate the traffic density of each road which will help to determine the duration of
each traffic light. An intelligent traffic signal control system with the proposed traffic density
estimation technique will be far better than the conventional timer-based system of Bangladesh. The
main contribution of this research lies in the development of a new technique that detects traffic
density according to the area of the edges of vehicles for controlling traffic congestion. Specialized
algorithm, morphology and images captured with cameras will be used for the detection of traffic
density for the intelligent traffic control system.
In Paper [3] K.Vidhya, A.Bazila Banu, describes A Review on The project is designed to develop a
density based dynamic traffic signal system. The signal timing changes automatically on sensing the
traffic density at the junction. Traffic congestion is a severe problem in many major cities across the
world and it has become a nightmare for the commuters in these cities. Conventional traffic light
system is based on fixed time concept allotted to each side of the junction which cannot be varied as
per varying traffic density [1]. Junction timings allotted are fixed. Sometimes higher traffic density at
one side of the junction demands longer green time as compared to standard allotted time. The image
captured in the traffic signal is processed and converted into grayscale image then its threshold is
calculated based on which the contour has been drawn in order to calculate the number of vehicles
present in the image. After calculating the number of vehicles, we will come to know in which side
the density is high based on which signals will be allotted for a particular side. Raspberry pi is used as
a microcontroller which provides the signal timing based on the traffic density.
In Paper [5] Snehal Kale*1, Swapnali Bakal*2, Gauri Kokate*3, Sejal Pol*4, Anuradha Virkar
describes A Review on Managing the increasing number of vehicles in urban areas presents a
persistent challenge. Traffic narrowing disrupts daily routines, elevates stress levels, and contributes
to higher carbon emissions, impacting the environment. With the rise in population, megacities need
to catch up on transportation activities. An intelligent traffic management system is essential to
monitor traffic density continuously and take proactive measures. Although there are designated lanes
for different vehicle types, wait times at traffic signals remain unchanged. To address this, we propose
leveraging artificial intelligence to gather real-time images from signals and improve the current
system. Our methodology uses the YOLO image processing technique to assess traffic density
accurately. YOLO is brilliant in detecting multiple vehicles, enhancing the system's effectiveness in
managing traffic jams. Intelligent monitoring technology integrates a signal-switching algorithm at
intersections to optimize time distribution and mitigate traffic congestion. This approach aims to
reduce vehicle waiting times, improving overall traffic flow.
In Paper [6] Abu Salman Shaikat, Rumana Tasnim, Farhan Mahbub, Rezwan-us Saleheen, Rayhan
Mahmud, Tohorul Islam, describes A Review on Traffic jam is one of the greatest problem of
Bangladesh. It affects mostly on its capital city, Dhaka, where density of population is second highest
among the world. One of the major reason for occurring traffic jam is inaccuracy of the use of traffic
signal. This paper introduces an intelligent traffic control system for four nodes traffic system. This
system is entirely controlled by the use of image processing and artificial intelligence techniques.
Image processing leads for detecting the density of vehicles by using Haar Cascade method, whereas
artificial intelligence helps to modify the timing of traffic signal accurately time by time. These
process held automatically and police can monitor from police box all over the time by computer.
Moreover, in case of emergency, a manual system is introduced, which can support traffic police to
turn the system to manual and operate the timing manually. Finally, traffic data is collected from road
and prove the effectiveness of proposed system. This system will support as an extremely effective,
self-coordinated and self-organized traffic control appliance.
In Paper [7] Vaibhav A. Suryawanshi, Sarthak B. Shah, Sagar B. Pokharkar, describes A Review on
Objective a novel real-time traffic control system which can easily keep traffic in control using image
processing techniques is presented. In this method, a webcam is used in each stage of the traffic light
in order to take pictures of the roads where traffic is bound to occur. Count of vehicles in these images
is calculated using image processing tools in “open cv” and different timings are allocated according
to the count along with a green signal for vehicles to pass. The images capture by the camera is
converted into the grey image and then it is given to the raspberry pie , where it analyze the image
and decides whether the traffic density is high or not and according to this the timer of the signal is
decided. In this project we have used the prototype like the green and red signals are represented
using LEDs and the decrementing timer for the green sign.
CHAPTER 2
2.1 objective
The primary objective of this project is to design and implement a vehicle density-based traffic
control system using Python. Specifically, the project aims to:
• Design and simulate a traffic control algorithm that adjusts traffic signal timings dynamically
based on current density levels.
• Evaluate the effectiveness of the proposed system in improving traffic flow and reducing
congestion.
1. Research and Analysis: Review existing literature on traffic control systems and related
technologies.
2. System Design: Design the architecture and components of the traffic control system,
emphasizing modularity and scalability.
3. Implementation: Develop algorithms for vehicle detection, tracking, density calculation, and
traffic control using Python libraries such as OpenCV and TensorFlow.
4. Simulation: Create a simulated environment to test the effectiveness of the system under
various traffic conditions.
5. Evaluation: Analyse simulation results to assess the performance of the system in terms of
traffic flow optimization and congestion reduction.
By addressing these aspects in the introduction, readers gain a clear understanding of the project's
motivation, objectives, and scope. This sets the foundation for subsequent sections that delve deeper
into the technical details and outcomes of your vehicle density-based traffic control system.
Traffic signal
timer is updated
CHAPTER 3
3.1 Algorithm Explained
3.1.1 Imports and Global Variables
This snippet initializes the TrafficLightSimulator class, which sets up the GUI for the traffic signal
simulation. It defines the root window title and initializes the traffic light states (green, yellow, and
red) with default durations. A dictionary, light_colors, maps each traffic light state to its
corresponding color and duration.
In this section, the code sets up the GUI components. A Tkinter canvas is created to draw the traffic
lights, represented as circles initially colored grey. Labels are added to display the current traffic light
state and a countdown timer. The initial state is set to 'red', with the corresponding label and timer
displayed.
This snippet contains the logic for starting and updating the timer. The start_timer method initializes
the timer based on the current light's duration. The update_timer method decrements the timer every
second and updates the label. When the timer reaches zero, the change_light method is called to
transition to the next traffic light state.
This snippet sets up the vehicle detection function. YOLO (You Only Look Once) is loaded using pre-
trained weights and configuration files. The COCO dataset class names are read from a file. A video
capture object is initialized to read frames from a video file or capture device.
In this part, the code processes each frame of the video for vehicle detection. It captures frames,
prepares them for YOLO input, and processes YOLO's output to identify objects. Detected objects are
filtered based on confidence levels, and bounding box coordinates are computed for identified
vehicles.
This snippet applies non-maxima suppression to eliminate redundant bounding boxes, counts the
vehicles, and updates the global vehicle_count variable. The detected vehicles are highlighted with
bounding boxes on the frame, which is then displayed with the vehicle count. The loop continues until
the video ends or the user presses 'q' to exit.
The final snippet initiates the vehicle detection thread and starts the Tkinter GUI for the traffic light
simulator. The vehicle detection function runs in the background, continuously updating the vehicle
count, while the GUI operates concurrently, adjusting traffic light timings based on real-time vehicle
density. This integration ensures dynamic traffic signal control, enhancing traffic flow and reducing
congestion.
3.2 Requirements
3.2.1 Hardware Requirements:
1. Computer/Laptop:
o A computer or laptop with a decent processor (e.g., Intel i5 or higher) and at least 8GB
of RAM to handle video processing and the GUI.
2. Camera:
o A USB camera or any other video capture device for real-time traffic footage (optional
if using a pre-recorded video file).
3.2.2 Software Requirements:
1. Operating System:
o Windows, macOS, or Linux.
2. Python:
o Python 3.x installed on the system.
3. Libraries and Packages:
o OpenCV (cv2): For video capture and processing.
o NumPy (numpy): For numerical operations.
Visual studio includes a code supporting IntelliSense (the code completion component) as
well as code refactoring. The integrated debugger works both as a source-level debugger
and a machine-level debugger. Other built-in tools include a code profiler, designer for
building GUI applications, web designer, class designer, and database schema designer. It
accepts plug-ins that expand the functionality at almost every level including adding
supportfor source control systems (like Subversion and Git) and adding new toolsets like
editors and visual designers for domain-specific languages or toolsets for other aspects of
the software development lifecycle (like the Azure DevOps client: Team Explorer).
Visual Studio supports 36 different programming languages and allows the code editor and
debugger to support (to varying degrees) nearly any programming language, provided a
language-specific service exists. Built-in languages include C, C++, C++/CLI, Visual
Basic.NET, C#, F#, JavaScript, TypeScript, XML, XSLT, HTML, and CSS. Support for
other languages such as Python, Ruby, Node.js, and M among others is available via
plug- ins. Java (and J#) were supported in the past. The most basic edition of Visual Studio,
the Community edition, is available free of charge. The slogan for Visual Studio Community
edition is "Free, fully-featured IDE for students, open-source and individual developers". As
of 8 November 2021, the current production-ready Visual Studio version is 2022, with older
versions such as 2013 and 2015 on Extended Support, and 2017 and 2019 on Mainstream
support.
2. Internet Connection:
o Required to download YOLO files and Python libraries.
3.2.4 Setup:
1. Python Environment:
o Install Python 3.x and set up a virtual environment (optional but recommended).
2. Library Installation:
o Use pip to install necessary libraries:
bash
Copy code
pip install opencv-python numpy
3. YOLO Setup:
o Download YOLOv3 weights, configuration file, and COCO class names, and place
them in the project directory.
3.3 Implementation
3.3.1 System Architecture Overview
The architecture of the vehicle density-based traffic control system is designed to be modular and
scalable, allowing for flexibility in implementation and future expansions. The key components of the
architecture include:
• Data Collection Module: Responsible for gathering real-time traffic data from sensors,
cameras, or other sources. This module captures information such as vehicle counts, speeds,
and positions.
• Vehicle Detection and Tracking Module: Utilizes computer vision techniques, possibly
leveraging frameworks like OpenCV or TensorFlow, to detect and track vehicles in the
monitored area. It identifies vehicles and their movements to provide input for the density
calculation module.
• Density Calculation Module: Processes the data collected from the vehicle detection module
to compute traffic density metrics. This module may employ algorithms to estimate the
number of vehicles per unit area or lane occupancy rates to determine congestion levels.
• Traffic Control Algorithm Module: This core module uses the computed density metrics to
adjust traffic signal timings dynamically. Algorithms could range from simple threshold-based
controls to more sophisticated predictive models based on historical data and machine learning
techniques.
• User Interface: Provides a user-friendly interface for system configuration, monitoring, and
visualization of traffic conditions and control decisions. It allows traffic engineers or
administrators to view real-time data, adjust parameters, and analyse system performance.
3. Integration:
o A threading mechanism allows the vehicle detection and GUI simulation to run
concurrently, ensuring real-time updates to traffic light timings based on vehicle
density.
• Feature Extraction: Deriving relevant features from raw data, such as vehicle speed, size,
and direction of travel, to facilitate subsequent analysis and decision-making.
• Data Fusion: Integrating data from multiple sources to enrich the information available for
traffic density estimation and control algorithms.
• Background Subtraction: This method identifies moving objects by comparing each frame
of a video feed with a reference background frame. Pixels that significantly differ from the
background are classified as foreground objects (vehicles).
• Haar Cascade Classifiers: Utilizes machine learning models trained to detect specific object
classes (such as vehicles) by analysing image features in a cascading manner.
• Deep Learning Approaches: Convolutional Neural Networks (CNNs), particularly models
like YOLO (You Only Look Once) or SSD (Single Shot Multibox Detector), are powerful for
real-time object detection, including vehicles, in video streams.
• Optical Flow: Analyses motion patterns in consecutive video frames to track moving objects,
including vehicles, based on the displacement of image features.
• Delay Reduction: Assess reductions in delay experienced by vehicles due to optimized signal
timings.
• Throughput Improvement: Evaluate increases in the number of vehicles passing through
intersections during peak periods.
CHAPTER 4
4.1 Testing
Testing is crucial to ensure that both the vehicle detection system and the traffic light simulation
function correctly and interact as expected. The testing process involves several stages, including unit
testing, integration testing, and system testing. Below are the key testing steps for this project:
4.2 Results
The results section of the traffic signal control project provides a detailed overview of the system's
performance and effectiveness based on the implemented features and testing outcomes. This section
highlights the system’s ability to detect vehicles, adjust traffic light timings, and integrate these
functionalities to manage traffic efficiently.
Observations:
• The system demonstrated flexibility in adjusting traffic light timings based on vehicle density,
effectively managing traffic flow. User feedback indicated that the GUI was intuitive and
provided clear visibility of the current traffic light status and remaining time.
Observations:
• The system performed well under various traffic conditions, including peak traffic hours and
low-traffic periods. The integration ensured that traffic light timings were dynamically
adjusted, contributing to smoother traffic flow and reduced congestion.
4.3 Conclusion
4.3.1 Summary of Findings
Begin by summarizing the key findings and results obtained throughout your project:
• Effectiveness of the System: Recap how your vehicle density-based traffic control system
performed in optimizing traffic flow and reducing congestion compared to traditional
methods.
• Performance Metrics: Highlight improvements in travel time, delay reduction, throughput,
and other relevant metrics observed during simulations or real-world testing.
• Integration with Smart City Initiatives: Explore opportunities to integrate your system with
broader smart city frameworks, leveraging IoT, big data analytics, and connectivity for
enhanced traffic management.
• Field Testing and Validation: Recommend conducting field tests and validation studies to
further validate the system's performance and usability in real-world urban environments.
References