Authors: Jehaan C. Darbari, Urvi V. Chavan, Kailash G. Bharti, Er. Manoj Kavedia, Mr. Amit Hatekar
Certificate: View Certificate
Monitoring traffic efficiently has been one of the biggest modern day problems. As population has exponentially increased in the last century, the same effect has been observed on vehicles. This has put tremendous pressure on the existent traffic systems. Even today, several traffic systems work with the concept of fixed time slots attached to each traffic light while overlooking the density of traffic at that junction. This causes millions of people to waste their precious time in traffic while concurrently affecting the nature through air and noise pollution. Another consequence of this waiting is the toll on the mental health of the commuters. To overcome these problems, we propose a system that manages traffic by taking the primary factor of real time traffic density into consideration. This system utilizes cameras along with image processing to achieve its goal. It ensures that the lanes switch based on the number of vehicles, consequently cutting down waiting periods while reducing pollution substantially.
Traffic management has seen drastic changes over the years. From the time when a traffic policeman used to manage several vehicles throughout the day, we have come a long way forward to today’s automated traffic signal system. Most traffic control systems these days make use of pre-set timers for each lane of traffic at a particular junction. The major problem with this system is the inconsideration of the traffic density at any specific time. It has therefore been a frequent observation that a certain lane having a greater pre-set time remains green even though it does not have any vehicles approaching the junction while the other lanes suffer because there is no switching of signals. As mentioned previously, this causes several problems which are further highlighted below:
These major problems need to be tackled by the traffic authorities at the earliest because they affect the society as a whole and make the travel experience much worse than it should be. Nevertheless, progress has been made in several parts of the world to curb the problems which arise from traffic mismanagement. Cameras have been installed at several traffic junctions to fine the offenders. At some places, officials have started using different sensors to switch traffic lights depending on the density. However, the use of loop detectors or proximity sensors as electronic sensors is once again debatable due to the high cost. Hence it is evident that going forward in the future, the systems in place today will not be able to help out with effective traffic management. It is therefore necessary to get a new, updated system into place soon. The system we propose utilizes real time traffic information to control the signals at any junction. It first detects the number of vehicles on each road and depending on the count, it assigns the optimum waiting time (through red signal light) and running time (through green signal light). In this manner, each cycle will have different waiting periods for every lane and will consequently ensure lesser congestion at the signals. Since the system is completely automated as well, it can go a long way in managing traffic dynamically.
II. LITERATURE REVIEW
Reference  proposes a system that takes live images from CCTV cameras at traffic junctions and uses it to calculate the real-time traffic density. This calculation is carried out using image processing and object (vehicle) detection through YOLO (You Only Look Once). The number of vehicles detected with the help of this algorithm controls the signal switching algorithm and accordingly sets timers for each lane. A simulation of the proposed idea has been developed as well to exhibit the effectiveness of the proposed system over the existing traffic management system. The accuracy of detection achieved through the system was between 75% and 80%, thereby improving the current traffic system by 23%.
Reference  uses digital image processing through OpenCV (Open Source Computer Vision Library) to control the live traffic present on roads. The captured videos from camera are first converted to grey scale images followed by the application of image thresholding. Subsequently, video frames are converted to images and again, smaller frames are created from these images. The SVM (Support Vector Machine) algorithm searches these small frames to identify and categorize vehicles which ultimately leads to switching of signals. This system is also able to identify traffic rule violators and stores these images separately. The results had an average error of 2% with an execution time of 1.5 seconds.
Reference  implements image processing using OpenCV with Haar Cascade algorithm. The system also makes use of Artificial Intelligence along with Arduino to count the traffic in each path. A model of the system containing Arduino Pro Mini and LEDs is created to illustrate the benefits of the approach. Although the system is completely automated, a feature to control traffic manually is also provided in case of an emergency. The success of the system was made evident through the effective monitoring of a local traffic prone area whose data was collected and run on this system. An estimated 60% decrease in the congestion of traffic was possible through this process.
Reference  proposes a five module implementation system for traffic management. Images are first acquired from the pre-existing data sets that depict the real-time images of traffic. This is followed by image pre-processing where unwanted noise and objects are removed from the image. Consequently, the images are processed with the help of edge detection that focuses on the discontinuities in the images. Later, decision is made to switch the traffic lights based on the density which is finally followed by the output. Raspberry Pi 3B+ module accompanies OpenCV to carry out the entire process.
Reference  achieves traffic monitoring by using Google API (Application Program Interface) crowdsource data, thereby avoiding the use of sensors. The data is communicated to the control system via a ZigBee network and the signal timings are thereby adjusted. In order to show the proposed system, a circuit was first tested on Proteus software and then implemented. Data from a junction of Delhi city was run on the system for three different hours of the day to get an idea about the variance of traffic density and the adaptability of the system to the same. The proposed system provided good results and proved to be a technique that could be instantly employed at any traffic junction where it is needed.
III. PROPOSED SYSTEM
A. Proposed System Overview
The system we propose takes input from cameras & infrared sensors and switches the signals at the junction. Thus traffic signals keep switching based on the density of traffic at that moment. In order to show the utility of our system, we have created a miniature model that shows the monitoring of a four-way traffic junction. The model system works in two phases, the primary system and a backup system. The primary system monitors the four-way intersection using two cameras and two sensors for the respective four lanes whereas the backup system uses two sensors for each lane (eight sensors in total). Arduino Mega 2560  is at the heart of both systems and works in unison with the software on the computer. Fig. 1 illustrates the miniature model.
B. Primary System
As mentioned previously, the primary system uses two infrared sensors and two cameras to monitor the live traffic. Assuming the four lanes at the junction to be lanes A, B, C and D, lanes A and C are monitored using the two sensors (one sensor for each lane) while the two cameras keep a check on lanes B and D respectively. Three 5mm LEDs are used for every lane to replicate a real life traffic signal. The sensors for the model are TCRT5000  infrared sensor modules that provide a good range to measure the presence of an object in front of the sensor. At the same time, the cameras detect appearance of a vehicle and send the data back to the controlling system. All hardware components, apart from the two cameras (which are directly connected to the laptop ports) are then connected to the Arduino Mega 2560 board which is eventually connected to the computer. Fig. 2 shows the schematic circuit diagram of the primary system.
The software of this system comprises of Arduino IDE (Integrated Development Environment) which controls the sensors and Python (through OpenCV using PyCharm ) which makes decisions depending on the feedback from the cameras. While the sensitivity of the TCRT5000 infrared sensors can be adjusted using the potentiometer present on the module, the area captured by cameras to detect the vehicles can be adjusted using the PyCharm software. The adjustment to the contour area in the software helps us to enable these changes. The Arduino code is first uploaded to the Arduino Mega board. Later, input is given to the PyCharm terminal to execute the code, thus making the system operational.
Once the system is active, traffic signals of all lanes will turn red. They will remain in this state as long as none of the sensors and cameras present at the junction detect any vehicle. Whenever any lane detects a particular vehicle, the traffic light for that lane will turn green. This pathway will now remain green for as long as there are no automobiles present in any of the remaining three lanes. As soon as you remove the vehicle from that lane, the traffic indicator will once again turn red. However, if the car is not removed and another car is made to enter either one of the three available paths, the first lane will not remain green for an immeasurable time but will rather have a limit of six seconds. Thus the two lanes that have been occupied with traffic will keep switching between themselves with a maximum time of six seconds. Again, if any of the two lanes become vacant, the other lane will remain green endlessly. The same logic can be applied to the presence of traffic in three lanes or all four lanes at the junction.
The rationality behind the working of the system is the timely examination of each road for the presence of traffic. The system keeps running in a cycle, going from lane A to lane D with a limit of six seconds for each lane. Therefore, whenever a certain single lane has detected traffic, the lane is assigned green light for a period of at least six seconds (as long as the traffic is continuously detected in that lane, i.e. unless the cars in that lane move away). After six seconds, the network monitors the other lanes for traffic. If it does not detect any motor car after going through the entire cycle, it starts the next cycle wherein it once again detects traffic at the first lane and keeps it open once again for six seconds. Since the primary system uses cameras and if any disaster takes place affecting the cameras, the system can be diverted to the backup system.
???????C. Backup System
As the name suggests, the backup system comes into action in an emergency situation where the main system fails. The backup system makes use of eight TCRT5000 infrared sensor modules (two sensors on each lane) to monitor traffic. Just like the primary system, the backup system too uses three 5mm LEDs to demonstrate each traffic signal. Four 7-segment displays are used as timers to display the time for which the respective lanes will remain green. For the backup system, each hardware component is connected to the Arduino Mega 2560 board that is ultimately attached to the computer. Arduino IDE (Integrated Development Environment) makes up the complete software for this system. Fig. 3 reveals the circuit diagram for the backup system.
The backup system gets activated once the necessary code is uploaded to the Arduino board. When no traffic is detected, the system starts working in a cycle from lane A to lane D, switching to each traffic signal for a maximum period of three seconds. The 7-segment timers too get activated in the first cycle and display the obligatory time. The preference hierarchy for the backup system is as mentioned below: 2 sensor trigger > 1 sensor trigger > Absence of traffic.
Thus, a crowded lane which has traffic present at both the sensors will be preferred over a lane with vehicle present at the first sensor. Traffic light switching based on the real time density is hence achieved through the backup system. Fig. 4 presents a traffic lane with three seconds displayed on the timer due to lack of traffic.
Whenever a single sensor, i.e. the first sensor of any traffic path detects a vehicle, it will assign a five second timer to that particular lane instead of the previously mentioned three seconds that were assigned due to the absence of automobiles. Unlike the primary system, the backup system will remain green for the entire duration of five seconds even if the vehicle is removed immediately after the timer is assigned. If multiple pathways of the junction have a vehicle present at the first sensor, the system will keep running in a loop, starting from lane A to D, assigning those lanes a timing of five seconds while the remaining lanes with no presence of traffic will remain red. Thus the presence of a single vehicle at lane A will trigger its signal first followed by the single vehicles present at lanes B, C and D respectively. A traffic light of the miniature model displaying five seconds on its timer is shown below in Fig. 5.
Lastly, if a particular road at the junction has both its sensors triggered by traffic, it will assign that lane a timer of eight seconds instead of the three seconds or five seconds. Just as a green light remains in the same state for five seconds irrespective of the car being present later for a single sensor trigger, the same is the case when two sensors are triggered. The path will remain green here for all eight seconds. Similarly, if more than one lane has vehicles present at two sensors, the system will run in a cycle, assigning eight seconds to those lanes. Fig. 6 illustrates a traffic light which displays a timer of eight seconds due to the presence of vehicles on both sensors.
IV. FUTURE WORK
Even though the proposed system improves the current traffic monitoring system, there is room for the following improvements that can be added in the near future:
It is evident that the current traffic management systems which make use of predetermined timers at traffic junctions are not capable of providing a smooth commute experience. They have a lot of drawbacks and will need a huge makeover to become efficient. Thus, they cannot act as a long time solution to the handling of ever-growing vehicle population on roads. The system that we propose takes into consideration all the current problems and finds an appropriate solution for the same. People will have to wait a lot lesser at signals, they will be relieved of the constant stress due to their commute while also reducing the traffic offenses that are observed. Most importantly, it will ensure that less fuel is wasted at traffic junctions while greatly reducing noise pollution too. The proposed system is not only smart but also completely automated which makes it great. Its consideration of real time traffic density is what separates it from the rest of the systems in place. The additional feature of a timer will also help to solve the problems of constant honking at the signal and speeding at a junction (to avoid the red traffic light) because commuters can now observe the timer and adjust to the situation accordingly. It is hence very much possible that our system can go a long way in making future travel worthwhile.
 M. M. Gandhi, D. S. Solanki, R. S. Daptardar and N. S. Baloorkar, \"Smart Control of Traffic Light Using Artificial Intelligence,\" 2020 5th IEEE International Conference on Recent Advances and Innovations in Engineering (ICRAIE), 2020, pp. 1-6, doi: 10.1109/ICRAIE51050.2020.9358334.  Renjith Soman \"Traffic Light Control and Violation Detection Using Image Processing”.” IOSR Journal of Engineering (IOSRJEN), vol. 08, no. 4, 2018, pp. 23-27  Shaikat, Abu & Tasnim, Rumana & Mahbub, Farhan & Saleheen, Rezwan & Mahmud, Rayhan & Islam, Tohorul. (2020). An Image Processing and Artificial Intelligence based Traffic Signal Control System of Dhaka. 10.1109/APCoRISE46197.2019.9318966.  A. S. R. R. A. F. Adwait Sharma, “Density Based Traffic Signalling System using Image Processing,” International Journal of Computer Applications Technology and Research, vol. 8, no. 05, pp. 213-216, 2019.  Mishra, Sumit & Bhattacharya, Devanjan & Gupta, Ankit & Singh, Vaibhav. (2018). ADAPTIVE TRAFFIC LIGHT CYCLE TIME CONTROLLER USING MICROCONTROLLERS AND CROWDSOURCE DATA OF GOOGLE APIs FOR DEVELOPING COUNTRIES. ISPRS Annals of Photogrammetry, Remote Sensing and Spatial Information Sciences. IV-4/W7. 83-90. 10.5194/isprs-annals-IV-4-W7-83-2018.  ‘Arduino MEGA 2560 & Genuino MEGA 2560’. [Online]. Available: https://www.arduino.cc/en/Main/arduinoBoardMega2560  ‘TCRT5000 Infrared Sensor Module’. [Online]. Available: https://www.openimpulse.com/blog/products-page/product-category/tcrt5000-infrared-sensor-module/  ‘PyCharm: the Python IDE for Professional Developers by JetBrains’. [Online]. Available: https://www.jetbrains.com/pycharm/  V. Chaubey, \"Helping patients get to hospital on time,\" The Hindu, Mumbai, 2017.
Copyright © 2022 Jehaan C. Darbari, Urvi V. Chavan, Kailash G. Bharti, Er. Manoj Kavedia, Mr. Amit Hatekar. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.