Intelligent Traffic Light Controlling System According to the Traffic Area

Traffic congestion is a significant problem in recent years because of the everincreasing number of vehicles in the roads and the poor management of traffic. Traffic congestions are not constant throughout the day. They are changing from time to time. Present traffic controllers have fixed time intervals for red, yellow and green signal lights and therefore, cannot provide a better solution for the dynamic traffic congestion during the day. Computer vision technology can be used to create an intelligent traffic controlling system which can adapt its time intervals according to the real traffic. In the existing traffic controlling systems, a wastage of the green signal duration occurs as fixed green signal duration assigned for a phase is sometimes larger than the actual requirement. Hence, the other roads at the intersection have to wait, in vain, with more traffic, until that fixed green time period is over. In the proposed method, real time traffic image sequences are analyzed by using image processing in order to obtain the actual traffic area. Then, time for green light is assigned according to that traffic area. Hence, the wastage of green signal duration is eliminated by the proposed method since it allocates time for the green signal that is sufficient for the actual traffic 1 Department of Statistics and Computer Science, University of Kelaniya, Sri Lanka, randi.fernando111@gmail.com. 2 Information Technology Centre, University of the Visual and Performing Arts, Sri Lanka, anusha.j@vpa.ac.lk Date Received: 02 November 2018 Date Accepted: 14 November 2019 KALYĀNĪ: Journal of the University of Kelaniya, ISSN 2012-6859, Volume XXXIII (Issue I/II), 2019 16 present on the road to the pass. The results reveal that the green signal duration that needs to pass the traffic is proportional to the road area covered by traffic at that time.


Introduction
Traffic congestion has become a major problem in recent years. It causes many problems such as air pollution, sound pollution, stress and, time and energy wastage. The reasons behind this problem are the insufficiency of the resources provided by the current infrastructure for transportation to meet the ever increasing number of vehicles on the road and the improper controlling of traffic creating traffic jams (Agrawal D. and Sahu A., 2015). These traffic jams not only affect the human routine but also lead to a rise in the cost of transportation.
Traffic congestion in urban areas especially in Colombo is a major problem which needs to be urgently solved. The traffic congestion during a day is dynamic. The current system of fixed time sequenced signal lights cannot adapt its time intervals according to the changing traffic.
There are situations in cross way intersections such as heavy incoming traffic available only from several sides of the intersection while the rest are relatively empty. In this case, people on the heavily -occupied side have to wait for a longer time while the road containing low traffic displays a green signal without having vehicles to move. The allocation of fixed green light time for all sides, leads to a wastage of green signal duration as well as creating more traffic in other roads thereby increasing the average waiting time of every person in the traffic.
The government officials set these timers according to the proportionate amount of traffic present on different sides of the intersection using some statistical data.
However, this can never be so flexible to control dynamic traffic throughout the day because some areas of high traffic may receive scanty traffic at some point of the day and some low traffic volume areas might get congested.
Hence, there is a dire need for a smart system that can adjust the timing of these lights based on the real time traffic present on the road. Because of this, there is an interest in developing intelligent traffic controllers using various technologies such as Magnetic Loop Detectors, Inductive loop detectors, light beams of infrared rays and LASER, and also using image processing. (Choudekar P. et al,2011) Using image processing operations to develop a self-adaptive, intelligent system which can help in better traffic management is cost effective as cameras are cheaper and affordable devices compared to any other devices such as sensors. (Joshi A. A. and Mishra D., 2015) Several researches have been done for controlling traffic using different techniques of image processing. They are mainly based on vehicle counting methods (Aher C. and Shaikh S.,2015), (Abbas N., et al, 2013) (Niksaz P., 2012) and image comparison methods. (Choudekar P. et al,2011) The aim of this research is to identify a technologically advanced, intelligent traffic controlling method by recognizing the actual area of the traffic which is presented on a road thereby providing an adequate amount of time for the traffic to pass by dynamically changing traffic light timers.
Moreover, the proposed method is supposed to eliminate the wastage of green signal duration by providing only a sufficient time interval rather than providing a pre-set time interval. Thus, the road with less traffic will be given the green signal for a shorter period of time, while the road with more traffic will be given a longer green signal period.
The ultimate objective of this research is to decrease the average waiting time of people in the traffic thereby saving more energy and time.

