Intelligent Traffic Light Controller using Fuzzy Logic and Image Processing

Today's traffic congestion in the big city is a serious problem, as it causes a lot of environmental pollution and difficulty in transportation, which leads to difficult daily life for the human beings in addition to material losses. In this work a smart traffic light controller was designed using fuzzy logic and image processing with MATLAB, to control movement in two ways, aided by a camera and auto sensors. The Fuzzy logic has two inputs and six outputs designed, the console input is the number of cars on each road and the time of the assumed red, yellow and green signal according to the vehicles congestion. The simulation result is similar to the proposed control unit, as it deals with the lights simultaneously according to the number of cars in each branch of the road, which leads to the use of all the time to operate the stoplights. Our system can be employed in solving the problem of traffic congestion in the big cities or the


I. INTRODUCTION
Traffic congestion in many modern cities around the world is a severe problem. Many critical problems and challenges are caused by traffic congestion in the large and densely populated urban areas moving to different places with the abundance of cars in crowded cities will become more difficult [11]. Due to these traffic problems, people lose time, miss opportunities and get disappointed. Overcrowding directly impacts companies. Due to that, there is a loss in the productivity of workers, and opportunities are lost, delivery gets delayed and thereby the cost goes on increasing. To solve efficiently these congestion problems, we designed an intelligent traffic control system. The essential goals of this paper are to improve safety, minimize travel time and increase the capacity of infrastructures [6]. Our case in Al Madinah, Saudi Arabia is that there are unlimited visitors during the Haj and Umra seasons, which increases the traffic congestion. A proposed fuzzy controller to control the car stream and traffic congestion [10] is related to the number of cars and population and road size in Al Madinah and Makah cites. They are a different case. First at the end of working days, in the morning, during the end of the weeks and holidays, a huge number of people come to the Al Haram. In addition, the unlimited number of cars which cause traffic congestion, and the number of visitors will be increase in Ramadan and Haj seasons. For these reasons, traffic control is a big challenge for these two cites. Everyone can repeatedly see that there are really traffic problems. Our proposal to solve this problem via using artificial intelligent.
Our controller is designed with fuzzy logic control [9], and at each stop there are multiple sensors and cams to capture photos and images. The processing algorithm is used to detect the number of vehicles in each direction. And we used an optical sensor equipped with cameras to detect the number of cars coming to the traffic light, and another to detect the number of cars leaving. The number of cars in the signal can be calculated by subtracting the number of cars entering from the number of the exiting ones [12]. This process is repeated for each road, and the total entries for the first and second roads are the fuzzy logic inputs. The fuzzy Controller is designed to estimate the traffic time according to the number of cars at each road irrespective of the fixed time [1]. The simulation result shows an excellent result, and the program can be designed and runon microcontroller of PLC and/or any other controller. Also, instead of an optical sensor, a magmatic or ultrasonic sensor can be used. Many researchers and papers focused on the study of traffic light and control. Conventional traffic light control system currently handles traffic at one junction. However, the synchronization of traffic light systems still caused congestion within them. This work proposes a system based on a microcontroller that controls the intensity of traffic using infrared sensors and achieves dynamic time slots at different levels. Also, the portable controller will solve the problem of cars stuck in traffic, which will benefit the economy, society and the environment. This paper discusses a solution that uses a Special Purpose Simulation Tool (SPS) to improve signal light timing at multiple signal and intersections [2]. Autonomous vehicle and driver assistance systems use various sensors such as sensor and radar to detect their surroundings, but they cannot detect standard traffic lights. To solve this problem, a previous map booth is used to predict the location of traffic lights.
Traffic congestion due to inadequate space and funds has led researchers to think of a solution to reduce it. The solution is using intelligent system. One of them is the use smart traffic light (STL) and wireless sensors network (WSN) [3]. The WSN collects data about traffic lanes in real time in terms of traffic quantity (TQ) and waiting time (WT). It then computes a priority degree (PD) that determines order of green light assignment [4]. For the past years, traffic signal control system was static and not efficient. For a better traffic control, there should be a more efficient and dynamic system that handles traffic easily and more safely. This system will be better particularly in the performance of traffic intersections control [5]. The main objective for this study is to introduce a new traffic signal controller based on fuzzy logic. In the second part www.ijacsa.thesai.org of the study, the before-after measurements are introduced. This paper proposes a traffic signal synchronization system which inputs real-time data using fuzzy logic. The paper also uses Q-learning module, so the system learns by is self by updating the set of role base [8].
This paper is organized as follows. In Section 2, the proposed modules will be presented with, in particular the intelligent fuzzy logic controller design. Section 3 describes the membership function Triangular types of function are used. Section 4 presents the fuzzy rule base and establishment also the result of MATLAB simulation.

