AI Based Traffic Light Control and Ambulance Detection Using Python

DOI : 10.17577/IJERTCONV12IS03072
Download Full-Text PDF Cite this Publication
Text Only Version


AI Based Traffic Light Control and Ambulance Detection Using Python

Mrs.Deepana M.E., Assistant Professor,

Computer Science And Engineering, Shree Venkateshwara Hi Tech

Engineering College, Gobichettipalayam.

Email :

Ms.D.Glaramettilda,Studen of Computer Science And Engineering, Shree Venkateshwara Hi Tech Engineering College, Gobichettipalayam.


Ms.M.Karthika,Student of Computer Science And Engineering,

Shree Venkateshwara Hi Tech Engineering College, Gobichettipalayam.

Ms.V.Pavithra,Student of Computer Science And Engineering,

Shree Venkateshwara Hi Tech Engineering College, Gobichettipalayam.

Abstract- Traffic light control system is widely used to control the flow of road junction.Currently, most of the traffic light system used pre-time and count down timers to control traffic flow. Thus, there is a need of adaptive traffic signals which are able to do real time monitoring to control traffic light signal based on traffic density.

This project proposed an adaptive traffic light control system that uses image processing and image matching technique in controlling the traffic in an effective manner by taking images of each lane at a junction.

Keywords Cyberbullying detection”, “Machine learning (ML)”, “Deep learning (DL)”, “Natural language processing (NLP)”.


