УДК 004

The efficiency of smart traffic light in the "Smart City" concept based on neural networks for object and image recognition

Нурмуханбетов Санжар Нурмуханбетович – магистрант Казахстанско-Британского технического университета (Республика Казахстан, Алматы).

Нурмагамбетов Галымжан Бектурганович – магистрант Казахстанско-Британского технического университета (Республика Казахстан, Алматы).

Abstract: The relevance of the study lies in the fact that in recent decades, the level of urbanization in the world has increased significantly. An increasing number of people are moving to cities, especially megacities, which leads to an increase in the burden on infrastructure, the transport system, social security, etc. Also, this trend leads to a decrease in the attractiveness of cities as tourist destinations due to the deterioration of the environmental situation, safety and service level.

The paper explores the possibility of introducing a smart traffic light system in Almaty in the concept of "Smart City". Based on the experiment as a simulation, it is possible to further explore the development of a full-fledged traffic light system in the form of a smart city. Based on the neural network technology (YOLO), a constructive algorithm has been developed for unloading traffic jams at the intersection. Developed software in Python. The effectiveness of the proposed algorithm is demonstrated in the form of comparison and analysis.

Аннотация: Актуальность исследования заключается в том, что за последние десятилетия уровень урбанизации в мире значительно вырос. Все большее количество людей переезжает в города, особенно мегаполисы, что приводит к увеличению нагрузки на инфраструктуру, транспортную систему, социальное обеспечение и т. д. Также данная тенденция приводит к снижению привлекательности городов как туристических направлений из-за ухудшения экологической обстановки, безопасности и уровня сервиса.

В статье исследована возможность внедрения системы умного светофора в г. Алматы в концепции «Smart City». На основе эксперимента в качестве симуляции можно исследовать в дальнейшем развитие полноценной системы светофоров в виде умного города. На основе технологии нейронной сети (YOLO) разработан конструктивный алгоритм для разгрузки пробок на перекрестке. Разработано программное обеспечение на Python. Эффективность предложенного алгоритма продемонстрирована в виде сравнения и анализа.

Keywords: Smart City, smart traffic light, neural network, Python.

Ключевые слова: Smart City, умный светофор, нейронная сеть, Python.


The attractiveness of cities for living and visiting tourists taking into account factors, including safety and environmental friendliness. The pace of urbanization is currently leading to overcrowding of cities, which leads to a general indicator of the quality and comfort of life for each individual. In order to make it convenient for a person to be in modern megacities, Smart City detection elements are being introduced around the world, such as Smart Traffic Light [1].

Today, the city is loaded with thousands of cars, which leads to development of an infrastructure based on smart traffic lights. Technology will become the basis for new cities and seamlessly integrate into existing ones. These tasks can be solved thanks to the concept of an integrated approach Smart City [2].

Smart Traffic Light system solves a tremendous problem with traffic jams, which can be implemented all around the world.

To construct a system which has an ability to collect the data by recognizing vehicles and its characteristics from the intersection and allocate time for the “green wave” is an extremely challenging task.

We investigate whether our Smart Traffic Light system is useful for Almaty. Our motivation comes from YOLO approach, which easily detects and tracks objects. The input data is collected by cameras.

Our proposition is to calculate time shifts for the green light adaptively, using single formula. We recommend to use adaptive time allocation formula rather than using machine learning, because the difference between results is insignificant.

The remaining parts of the paper are organized as follows. First, we examine the related works that designed different traffic light systems in Section 2. Methods that were used during construction of traffic light system are described in Section 3. Following that, Section 4 explains our proposition, starting with the core idea, moving on to comparing our work with Smart Traffic Congestion Control System (STCCS) [3] and Adaptive Traffic Light Control System based on WSN (ATLCS) [4]. Finally, we offer some closing thoughts and suggestions for future study that might enhance the outcomes in Section 6.

Related work

In Smart City Concept (SCC), “smart traffic light” is a main key solution to all problems. Smart traffic light researches have led to the development of traffic lights that can adjust to different traffic conditions.

Avatefipour et. al [5] proposed “Traffic Management System” and focused on IoT technology, which accurately gathers input data. Input data is obtained by using noise sensors.

In [6], the authors designed traffic light optimization that has an artificial intelligence. In modern urban places, the traffic situation is more complex and complicated, so that time allocation is extremely essential.