II. PROPOSED MODULES
The present traffic light depends on fixed time for each road. The first road, Ro1, has three signals (R1, G1 and Y1); the second road has three signals (R2, G2 and Y2). The controller is programed with fixed time for each pair (R1and G2) having the same time. Also (R2 and G1), the third signals yellow once both (Y1 and Y2) have the same timing at all time. The duration of each one is with a fixed time all the time, and it will be monitored just manually by a policeman. Our proposed system (artificial intelligent control) is fuzzy logic controller with multiple sensors and cams distributed around the traffic signal at each direction. The function of each sensor is to sense if there is a car or not and if any car entered the target zone, in which case the sensor activates the camera to capture a photo, and the photo is processed and the number of cars on the photo are calculated. The same mechanism is applied to each road, and the signal time for the road is not fixed. It depends on the number of cars on each road at a time, and the time must be set by the fuzzy logic controller which depends on the design of the fuzzy rules and the number of cars at each road. Fuzzy logic has been used extensively to develop a traffic light controller because it allows the qualitative modeling of complex systems that are difficult to solve using classic mathematical models. It is also good for systems that have multiple changes at a specific time. Several researchers have proposed traffic light control systems using fuzzy logic. They proposed FLSC for a 4-way isolated intersection from East / West / North and South without moving traffic. This generally provides better performance for FLSC compared to fixed time and actuated controllers. Today, all FLSC research work has developed based on unstable traffic conditions especially in developed countries, [7]. The main objective of this research is to design an intelligent fuzzy logic controller to control four way traffic light. MATLAB fuzzy logic and image processing tools books were used for simulations to examine and analyze the effectiveness of the proposed FLSC. Then, the optimal performance of the proposed controller is typically contrasted with an optimized fixed time.

A. Design Criteria and Constraints
The following assumptions have been made to develop a fuzzy logic control system for traffic lights:  Interchange: It is a four-way intersection between the traffic coming from the direction of the first road (north, south) and the second road (west and east).
 When traffic moves from north and south it stops from west and east and vice versa.
 The left and right turns are not considered.
 Fog logic unit inputs from the first and second paths taken from sensors and cameras.
 The picture is taken from every point of view and is usually from several cameras.

B. Design of Fuzzy Logic Controller
Two fuzzy logic controllers were designed for controlling the flow of two ways (road one RO1 and Road two RO2) Fig.1, with six traffic signals (green one, green two, red one , red two ,yellow one and yellow two). The number of cars on road one can be calculated by fixing a sensor 30m from the signal. Road one is assumed with three sub roads with full capacity of 24 cars, and road two is assumed with two sub roads with maximum capacity of 16 cars as represented of fuzzy logic input. There are many sensors at each road, and the function of the sensor is to activate the camera to capture cars photos then process them to calculate the actual number of cars in the specific zone and activate the controller to adjust signals time.

C. Fuzzy Logic Input and Image Processing
The number of cars is a very important and complicated topic. If any car appears in the cams zoom, the first optical sensor or ultrasonic or metal detection sensor is used to activate the camera to capture a photo. for the specific. zoom in which the car is detected, then it is sent to the processor to filter , and is converted to the black and White color. Then the surrounded edge is detected as in Fig.2. and the inter space is filed with identified color to calculate the number of cars. We can calculate the number of objects on the processed image [13].  III. MEMBERSHIP FUNCTION In this work, we used a triangular membership function due to their computational efficiency. The membership function for each input-output ambiguous variable in FLSC is as follows:  Membership function for the number of cars on two roads.
(Road one RO1and Road twoRO2)  Membership function for the output traffic signal.
(R1,Y1,G1,R2,Y2and G2) The number of cars on the first input Road one RO1 is {C1, C2, C3, C4,C5,C6,C7 and C8}, the second roads RO2 is{C11,C22,C33,C44,C55 }, the total capacity of the cars on the roads covered by the cams zooms are assumed to be 24 on RO and 15 on RO2 respectively. Traffic signal time has linguistic variables as in the Fig.3. The potential membership function of the number of vehicles standing in line is represented in the line at traffic lights as shown in Fig.4. After the sensor activates the camera to capture photos from the road, it is processed in many steps: first converted to black and White photo, filtered and edged, detected and filed as objects then functions are used to calculate objects on the road as in Fig.2.  IV. FUZZY RULE BASE AND ESTABLISHMENT The basic function of the fuzzy rule base is to represent the expert knowledge in a form of IF-THEN rule structure combined with AND/OR operators [8]. For e.g., IF the number of cars in road one is C3 and in the second road is C11, then the output of traffic signal is adjusted according to the number of cars in each roads Fig.5. The fuzzy rule base is set of fuzzy rules. It maps the combination of fuzzy inputs (number of cars on each roads) to the corresponding fuzzy output (signal times of RYG) Fig.6. In this paper we consider different membership of cars number and different time zoon, changed according to the Traffic congestion.
In our work this with different inputs, the extension time (z axis) is small when the access density (y axis) is small, and the queue side density (x axis) is also small Fig.7. This indicates profit for time, unlike the other method, where on the three axes the growth is external time. In other words, the outside time grows slowly because it is large only when the reach side density increases, and the intensity of the queue side is constant. Another advantage is if the access side density is constant and the queue side density increases, then the rollover time shifts to medium to short. This is an important difference between the other methods, especially in the fixed time system.   V. CONCLUSION The system proposed here is very flexible. The fuzzy logic controller inputs can be taken from images taken from cameras fixed at each road. Due to the flexibility of fuzzy logic in dealing with stochastic systems, the traffic light control system showed good results in our simulations. The proposed FLSC is operated properly and efficiently in MATLAB environment. This controller gives a suitable green flexible timing that depends on the number of cars in each road, which can ensure vehicles are not allowed to wait too long on the road. While in the case of fixed time controller green time cannot be changed automatically, our system will give the green time according to the traffic congestion. So, arriving cars must activate the traffic signal time. The performance of the FLSC is affected by traffic congestion. The fuzzy logic control system has proven better in terms of improving the flow of traffic lights in the cities of Madinah and Makkah cities. In the future, this system will be proven on datasets from other countries, and to provide better results it will include a tracking stage to determine the traffic situation on the road before arriving at the traffic light is reached.