Traffic Congestion and traffic monitoring is one of the important problems all over the world. In this way, a traffic cycle will be established which will control the traffic. Traffic lights operate in a systematic way which causes a lot of delays for the drivers in some cases. Drivers can be unnecessary waiting for the time period. Our project to overcome the problem. An intelligent Hand Held Traffic light controller system using mobile application traffic police can be handled the traffic easy and Simple way.


    Machine learning (ML) comes under the most booming topic which is artificial intelligence as a branch and also mentions the capability of delivering unmanned or automatic extensive learning which improves the outcomes coming from experiences by detecting the patterns. This technology uses current algorithms as well as datasets in order to develop any computer programs which provide sufficient solutions for the specific problem mentioned and that program will use those algorithms and dataset to learn without any human intervention. The learning process gets

    started with observing in data given, then identifying the patterns present in the data next creating progress findings by using those algorithms in next coming years based on the identified preexisted patterns. The main aim of using machine learning is that it can makeany electronic device not only computers learn automatically without having any interference from humans or to change results correspondingly. Machine learning algorithms can analyze huge amounts of data which results in high accuracy in a small amount of time.


    RL is based on Markov decision process (MDP) and learns to maximize long-term returns. In a fully observable environment, an agent observes a state st

    S at time t and performs an action at A according to a policy function (a |s). Then the next state of the agent is st+1 according to a state transition probability function pt (st+1 |st, at), and the environment gives a reward rt = r (st, at,st+1). Suppose that an episode has P n steps, the agent obtains a return Ut = n =t t r at time t, where

    [0, 1) is a discount factor. An action-value function, i.e., Q function Q (st, at), is the expectations of return Ut for future states and actions at the times. In practice, the agent does not know Rt and St+1 and can only obtain the optimal Q function by estimation and Monte Carlo approximation. RL training is based on the experience et = (st, at, rt, st+1) in a data-driven way. The Q-learning algorithm is one of the most basic RL methods. Q function is fitted by the model Q with parameters, such as Q table, linear regression (LR) , and deep neural network (DNN). According to the behavior policy, the agent collects the training data and stores it in the experience replay buffer in the quadruple form of et= (st, at, rt, st+1). We use a common behavior policy named -greedy policy.

    ON There are many action settings, such as the duration of the current signal, the next phase of the traffic light, and holding or changing the current phase. We choose the second set and define each local action as a possible phase or a combination of the red and green phases at the intersection. This setting is more flexible and suitable for ATSC. According to the current intersection traffic, an agent performs the best phase from all possible phase set Ai. B. STATE The setting of a state is significant to describe the traffic condition at an intersection. We define the local state as follows: st, i = {waitt [li], wavet [li]}liLi where li is an incoming lane of intersection i and Li denotes all the incoming lanes of intersection i. wait describes the waiting time for the first vehicle in the lane, and wave represents the total number of vehicles in each incoming lane within 50m of the intersection. A lane Area Detector in SUMO is used to capture state information, which ensures the real-time ATSC. C. REWARD The definition of reward is vital in RL performance. The goal of an agent is to maximize long-term returns. Combined with the definition of reward in [3] and [4], a new reward function is defined as rt, i = X liLi pressuret+1t [li] + a · waitt+1t [li] (19) where a [veh/s] is a trade-off coefficient, and pressure is the evaluation metric based on the vehicle queue length and can be simply measured. The reward is post-decision, and both pressure and wait are calculated at time t+1t. This kind of reward setting is closely related to state and action, which can directly reflect the degree of traffic congestion and vehicle delay time at the intersect.


    Optical systems are based on utilizing coded infrared (IR) transmission between the EV transmitter and the IR-receiver that can be validated against unauthorized use. In GPS- based systems, the EV location estimation can be improved in open areas without obstructions (e.g. high building) where the trilateration by the GPS satellites is possible and the multipath effect can be reduced. This requirement makes the use of GPS method is also restricted to some places.


    We will create an android application for the ambulance. Through that application the ambulance driver can register the case of emergency. When the ambulance will be approaching the signal the image processing will then determine from where is the ambulance coming. It will stop performing the normal operation of the signals and will stops all the signals leaving the one through which the ambulance needs to pass. We will connect the traffic signals control system through your application so that the entries should be stored in the database. Also connect the image processing to the traffic signals. We need to also learn how to manipulate the traffic signals. We plan the development this project in below mentioned modules. Module 1: Admin Module 2: Driver/Ambulance Module 3: Controlling Signals 3.1 Module 1: Admi Module This module is fully responsible for providing the route to the drivers of the ambulance. Also it will monitor and track the ambulance from where it is arriving and where it is going. 3.2 Module 2: Driver/Ambulance This module is responsible for sending the request to the admin to get permission to reach to the location. As soon as the driver sends request he will have to wait for the route. After the route is decided, the driver will then send request to the cloud database to create green corridor.

    3.3 Module 3: This module is a module dedicated to the manipulation of the signals. As soon as the cloud gets the request, the cameras will be activated for image processing. Once the ambulance is spotted then it will verify and provide a green corridor. The above figure depicts the flow of the project. The admin that is the official person from the hospital, who wants to send an organ for transplant will send the notification to the driver. The driver will receive the notification and will select path of the source and the destination. The admin will send a message to the traffic control department that will provide green corridor to the ambulance after receiving its location. The driver will be able to track the ambulance as to get assurance that the ambulance will reach its proper location.


    Algorithm 1 Multi-Agent Q-Learning for ATSC Input: , , T, |B|, . Output: {i}iV.

    1. initialize s0, 0, t 0, k 0, B = ;
    2. while stop condition is not reached do
    3. for i V do
    4. perform at,i from t,i ;
    5. receive rt,i and st,i ;
    6. end for
    7. B B st,i, at,i,rt,i,st+1,i , t,i iV ;
    8. t t + 1, k k + 1;
    9. if t = T then
    10. initialize s0, 0, t 0;

      It is the source of real time traffic data which is representing the current traffic situation in the area. There are many sources and methods suggested by researchers from where we can obtain this data like placing sensors and cameras at the junctions to capture the traffic flow and applying algorithm to obtain the intensity of the traffic but all these approaches are so much cost effective and complex to implement (Castillo et al. 2015). Also the accuracy of this data is the most important ingredient of our proposed

    11. end if
    12. if k = |B| then
    13. for i V do
    14. estimate R , i, B;
    15. estimate R , i, B;
    16. calculate yt, i and L (i);
    17. update i with · L (i);
    18. end for
    19. B , k 0;
    20. end if
    21. end while

    solution. Google Maps APIs is the easy and reliable source from where we can drive the traffic intensity for our optimal distribution (Fairfield and Rumson 2011).Travel time in current and future traffic is now available through the Distance Matrix and Directions APIs of Google Maps which is requested by server after every threshold time. This threshold time is configurable as it is inversely proportional to network communication cost.


    Fig no.1 Vehicle Detection

    One common approach to vehicle detection is through the use of object detection algorithms. These algorithms are trained on large datasets of annotated images, where vehicles are labeled with bounding boxes indicating their locations within the image. Examples of popular object detection algorithms include YOLO (You Only Look Once), SSD (Single Shot MultiBox Detector), and Faster R-CNN (Region-based Convolutional Neural Network).

    These algorithms work by analyzing the features present in the image and predicting the likelihood of different objects, including vehicles, being present at various locations. They utilize deep learning architectures, such as convolutional neural networks (CNNs), to learn and extract meaningful features from the input images, which are then used to make predictions about the presence and location of vehicles.



    The web dashboard module serves as the primary interface for users to interact with the adaptive traffic light control system. Accessible through a web browser, this module offers a user-friendly platform for monitoring and managing traffic flow at road junctions. Users, which may include traffic engineers, city planners, or transportation authorities, can access the dashboard from any internet- enabled device, providing flexibility and convenience. Upon logging in, users are greeted with a comprehensive overview of the traffic conditions, including real-time data on vehicle density, traffic flow rates and current signal timings and also facilitates the monitoring the performance of the system.


    The module responsible for gathering data for training and operating the adaptive traffic light control

    system plays a critical role in ensuring the system’s effectiveness and accuracy. At its core, this module involves the collection of comprehensive datasets that encapsulate various aspects of traffic behavior and patterns at different road junctions.One of the primary data types collected is images or videos of traffic scenes captured from cameras strategically positioned.


    The module responsible for preparing and organizing collected data for training purposes is integral to the success of any machine learning model. This process involves several key steps, including preprocessing, segmentation, feature extraction, and classification, each contributing to the refinement and optimization of the dataset.


    Image processing and computer vision techniques play a crucial role in the development of intelligent traffic systems by enabling the detection and identification of vehicles in real-world scenarios. These techniques are essential components of systems designed to optimize traffic flow, enhance safety, and improve overall transportation efficiency.

    At its core, vehicle detection in traffic scenes involves analyzing images or video frames captured by cameras installed at strategic locations, such as road junctions or highways. The goal is to accurately identify the presence and position of vehicles within the scene, regardless of factors such as lighting conditions, weather, or



    The core module of the adaptive traffic light control system is pivotal in ensuring efficient management of traffic signals in real-time. By integrating inputs from the vehicle detection module, it conducts a thorough analysis of the current traffic density at a particular junction. This analysis serves as the foundation for making informed decisions regarding the adjustment of traffic signal timings. Through sophisticated algorithms for adaptive signal control, this module dynamically alters signal timings based on the prevailing traffic conditions.


    Fig no.2.Traffic light signal

    Initially, all signals at a particular junction will turn yellow and as the traffic increases the signal will start turning greenin sequence. The normal flow of traffic shows that signal 1 will turn green first, and then signal 2 followed by signal 3 and at last signal 4. The order of the traffic lights began as agreen light that lights up at traffic signal 1, and the red lightof other traffic lights. Each vehicle has been iven 2 secondstime to

    pass through the particular signal. The duration of this groups utilizing 3DCGSA, then corresponding data is learned through interfrequency planning. Utilizing EEG SIGNAL DATASET, tests, the proposed strategy beat customary methodologies in its capacity to recognize pressure states.