Methodology
The proposed approach to the elimination of the wastage of 'green signal duration' and controlling traffic is as follows: firstly, a camera was installed at the phases of an intersection to monitor the incoming traffic. After collecting image data sequences through the camera, the area covered by the vehicles in that particular road phase was quantified by processing images. Traffic signal time duration for effective green period will be dynamically set based on the current incoming traffic area from that direction. In this method, the road which is having more traffic, will be allotted a longer duration of green signal duration compared to others. Hence, it can be used to avoid the wastage of green signal duration.

Figure 1. Proposed method for calculating the green signal duration
According to Figure 1, the proposed method can be divided into four parts: the first part is the acquiring of image sequences of the traffic on the road phase by using a fixed camera. The second part is applying pre-processing techniques on image sequence to enhance the features of the image to prepare it for further analysis. This is achieved by using an OpenCV vision library. The third part is to detect the targeted area where the vehicles are actually presented on the road. The last part is allocating 'effective green signal time' to the phase which can be performed according to the current area of the traffic which covers the road at that particular moment. This research is done with the help of Open Source Computer Vision Library (OpenCV) version 3.2 and C++ with the use of Visual studio 2015. Traffic videos were captured by using a phone camera with 12 MP.

A. Image Acquisition
Image acquisition in image processing can be broadly defined as the action of retrieving an image from some source usually a hardware-based source which can be passed through whatever processes that need to occur afterwards. Image acquisition is the first stage of any vision system because without an image, no processing is possible. The image acquired is completely unprocessed. Therefore, after obtaining the image, various methods of image processing are applied to the image to perform many different vision tasks. However, if the image is not acquired satisfactorily, then, the intended tasks may not be achievable even with the aid of image enhancement.
In this research, image sequences were captured by using a phone camera and the camera was stationary. The camera was positioned at sufficient height in order to have a clear view of the road from the point of the traffic lights. The camera is activated a few seconds before the light turns into green. As a preliminary task, offline videos which were taken from real time videos were used to propose a method. The method that is proposed here can be directly applied to the real time videos as well.
The next stage is to extract the frames continuously from the real time video coming from the stationary camera. These frames were then pre-processed and analyzed to detect the traffic area.

B. Pre-processing
Pre-processing is a common name for operations with images at the lowest level of abstraction. In these operations, both input and output are intensity images. The aim of preprocessing is to suppress unwanted distortions and enhance image features which are important for further processing (Gaikwad O., et al,2014). In other words, pre-processing is done to get a clear image. Since the images are extracted from real time video frames, they can be distorted, blurred, dark etc. For example, images can be blurred in rainy weather. Similarly, images can be darker when captured at night time conditions or can be too bright when it is very sunny.
Therefore, different pre-processing methods are applied to the images to improve 20 the quality of the image that further helps in better analysis of the image and also the traffic area calculation.
Image pre-processing methods can be categorized according to the size of the pixel neighborhood that is used for the calculation of new pixel brightness. Every piece of video will need some preprocessing to some extent and the amount is wholly dependent on both the source video and the format. The following are some pre-processing techniques used in the proposed method: The input to a thresholding operation is typically a grayscale or colour image. In the simplest implementation, the output is a binary image representing the segmentation.

5). Normalization:
In image processing, normalization is a process that changes the range of pixel intensity values. Normalization is sometimes called as contrast stretching or histogram stretching. In more general fields of data processing such as digital signal processing, it is referred to as dynamic range expansion. The purpose of dynamic range expansion in the various applications is usually to bring the image or other type of signal into a range that is more familiar or normal to the senses. Hence, the term normalization.

C. Traffic Area Identification
After performing pre-processing techniques described above, the resulting image is ready for further analysis in order to identify the actual area of the road that is covered by vehicles. This study was carried out for a single lane. During the analysis stage, the value of pixels is scanned across straight lines originating from While scanning each pixel lying on these lines, it is required to identify whether that pixel represents a part of a vehicle or not.
When there is lesser traffic on the road after some point along the road, the values of consecutive pixels hold a value which equals to the pixel value of the road.
That is because from that point onwards no vehicle queue is presented on the road or the next vehicle might not still connect the queue as it is still coming or has some distance to pass in order to connect the queue. Hence, the queue length can be derived from the distance between the starting point of the traffic lights and the last co-ordinate of pixel of which the pixel value represents a vehicle.
A similar process was carried out across various lines on the road and then, returned to the length of the line which has the highest distance. This process was applied to all frames in the image sequence to take the highest distance of the line.

