Assist.Prof. Dr. PERİ GÜNEŞ1 OSAMA BITTAR2
Instructure at İstanbul Aydin University
Email: parvanehshams@aydin.edu.tr
2 Master’s Student in Computer Science at Istanbul Aydın Üniversitesi
Email:
HNSJ, 2022, 3(4); https://doi.org/10.53796/hnsj3412
Published at 01/04/2022 Accepted at 19/03/2022
Abstract
The rapid development of technology, economy and population growth cause more transportation vehicles to be used in today’s cities. Using more vehicles causes long queues at traffic lights, unnecessary waste of time, unnecessary fuel consumption while waiting at traffic lights and nature pollution.
In this study, it is to create an intelligent traffic light based on image processing technology, using Python, YOLO v3 and OpenCV Library, where the traffic light knows the number of vehicles available in addition to the number of pedestrians, depending on these numbers the timers of traffic light will be changable and this reduces the unnecessary waiting time. Also, if there is an ambulance, the traffic light will open the way for the cars and help the ambulance to pass quickly, thus helping to save people’s lives. At the end of the search, the proposed traffic light has been compared with a classic traffic light in Istanbul. and the results have proven the superiority of the smart traffic light over the traditional one at many points.
Key Words: Python, YOLO v3, OpenCV, Object Detection, Traffic Light.
عنوان البحث
تصميم نظام ذكي لإشارات المرور باستخدام معالجة الصورة
تاريخ النشر: 01/04/2022م تاريخ القبول: 19/03/2022م
المستخلص
يتسبب التطور السريع للتكنولوجيا والاقتصاد والنمو السكاني في استخدام المزيد من مركبات النقل في المدن اليوم. وهذا يؤدي الى استخدام المزيد من المركبات والوقوف في طوابير طويلة عند إشارات المرور، وإهدار غير ضروري للوقت، واستهلاك غير ضروري للوقود أثناء الانتظار عند إشارات المرور بالإضافة الى تلوث الطبيعة.
في هذه الدراسة، يتم إنشاء إشارة مرور ذكية تعتمد على تقنية معالجة الصور، باستخدام Python و YOLO v3 و OpenCV Library حيث تستطيع إشارة المرور عد المركبات المتواجدة في طابو الانتظار بالإضافة إلى عد المشاة، واعتمادًا على هذه الأرقام ستكون إشارة المرور قادرة على تغيير اوقات الاضاءة الخاصة بها وهذا يقلل من وقت الانتظار غير الضروري. بالإضافة لذلك يستطيع النظام المقترح اكتشاف سيارات الاسعاف وفي حال وجود سيارة إسعاف فإن إشارة المرور ستفتح الطريق أمام السيارات وتساعد سيارة الإسعاف على المرور بسرعة، مما يساعد في إنقاذ حياة الناس. في نهاية البحث، تمت مقارنة إشارة المرور المقترحة بإشارة مرور كلاسيكية في اسطنبول وقد أثبتت النتائج تفوق إشارة المرور المقترحة على الإشارة التقليدية في العديد من النقاط.
الكلمات المفتاحية: معالجة الصورة، اكتشاف الاشياء، إشارة المرور، بايثون،YOLO v3 ،OpenCV.
1. Introduction
As is known, the biggest cause of traffic congestion in cities is traffic lights where the lighting times of traffic lights cannot adapt to the changing traffic density and cause long and unnecessary queues. Intelligent traffic light control systems have begun to spread with the development of technology in the past two decades, these systems attempt to reduce waiting times at traffic lights and apply pre-determined minimum or maximum lighting times in proportion to the number of pedestrians or vehicles at traffic lights in an attempt to prevent traffic congestion, But finding a fixed time commensurate with the traffic congestion at the traffic light is very difficult because the number of vehicles and pedestrians changes irregularly, and this makes the process of adjusting the time of the traffic light difficult and inaccurate. In addition to what was previously mentioned, there is a problem when an ambulance is in the waiting queue, where traditional traffic lights cannot take any decision, and this will delay the ambulance a lot, which may endanger the lives of patients.
The proposed solution in this study is to create a smart traffic light based on image processing technology, where the traffic light can count vehicles in addition to counting pedestrians at every moment and thus change the time of the traffic light in proportion to the amount of current congestion and this reduces the unnecessary waiting time, and also in the case Having an ambulance, the traffic light will open the way for vehicles, helping the ambulance pass quickly and reach patients faster.
2.Literature Review
E. Leigh (2017) designed an intelligent traffic management system, and this system was partially implemented in the city of Cambridge, where the system relies on placing sensors that detect queues for vehicles and then sends the information to a central control unit to take the appropriate decision, but the problems In this way, the networks suffer from many problems, which leads to the slowdown of the central system [1].
The researcher Kartikeya Jain in (2017) designed a system capable of identifying cars through the number plate, and he used cameras to identify cars. But this system failed in Pakistan because donkey carts and bicycles do not have a number plate and therefore cannot be recognized [2].
V.S.A.M.S.D.K.K. Swathi (2016) has designed an intelligent system to direct car traffic to the least crowded road. It relies on a set of infrared sensors that can detect traffic density by observing the reflected light from cars. This system suffers from a problem, which is the value of reading the sensors is affected by a degree Heat and humidity make the results of this system inaccurate[3].
Syed (2009) found that controllers based on fuzzy rules are able to efficiently manage the traffic light system and have optimal decision-making ability. Whereas, traditional constant-time-based control methods cannot effectively deal with a complex and changing traffic situation [4].
Z.Yang, L.S.C. Pun-Cheng (2018) Image processing systems can detect the complex, where the algorithm extracts the number of vehicles from the video and thus knows the traffic density. Traffic light control systems that rely on image processing are characterized by their ability to pre-process and make the appropriate decision. Image processing techniques have been applied on a very wide scale in Traffic field in order to collect information from the beams in real time[5].
N.K. Jain, R.K. Saini, and P. Mittal (2019), Estimating traffic density is fundamental to addressing traffic congestion and improving traffic management systems. This requires detection of moving vehicles and tracking of vehicles. Intelligent Transportation Systems (ITS) based on magnetic ring, infrared radar, RADAR microwave, and sensors based on video and ultrasound processing have been used to manage traffic [6].
Roxanne Hawi and others (2017), an increase in traffic congestion and insufficient space and funding prompted researchers to work towards reducing it. One of these solutions is the use of a smart system such as the use of Smart Traffic Signal (STL) and Wireless Sensor Network (WSN) [7].
Nathanie Fairfield and Chris Urmson (2011), over the past years the traffic light control system has been static and ineffective. In order to better control the traffic there must be a more efficient and dynamic system that can handle the traffic easily and safely and therefore this system will be especially better in the performance of traffic control Traffic intersections [8].
T. Kanungo and other(2002), Although the video-based traffic monitoring recognition technology has the characteristics of multiple information gathering, ease of installation and low cost, it is difficult to obtain the required traffic information from the image. In recent years, how to obtain traffic information efficiently, accurately and in real time has become an essential technology for video surveillance [9].
In this paper, we propose a method capable of determining the number of vehicles and number of pedestrians in real time as well as the ability to distinguish ambulances and make the appropriate decision effectively.
3.Problem Statement
Traditional traffic lights suffer from the problem of fixed time for vehicles and pedestrians, therefore it is unable to adapt to the requirements of congestion, and this is what causes queues of vehicles and pedestrians. In this study we try to solve this problem by designing a intelligent traffic light that depending on image processing technology and is capable of making real-time decision commensurate with the traffic density.
4.Data Set
In order to discover the elements in the images, it is necessary to have the appropriate set of images, as the number of images greatly affects the learning algorithm and the greater the number of images, the greater the ability to detect objects in the image.For this reason, several visual collection methods were used in this study.
4.1.Google fatkun bulk data downloader
The keywords covering all types of vehicles were written in Arabic, English and Turkish in the Google search engine, and then the Fatkun Stack file plugin tool integrated with the Google Chrome browser was used, which helps to download all the image at once instead of downloading the images one by one.

Figure (1): Google fatkun bulk
4.2.Download Image From Shuttterstock.com
Images containing only ambulance have been downloaded from Shuttterstock.com and istockphoto sites. This was done in order to focus only on objects at the training stage. Downloaded images are in high resolution. It is aimed to increase the accuracy of the neural network model by obtaining details with high resolution images.

Figure (2): Shuttterstock.com website
4.3.Tagging The Created Dataset
LabelImg program was used to determine the coordinates of the photos taken by labeling them. After the program was opened, the “OpenDir” button was clicked, the file containing all the images was selected and all the images were added to the program.

Figure (3): labeling image using LabelImg program
4.4.Training YOLO v3 Using Google Colab
After the previous operations an account was created to train YOLO v3 in Google Colab. The folder containing both images and text files created after tagging was uploaded to Google Drive.
5.Methods
The study was applied to a one-way traffic light as shown in figure (4), where A and B represent the areas pedestrian:

Figure (4): One Way Traffic Light
The classic traffic light is based on a fixed life cycle, as shown in the figure (5):

Figure (5): Classic traffic light life cycle
In this study, the work was divided into five steps, image processing technology which depending on YOLO v3 and OpenCV was used in order to detect objects in the images and obtain their number. The work stages are as follows:
- Step 1: Process the video from the first pedestrian camera and then count the number of people as shown in Figure (6):