The envisioned AI-Based Traffic light Control and Ambulance Detection system, incorporating CNN algorithms, stand as a groundbreaking approach to enhancing traffic management and emergency response in urban environments.

The project’s underlying premise is to leverage the power of artificial intelligence for more responsive and intelligent

traffic control, particularly scenarios involving emergency vehicles like ambulances.

In the future, this project could be expanded to incorporate advanced machine learning algorithms for even more accurate and efficient traffic signal control. By integrating deep learning techniques, the system could learn and adapt to complex traffic patterns in real-time, further optimizing traffic flow and reducing congestion.


We are very grateful to Dr.T.SENTHIL PRAKASH ME PhD, Professor and Head Department of Computer Science and Engineering , for the aspiring suggestion, invaluably constructive criticism and friendly advice.

We wish to express our gratefulness to our guide Mrs.D DEEPANA ME., Assistant Professor of Computer Science and Engineering, for his invaluable guidance and constructive suggestions.


  1. USA TODAY. The Effects of Traffic Congestion, accessed Oct. 2014. [Online]. Available: trafficcongestion-61043.html
  2. TTIs 2012 Urban Mobility Report, Texas A&M Transp. Inst., College Station, TX, USA, 2012.
  3. Z. Cao, H. Guo, J. Zhang, D. Niyato, and U. Fastenrath, Finding the shortest path in stochastic vehicle routing: A cardinality minimization approach, IEEE Trans. Intell. Transp. Syst., vol. 17, no. 6, pp. 16881702,

    Jun. 2016.

  4. D. J. Wilkie, J. P. van den Berg, M. C. Lin, and

    D. Manocha, Selfaware traffic route planning, in Proc. 25th Conf. Artif. Intell. (AAAI), 2011, pp. 15211527.

  5. Z. Cao, H. Guo, J. Zhang, D. Niyato, and U. Fastenrath, Improving the efficiency of stochastic vehicle routing: A partial Lagrange multiplier method, IEEE Trans. Veh. Technol., vol. 65, no. 6, pp. 39934005, Jun.


  6. T Senthil Prakash, V CP, RB Dhumale, A Kiran., “Auto-metric graph neural network for paddy leaf disease classification” – Archives

    Volume 12, Issue 03

    Published by,

    ISSN: 2278-0181

    of Phytopathology and Plant Protection, 2023.

  7. T Senthil Prakash, G Kannan, S Prabhakaran., “Deep convolutional spiking neural network fostered automatic detection and classification of breast cancer from mammography images”,2023.
  8. TS Prakash, SP Patnayakuni, S Shibu., “Municipal Solid Waste Prediction using Tree Hierarchical Deep Convolutional Neural Network Optimized with Balancing Composite Motion Optimization Algorithm” – Journal of Experimental & Theoretical Artificial , 2023
  9. [TS Prakash, AS Kumar, CRB Durai, S Ashok., “Enhanced Elman spike Neural network optimized with flamingo search optimization algorithm espoused lung cancer classification from CT images” – Biomedical Signal Processing and Control, 2023.
  10. R. Senthilkumar, B. G. Geetha, (2020), Asymmetric Key Blum-Goldwasser Cryptography for Cloud Services Communication Security, Journal of Internet Technology, vol. 21, no. 4 , pp. 929-939.
  11. Senthilkumar, R., et al. “Pearson Hashing B-Tree With Self Adaptive Random Key Elgamal Cryptography For Secured Data Storage And Communication In Cloud.” Webology

    18.5 (2021): 4481-4497

  12. Anusuya, D., R. Senthilkumar, and T. Senthil Prakash. “Evolutionary Feature Selection for big data processing using Map reduce and APSO.” International Journal of Computational Research and Development (IJCRD) 1.2 (2017): 30-


  13. Farhanath, K., Owais Farooqui, and K. Asique. “Comparative Analysis of Deep Learning Models for PCB Defects Detection and Classification.” Journal of Positive School Psychology 6.5 (2022).

Volume 12, Issue 03

Published by,

ISSN: 2278-0181