Results
Following are the green signal duration based on the several different traffic situations: the time represented here is in seconds.
In the actual fixed time scenario, the allocated green signal In this study, we assumed that this 60 second time is enough to pass the traffic within a maximum area of 200 * 945 pixels. After obtaining the actual traffic area (that area was also obtained in pixels) by using the method which is described above the green signal duration was determined as a portion of 60 seconds.
The following table shows some traffic area measurements and respective green time durations which were obtained using the proposed method:

30
The following Figure 14 depicts the relationship between the traffic area and the green signal duration which was generated by using this method: It is clear that the effective green light time was proportionate to the traffic area.
Hence, it can be concluded that the proposed method is accurate. The proposed system optimizes the average waiting time of every person present in the traffic.
It can generate the green signal duration intelligently by considering the actual traffic present on the road.
A simple analyzing method was used for analyzing the binary image in order to detect the traffic length. Moreover, a simple calculation was required to obtain the traffic area. Thus, even with less computing power, this method could work well.
The proposed system is very cost-effective compared to the other methods which are used in traffic controlling as it only needs a computer and a digital camera. Furthermore, the cost for Installation and maintenance is less than other technologies.

Figure 14. Relationship between traffic area and green signal duration
Traffic congestion is becoming a serious issue day by day since it can lead to many other problems. The main reasons for traffic congestion problems are insufficient infrastructure for transportation with the ever-increasing number of vehicles and inefficient transport management systems etc.
The current traffic controlling systems have been unable to provide efficient solutions for the ever-increasing traffic congestion. The main reason behind the failure of fixed time controllers, is that they could not adapt its time intervals according to the varying traffic patterns. Therefore, the waiting time of each vehicle in the traffic queue is increasing. This study showed that the image processing is a better technique to control the traffic congestion problem. It is also more consistent in detecting vehicle presence because it uses the actual traffic frames. Since it visualizes the reality, it also functions much better than those systems that rely on the detection of vehicles using a metal detector.
The method proposed in this study is control traffic in an intelligent way. It would basically reduce the vehicle waiting time at junctions. It can identify the actual area of traffic with which the road is covered, by using simple methods and it can allocate time for green lights based on the factor of the current traffic area. Thus, a road with less traffic will be given the green signal for a shorter period of time while a road with more traffic will be given the green signal for a longer period.
This system is initially developed for controlling traffic in a single lane. It can be further developed for handling traffic in a road with several lanes.
The accuracy of this method can be improved by concurrent analyzing of traffic videos from two points along the road thereby taking the mean value of the area covered by traffic. During the study, it is ascertained that the camera position is very crucial in getting accurate data. A higher camera position is necessary to detect the traffic area accurately.
It is a timely requirement to have the type of system mentioned in this study as this time saving factor will lead to efficient transporting, benefitting not only the vehicle users but also governmental and non-governmental sectors of the country (Rane R., Pathak S., Oak A. and Khachane S.,2015). Furthermore, saving fuel would benefit the entire vehicle users since the money that would be spent on fuel KALYĀNĪ: Journal of the University of Kelaniya, ISSN -2012-6859, Volume XXXIII (Issue I/II), 2019 32 will be reduced. Since the vehicles would spend lesser time at the intersections, a more eco-friendly environment will be created thereby lifting the living standards of the people.

Conclusion
The results show that this method has acquired its objectives by successfully eliminating the wastage of effective green time and controlling traffic in an intelligent way. This method provides an efficient solution regarding the traffic congestion problem. The proposed method is beneficial and with some improvements, it can be used to create a fully completed intelligent traffic controller which can adapt its time intervals according to real time traffic present on the road.
This work can be enhanced further by proposing a system which identifies the presence of emergency vehicles such as ambulances or fire brigades and give preference to those lanes with emergency vehicles to pass the traffic (Khanke P. and Kulkarni S., 2014).
In addition, any future work can involve further image processing that would provide better results including night time images. Through these means, traffic can be controlled in the day time as well as night time.
In addition, this work can be further expanded by implementing this technique with the real time online image sequences and can be used to create a perfect traffic controlling system.