Figure (6): Pedestrian detection on the first side of road
- Step 2: Process the video from the second pedestrian camera and get the number of people as shown in Figure (7).

Figure (7): Pedestrian detection on the second side of road
- Step 3: Process the video from the vehicle camera and get the number of vehicles as shown in Figure (8).

Figure (8): Vehicles detection in waiting queue
- Step 4: detect if there is an ambulance in the waiting queue as shown in Figure (9).

Figure (9): Ambulance detection
- Step 5: set the timer for vehicles and the timer for pedestrians in proportion to the number as shown in Figure (10).

Figure (10): Setting the timer for vehicles and pedestrians
The number of pedestrians and vehicles was divided into four groups as shown in the table (1):
Table (1): Divide the number of vehicles and pedestrians into groups.
| Pedestrians Group | Vehicles Group | ||
| Number of Pedestrians | Group name | Number of Vehicles | Group name |
| [0] | Low | [0] | Low |
| [0… 9] | Medium | [0… 6] | Medium |
| [10… 19] | High | [7… 14] | High |
| [20, …[ | Very high | [15, …[ | Very high |
Depending on the previous groups, the traffic light timer will be set as shown in the table (2):
Table (2): Timers scheduling depending on groups type.
| Vehicle Group | Pedestrians Group | Vehicle Timer | Pedestrian Timer |
| Low | Low | 80 sec | 40 sec |
| Low | Medium | 00 sec | 40 sec |
| Low | High | 00 sec | 40 sec |
| Low | Very high | 00 sec | 40 sec |
| Medium | Low | 80 sec | 00 sec |
| Medium | Medium | 58 sec | 35 sec |
| Medium | High | 50 sec | 70 sec |
| Medium | Very high | 40 sec | 80 sec |
| High | Low | 80 sec | 00 sec |
| High | Medium | 95 sec | 25 sec |
| High | High | 90 sec | 30 sec |
| High | Very high | 60 sec | 60 sec |
| Very high | Low | 80 sec | 00 sec |
| Very high | Medium | 105 sec | 15 sec |
| Very high | High | 100 sec | 20 sec |
| Very high | Very high | 100 sec | 20 sec |

Figure (11): Flowchart diagram for Traditional traffic light
Figure (12): Flowchart diagram for intelligent traffic light
6.Discussion
The study was carried out on traditional traffic lights in Yenibosna, Istanbul, as shown in Figure (13):

Figure (13): traditional traffic lights in Yenibosna
In this study, the duration of the green signal assigned to vehicles and pedestrians was compared in the classic control system and the proposed system. The figure (14) shows the number of pedestrians and number of vehicles accumulated at traffic lights, and the duration of the green light in both the classic control system and the intelligent control system proposed in this study:
Figure (14): Comparison of Classic and intelligent Vehicle timer
Figure (15): Comparison of classic and intelligent pedestrians timer
We note that in traditional control the duration of the green light is always fixed, while in intelligent control the duration is changeable according to the number of vehicles and pedestrians at the traffic light. The figure (16) below shows the lost time at the four life cycles of a traffic light as it is calculated from the difference between the green light times in the traditional and intelligent system.
Figure (16): Lost time in the traditional and intelligent system.
The table (3) below compares the duration of the green light for pedestrians with the duration of the green light for vehicles in both traditional traffic light control and intelligent traffic light control over the four life cycles.
Table (3): Compares the duration of the green in traditional and intelligent traffic light.
| Classic Control Traffic Light | Intelligent Control Traffic Light | |||
| pedestrian timer | vehicle timer | pedestrian timer | vehicle timer | |
| First life cycle | 30 | 90 | 70 | 50 |
| Second life cycle | 30 | 90 | 30 | 90 |
| Third life cycle | 30 | 90 | 0 | 80 |
| fourth life cycle | 30 | 90 | 80 | 40 |
7.Results and Recommendations
This research presented a new algorithm for a control system based on image processing and found a solution to many classical traffic light problems where traffic lights working with this Intelligent system can distribute time between vehicles and pedestrians in proportion to their number.
In this way, fuel consumption is reduced, environmental pollution is reduced and ambulances are given priority, if any. This system can also respond to changes in traffic situation, thus reducing traffic congestion and shortening waiting time. At a small economic cost, we only need three cameras for each traffic light, thus achieving the high reliability of a flexible control system that solves many traffic problems and reduces traffic congestion and its negative effects.
The study was applied to a traditional traffic light in Yenibosna, Istanbul, then were compared classical control with intelligent control. The results showed the superiority of the proposed system over the classical system in several points.
It can be recommended to design an intelligent control system in the form of an interconnected network, especially in areas where there are two or more intersections, where the efficiency of this system and the ability to make appropriate decisions will increase.
REFERENCE
[1] E. Leigh, “Advancing integrated and sustainable transport for the
Cambridge region,” Smarter Cambridge Transport, (2017).
[2] Kartikeya Jain, “Smart vehicle identification system using OCR,” in 3rd International Conference on Computational Intelligence & Communication Technology, Ghaziabad, India, (2017).
[3] V.S.A.M.S.D.K.K. Swathi, “Traffic Density Control and Accident Indicator Using WSN,” International Journal for Modern Trends in Science and Technology, vol 2, no 4, pp 2455-3778, (2016).
[4] Syed M. S. , Syed A. ve Humera N, “Fuzzy Rule Based Traffic Signal Control System For Oversaturated Intersections,” Cinc, Vol. 2, Pp.162-165, 2009 International Conference On Computational Intelligence And Natural Computing(2009).
[5] Z.Yang, L.S.C. Pun-Cheng, “Vehicle detection in intelligent transportation systems and its applications under varying environments”, (2018). https://doi.org/:10.1016/j.imavis.2017.09.008.
[6] N.K.Jain, R.K.Saini, and P.Mittal, “A Review on Traffic Monitoring System Techniques”, Soft Computing: Theories and Applications. Advances in Intelligent Systems and Computing, Springer, (2019). https://doi.org/10.1007/978-981-13-0589-4 .
[7] Roxanne Hawi, George Okeye , Michael Kimwele ,”Smart traffic light control using fuzzy logic and wireless sensor network ”, Computing Conference, London, UK , INSPEC Accession Number: 17486620 , DOI: 10.1109/SAI.2017.8252137. IEEE, (2017).
[8] Nathanie Fairfield, Chris Urmson , “ Traffic Light Mapping and Detection”, IEEE International Conference on Robotics and Automation, (2011).
[9] T. Kanungo, D Mount, N Netanyahu and other, “An efficient K-means clustering algorithm: analysis and implementation,” IEEE Transactions on Pattern Analysis Machine Intelligence, 24(7): 881-892, (2002).