The study of [7] offered “sharing cities”, where cities are truly smart and sustainable, since it is another technical option for smart cities, which is advanced data collection.

Moreover, Donti et. al [8] implemented machine learning to sustainable energy systems of the smart city.

In addition to these works, there is [9] where fuzzy neural network is applied for traffic signal control.

We also rely on careful and advanced data collection, however input data gathering is performed by cameras with using YOLO technique. Nevertheless, unlike [6] our application is based on adaptive calculation of time shifts for green light.

Materials and methods

Our smart traffic light system is an application which collects information about number of cars that enters the road intersection by recognizing them through the camera using neural network, count them and reproduce recommended time limit for the green light.


Figure 1. Architecture diagram of traffic light system.

Since there are only two directions at the intersection, respectively, for two traffic lights (North-South and West-East) of the same direction, one time shift for green light is calculated as can be shown in Fig. 1.

After every period or “round” of traffic light’s performance, our system has to gather data about the traffic situation (Fig.2). And this process is cycled.


Figure 2. The UML-Sequence diagram (Process).

The main components of the Traffic Light Controller are vehicle recognition (YOLO) and adaptive algorithm that executes time allocation.

YOLO is Convolutional Neural Network, a cutting-edge method of object detection. It has been done earlier to detect things using classifiers. As an alternative, we consider object detection to be a regression issue to spatially distinct bounding boxes and associated class probabilities. In a single assessment, a single neural network can immediately predict bounding boxes and class probabilities from the entirety of an image. Because the whole detection pipeline is made up of a single network, the detection performance may be altered from beginning to end [10].

YOLO detects and tracks the objects as a centroids. Each centroid must be initialized as a class(“person”, “car”, “bus”), so it can count vehicles [11].

The YOLO method, which has been employed in both production and real life, provides significant benefits over other algorithms in 1-stage target detection. It has been the subject of extensive study and attention, and it has since changed from the Yolov1 algorithm to the Yolov5 method. The Yolov1 method divides the input picture, on average, into multiple rectangular parts. The rectangular region is in charge of forecasting the object to be tested if the center location of the object to be tested falls on it. Each area predicts the kind of item as well as the B bounding box, which includes the center location, height, breadth, and confidence of the anticipated object. Formula 1, which expresses confidence as the accuracy of object information prediction:

f1   (1)

There is an improved algorithm for small vehi- detection based on YOLOv2. The algorithm adds an additional feature layer that can reach 1/32 of the input image in size, making the algorithm more adept at detecting small targets and having higher localization accuracy than YOLOv2 [12].


Figure 3. Dense YOLO network model.

In our case YOLO is the best suitable technology, it is crucial to detect vehicles quick and accurate.


Figure 4. Part of the program code of the YOLO algorithm.

At the beginning, the video returns an array with 80 elements containing information about detected classes. Each element contains a list of detected boxes.


Figure 5. The performance of YOLO detection (Tole-bi street).

Time Allocation Module has the simple approach. Basically, it compares the number of vehicles on each side of a road and distributes time shifts depending on priority.


Figure 6. Part of the program code of the Time Allocation Formula.

In synthesis of these two algorithms, Traffic Light Controller is conducted. The working process is described as follows:

  • There are 4 cameras at the road intersection, therefore there are 4 input videos to track the number of cars on each side of a road.
  • Since normally every traffic light’s the longest duration is 2 minutes, base timer is 120 seconds.
  • Moreover, it is essential to provide the minimum and maximum parameters for durations, 5 and 30 seconds, respectively.


Figure 7. Model of an isolated intersection.

Results and discussion

The proposed traffic light system is examined by simulation using pygame library. Furthermore, it was compared with real traffic light’s simulation and with traffic light system based on fuzzy logic to obtain the advantage of the program [13].

The simulation is carried out using Python library, pygame. Therefore, it is visually understandable.


Figure 8. Simulation using pygame.

The 10 distinct real-time values of the input parameters, as recorded at various time intervals during the day, are displayed in Table 1. These 10 values were chosen at random from a larger list of values that were generated after the system was subjected to the suggested methodology. According to the observation, peak hours is the most crucial factor in determining how long the signal's timer will run.

When it is 11:30 PM, number of vehicles in the queue is less, remaining time for green light is less, and time extension is less—51.85 seconds—than it would have been with conventional timers, which would have resulted in an additional 8.15 seconds of waiting for the other queues.

Similar to 9:30 AM, both the number of vehicles in the queue and remaining time for green light values are large and medium, and the timer is extended by 15.9 seconds to clear the running queue because it is a busy time of day. However, if a conventional timer were used, the timer would only be extended by 60 seconds, which would cause the queue to build up and the waiting time for each vehicle to increase significantly.

Because there is less traffic at midnight, which results in less waiting time for vehicles and less fuel consumption than the conventional counterpart, the extension of the timer is decreased to 26.2 seconds when the Peak-hours are 12 a.m. and midnight, and the values of number of vehicles in the queue and remaining time for green light are medium.

Table 1. Results of comparison between our TL system and conventional TL.

Number of vehicles

Rem. time green, sec

Peak hours

Time extension, sec

Conventional, sec

Difference, sec

Improvement, %




60 -8.15=51.85














60+21.7 = 81.7







60+16.8 = 76.8







60+7.7 =67.7







60+15.1 = 75.1







60+20.7 = 80.7







60+21.3 = 81.3







60-33.8 = 26.2




The proposed method has been contrasted with Smart Traffic Congestion Control System (STCCS) and Adaptive Traffic Light Control System based on WSN (ATLCS) for figuring out an average journey time for a specific distance. For the sake of our calculations, we assumed that each car would travel an average distance of 10 km. The road has signals every 1 km, and each vehicle must wait 180 seconds for its turn to pass a junction before the signal turns green for all lanes. According to our findings, the proposed strategy reduces the journey time by 15% when compared to STCCS and 17,7% when compared to ATLCS, which are the two ways mentioned above.

Table 2. Comparison of proposed TL system with STCCS and ATLCS.


Journey time (per 1000 vehicles), sec





Proposed TLS


%, Improvement

15% (STCCS)

17,7% (ATLCS)


In this paper, the new Smart Traffic Light system for Almaty was proposed. For the implementation YOLO object recognition in synthesis with Adaptive Control, a series of programming code has been created. The algorithm was implemented on the Python using the supporting libraries such as pygame, tensor, etc. This guarantees a working algorithm, which can to reduce traffic jams in Almaty.

The proposed approach was tested and compared with the conventional traffic light and other approaches, as a result our proposed system demonstrated improvement by 15% and 17,7%


  1. Chan K. What Is A “Smart City”?. // Expatriate Lifestyle. 2017. No. 4. P. 23-25
  2. Atta A., Abbas S., Khan E. Adaptive approach: an intelligent traffic congestion control system. // Journal of King Saud University. 2018. No. 2. P. 45-48.
  3. Zaaturi K., Jeridi M., Ezzedine T. Adaptive traffic light control system based on FSN: optimization of algorithms and hardware. // Software, telecommunications and computer networks. 2018. No. 4. P. 1-6.
  4. Awatefipur O., Sadri F. Traffic management system using IoT technology. // Comparative review. 2018. P. 1041-1047.
  5. Cabrane M, Crete S, El Maimouni L. Smart cities: A study and comparison of traffic light optimization in modern urban areas using artificial intelligence. // International Journal of Advanced Computer Research. 2018. No. 3. P. 10-18.
  6. McLaren D. Sharing cities: an example of truly smart and sustainable cities. // MIT Press. 2015. No. 19. P. 47-61.
  7. Donty P. Machine learning for sustainable energy systems. // Annual Review of Environment and Resources. 2021. No. 2. P. 719.
  8. Pappis S. Fuzzy logic controller for road junction. // Transactions on systems, man and cybernetics. 2016. No. 1. P. 707-717.
  9. Diwan T. Object Detection with YOLO: Issues, Successor Architectures, Datasets, and Applications. // Springer. 2022. 76.
  10. Svenzhensky J. YOLO algorithm and YOLO object detection. // Epsilon. 2022. No. 6. P. 389 – 400.
  11. Payan J. A review of the development of the YOLO algorithm. // Computer Science Procedia. 2022. No. 8. P. 516.
  12. McGann W. Beginning game development with Python and Pygame: from beginner to professional. // Press Python. 2022. No. 11. P. 690-703.

Интересная статья? Поделись ей с другими: