Traffic Congestion Avoidance System Using Foreground Estimation and Cascade Classifier

In recent decades, the traffic on road increased in a huge number. It is very important to manage the safety of the humans as well as to make an efficient flow of the traffic. To manage the traffic flow and to overcome from the situation of the traffic congestion the vehicle detection and counting needs a greater amount of accuracy. In this work, two different techniques are proposed that provides better performance in terms of F-Measure score and Error Ratio. The first technique is based on the foreground estimation while the second proposed technique is based on the training of dataset using a cascade classifier which is based on the Histogram of Oriented Gradients (HOG). Furthermore, four images are provided at once to the proposed system to count the vehicles and generate a signal that shows a greater number of vehicles in that image. The priority of each image will be set on the basics of greater number of vehicles present. The proposed techniques showed outstanding performance on a sunny and a cloudy day which is verified from the experimental results.


I. INTRODUCTION TO TRAFFIC ON ROADS
Traffic on roads mostly consists of vehicles. Traffic Laws are governed for proper and timely flow of the traffic. In many developed cities well established signals and lanes are properly marked for the flow of traffic. But with an increase in population, the number of vehicles has also increased. In some situations, the traffic has increased so much in many cities that it leads to the congestion. Due to this congestion some of the drivers do not follow their lanes which leads to many accidents.

A. CONTROL OF TRAFFIC FLOW
Traffic rules are the most important part of any society and it is the responsibility of everyone in the society to follow The associate editor coordinating the review of this manuscript and approving it for publication was Tomasz Trzcinski. these rules properly. These rules are designed so that there should be less risk factors related to accidents and jam. Traffic rules are also important for the proper functionality of the traffic to avoid traffic jams. The traffic jam mostly occurs due to the improper flow of the traffic at the junctions. If one needs immediate treatment and wants to go to the hospital as soon as possible but just due to traffic jam one in unable to reach the hospital timely, and it can also cause serious issue. Also, everyone is in a hurry and wants to reach to his/her destination as early as possible. This could only be done if there is a proper control flow of the traffic to avoid from such situations. Traffic signals provide a good control of traffic at the intersections. It is very necessary to maintain a good flow of traffic at the intersection. The traffic signals are of huge advantages. A signal is able to stop the traffic from some end and allow the flow of the traffic from the other end which helps the pedestrians to cross from one side to the other. This VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ is therefore a continuous movement of the traffic in a regular manner. Besides the advantages of the traffic signals there are also some limitations of the traffic signals. For instance, if the traffic signals generate the wrong signals or sometimes the lights get malfunctioned it will adversely affect the flow of traffic and the efficiency of the proper movement at the intersections. Besides two more disadvantages of the traffic signals are: 1. It will increase the traffic congestion, fuel consumption, and increase the air pollution in the society.
2. A specific time is allocated to the flow of traffic from one side and this leads to excessive delays for the other side if there is no traffic on the current active signal side.
To address the disadvantages of the traffic signals research is being carried out using the image processing techniques. These techniques are the advanced techniques and used for solving real life problems. These advanced techniques are more powerful, and we can adjust these easily according to our needs. In order to maintain a reasonable and proper flow of vehicles on traffic lights signals the counting of vehicles (number of vehicles) should be more accurate. This can be understood in a better way by considering a scenario in the intersection depicted in Fig. 1. In this situation a traffic light is allowing traffic from all four side (roads) to maintain a proper flow of traffic as well as to minimize the delay between the vehicles. This delay can be minimized if there is no vehicle present on any road so, a signal will be generated, and this specific time is allocated to the next road to allow the traffic flow through it. If the vehicles are detected correctly, then it is very easy to generate the proper flow of the traffic.

B. INTRODUCTION TO DETECTION
In computer vision it is a very difficult and unsolved problem to recognize objects in different classes due to the huge variety of different classes as well as in sub-classes. Different research has been made in the past few years in area of face recognition due to the similar structure of the face. The detection of other objects is a very complex task due to the presence of their large variety.

C. INTRODUCTION TO VEHICLE DETECTION
Vehicle detection is a very complex tasks and many tasks are carried out in this field of image processing and computer vision [1]- [4]. If we take the example of vehicles detection in the specified image than it a very complex task to detect color on the basis of shape or color because the vehicles come in different shape, size, color and models etc. This work is based on the detection and counting of vehicles so that will be helpful in flow of traffic. This vehicle counting will play an important role in the control of traffic flow.

II. RELATED WORK
Onoguchi [1] calculate the Traffic Volume by Time Series Images Created from Horizontal Edge Segments. Their method is robust in term of vehicles overlap and sudden brightness changes. However, they do not consider the motorbikes in their traffic volume. Also, the FP and FN occurs due to the vehicle speed changing rapidly.
Velazquez-Pupo et al. [2] used the blobs that are extracted from the foreground mask and further the morphological operations are done to avoid the noise and also enhances the shape of the detected vehicle. However, in their method it is complicated to distinguish multiple vehicles in the case of vehicle overlap.
Authors in [10] proposed a Model-Predictive Control system to reduce the traffic congestion in the urban traffic network. A tradeoff between the reduction of the congestion and of the total emission is also balanced by using a new smooth integrated flow-emission model.
Authors in [11] have used adaptive background subtraction and shadow elimination method for counting purpose which counts the vehicles in a video display. This system is designed on ARM/FPGA processor.
Negative prospect is the high cost of systems [12] like these when installed in urban areas. Mostly widely used sensors in traffic monitoring are surveillance video cameras that provide videos for the purpose of detection and counting vehicles, but there exists a gap including occlusion, cloudy weather, shadows, and limited view.
In 2017, Gill et al. [13] proposed a system for the vehicle detection that used satellite images. In their proposed design they first enhance the image, further this image is converted into the grey scale and then into binary image. The images are then further processed using the canny edge detector and the morphological operators. In the last the blob analysis is used for the vehicle detection.
An autonomous system has been proposed for vehicle detection having different size in low-resolution aerial imagery [14]. First, multiscale Hessian analysis is used to design filter which enhances the vehicle detection. Second, based on bilateral summary the detection was being made clear in order to detect the vehicle. The proposed work has improved the accuracy in term of detection as compared to previous work.
Seenouvong et al. [15] detected the vehicles in surveillance video sequence by subtraction method and centroid of objects in virtual detection zone is calculated for counting purpose. Thought this study is very useful for traffic monitoring for tracking on monitoring purpose but still it cannot be applied for monitoring purpose in large area with heavy load.
Mahabir et al. [16] has used Operation of object spectra and image morphology for the detection and identification of vehicles from RGB images with enhanced results of 62%.
In [17] an algorithm has been proposed deployed on the aerial images for object detection. This autonomous system uses morphological recognition in which input image is taken in the RGB scale and then the conversion from RGB to Gray scale is carried out. The current frame of the image is complemented and then the binary conversion is applied on the dilated image. After this process vehicles size to be detected enlarged and can be identified a bounding box.
In [18], Support Vector Machine (SVM) has been used for the detection of the vehicles also the occlusion handling is done here. Authors in [19] has designed a method to detect the vehicle using image gradient with vehicle counting addition.
Various background subtraction methods are shown in [20] which include are Adaptive Background Learning, Gaussian Mixture Model, and Multi-layer Background Subtraction.
Zheng et al. [46] propose a new method by using a ResNet encoder to model spatial information, and a Conv LSTMs-based decoder to model temporal information.
In 2014 another system is designed using image processing techniques to detect the vehicles in real time in a highway. In this technique the whole process is implemented on a single image individually. So, the vehicle is detected on all images. After the detection process total number of detected cars will be counted on each image and a threshold value is also initialized so that if the total number of cars cross this threshold value then a warning will be generated. This warning showed that the traffic on that image is heavy [22].
The GRAM Road Traffic Monitoring is used for the vehicle detection and counting, and it is adopted by many recent researches for the evaluation of the proposed techniques [23].
In 2013 another implementation is done that used Histogram of oriented gradients as well as the Haar features for the detection of the vehicles. Haar features will be the helpful features while the HOG used that Haar features to detect the vehicles. This method not only detected the vehicle but also classify these detected vehicles into two categories. The classification is done on the basis of the Haar features and the HOG features. The advantage of this technique is that it can detect multi-orientations vehicles and also the classification of these vehicles is good [24].
In 2020, a Broad Learning System is examined for the prediction of the traffic [25]. The Broad Learning System is fast method in terms of the training time and testing accuracy.
A shadow removal algorithm with the help of the color-based background subtraction model is developed in [26]. The foreground estimation model is used for the detection and counting of the vehicle are the entrance points [27].
In 2012, Zezhong Zheng proposed another technique for the detection of vehicles. Their design used aerial image from the highway and then they detect the vehicles from these images. In their method a GIS road vector map is used that will limit the vehicle detection to the networks of highway management. Furthermore, they used the morphological operations to identify a vehicle. The resolution of the images that are used in their technique is of.15 m. the results that was achieved by them is very promising that shows that their demonstrated method is very good in terms of the performance [28].
A novel two-layer approach is used for the modeling of traffic flow in the urban areas [29]. This research showed promising simulation results.
In 2010, Yan Liu et al. [30] proposed a system using image processing to detect the traffic. This system was based on a Quasi-shot Segmentation Vehicle Detection (QSVD) that was helpful for the traffic flow. Their system also improves the accuracy and the robustness of the detection. This method is based on the histogram intersection method that find the maximum distance between the two consecutive frames. So, in that way a vehicle is detected in the current frame. Vehicle detection using Background models are presented in these [31]- [34]. All these papers did not handle the occlusion.
The foreground estimation and the morphological (i.e., opening and closing) can be used to isolate vehicle shapes: To detect the foreground object, the image are first converted to grayscale. The successive pixels values in a current image frame are subtracted from the next image frame and give the foreground and background areas in white and black respectively. A threshold value is set to distinguish between the foreground object from the background [35]- [41].
Block sparse RPCA algorithm and low rank representation with UAV have been used in order to count the number of vehicles [42] but the drawback of this work is that UAV takes static images only. Also, the method is not effective to differentiate between the direction and distinctiveness of vehicle resulting in counting mistake. A simulation-based design of the biomedical sensor [43] is presented that will help the public in the near future. The main focus is to study the behavior of relative intensity noise to make the sensor more stable. Cloud and fog computing is widely used in human's lives and it is considered to be the growing demand in the future [44]. In 2010, Jain and Rani [45] implemented an algorithm for the vehicle detection as well as the vehicle classification by using the fuzzy logic. Due to the fuzzy logic the overall complexity of the system increases also the performance of the system was enhanced and it detected the vehicles is a difficult scenario. After the detection process these objects are then classified using neuro-fuzzy etc. In this implementation both the supervised and unsupervised VOLUME 8, 2020 learning is used to train the system. This algorithm is implemented on the real time projects.
A Cognitive Adaptive Optimization can deal with the complex daily life problems. The traffic congestion problem in the urban areas is minimized by managing the traffic light parameters [46].
In 2020, Masud et al. [47] perform special test for the manufacturing of the medical sensor to help the general public. The control system of the setup involves optoelectronic components like fibre Bragg gratings, optical amplifiers and optical couplers that have been mechanized by implementing newly developed algorithms in software (LabView and MATLAB).
In 2013, Sindoori et al. [48] proposed a technique for the vehicle detection. They used the satellite images for the vehicle detection purpose. They used pixel wise classification method for the vehicle detection. The main part of their approach is to extract the features from the image and then classify the vehicle color. Edge and corner detection techniques are used for the extraction of features. The edge detection is done by using the Canny edge detector. The corner detection is done by using the Harris corner detector. For the extraction of the vehicle color adaboost algorithm is used. This adaboost will separate the vehicle and non-vehicle color. After all these detections the morphological operations are performed that enhances the vehicle detection.
Integration of additional prediction layers into conventional Yolo-v3 developed by Kwang-ju Kim et al. (2019) used spatial pyramid pooling [49] to complement the detection accuracy of the vehicle for large scale changes. They have also discussed that the proposed architecture shows a mAP detection ratio against the other vehicle detection with improvised speed of run-time.
In 2014, Sharma et al. [50] used morphological operations in their technique to detect the vehicles. Their algorithm is capable of to detect the vehicles automatically from the traffic images. Furthermore, they showed the comparison between different previous image processing-based method with their implemented method. The results section showed promising results than that of previous image processing-based methods.

III. PROPOSED TECHNIQUES
This section presents two proposed techniques that will detect and count the vehicles so that this counting will be helpful in the real-life application to control the traffic flow in an intelligent way.

A. PROPOSED TECHNIQUE 1
The first proposed technique comprises of the pre-processing block, image subtraction block, and the detection and counting of vehicles block. The architecture of the first proposed technique is shown in Fig. 2.
As shown in the structure of the proposed system, the input of the system is an image that passes through the pre-processing block. After passing through the pre-processing block the image goes into the image subtraction block where the current frame of image is subtracted from the ground truth. Finally, the images go into the vehicle detection and counting block where the vehicles are detected and counted to provide the final output. The process flow of the first proposed technique is shown in Fig. 3. Pre-processing in an important step to further carried out the implementation process. Due to pre-processing the image will be enhanced such that it will easy to detect and count the exact vehicles and increase the true positive in the proposed technique. The components of the preprocessing block are shown the Fig. 4. This is the first step in the pre-processing stage. In this step the image is scaled to a constant size of 240 rows and 400 columns so that if the camera is changed and the capturing size of that image is different our algorithm is still robust enough to accommodate this change. The formula that is used to do the image resizing is shown below.
where, gt is the image that need to be re-sized while gtr is the image the contains the re-sized image. The second main step in the pre-processing block is the conversion of RGB image into to YCbCr color domain. The purpose of this conversion is that the luminance will be separated from the chrominance. The luminance is the intensity of light and it ranges from black to the white. So, if the luminance is separated then we can detect the vehicle more accurately. The formula for the conversion of RGB into YCbCr domain is shown below. The second step in the pre-processing stage is to pass the image from the median filter. The advantages of passing the image from the median filter is that it removes the noise from the image as well as it enhances the edges and makes the edges sharp. The sharp edges will be helpful in detecting the vehicle. The formula for the median filter is shown Here we have two images named Image1 and ImageGT. The Image1 is the image that is generated by the pre-processing block after carrying out different operations on it. The ImageGT is the image that is the image of road when there is no vehicle present on it. Image1 is subtracted from ImageGT which results in the region that is present in the Image1 and not in the ImageGT. A threshold will be set according to the current situation. After subtraction if the value is greater than the threshold value then that pixel is considered to be the foreground pixel Fig. 5. Now the vehicles will be detected by using the operation as shown in the Fig. 6.
Overall image contains such regions that are not necessary for examination in traffic scenario. If we are examining the load of vehicles on one side, then we will not consider the other side of the road. So, to eliminate this region and operation is carried out between the original image and the masked image. After the and operation the masked region will be placed on the image portion as shown in the Fig. 7. Due to this it will be helpful in the further detection of the vehicles, where, C is the dilated image and C1 is the mask. The last process used in the proposed technique is the usage of the region props in the implementation. This is used to draw the bounding boxes across the vehicles, and it will also count the total number of vehicles in that current image. As shown in the Fig. 8 the vehicles will be detected and counted. The total vehicles present in the original image is 3 and the proposed technique also detect and count all three vehicles.

B. PROPOSED TECHNIQUE 2
The second proposed technique consists of two phases.
1. Training Phase 2. Testing Phase The architecture diagram of the second proposed technique is shown in Fig. 9.
This proposed technique works on the following steps.    The first step of the second proposed technique is to train a cascade classifier by providing positive and negative samples. Negative samples comprise of images in which no car is included while the positive samples include the images in which car is present and labeled accordingly. The block diagram of the training phase is shown in Fig. 10.
In the proposed technique no already labeled data is used. So, for the labeling we used 1000 images and from those images we labeled 1449 vehicles. The training of a cascade object detector requires positive and negative samples. After the collection of the positive and negative samples, the preferred feature extraction method and the total number of cascade stages will be decided.
For the training purpose, no pre-trained model is used. The training is based on different types of vehicles to achieve better results. Some of the training vehicles are shown in Fig. 11.
In the testing phase the trained model designed in the training phase is used. The block diagram of the testing phase is shown in Fig. 12.
The detector will run on the supplied images by sliding the window and check whether a positive sample is present in that region or not. As soon as the positive instance is found, the rectangular box will be made on that region and also the counting will be started. After this the sliding window will move on the next portion of the image and the above same process will be repeated until the sliding window will cover the whole image.
As shown in the Fig. 13 the vehicles will be detected and counted. The total number of vehicles present in the original image is 3 and the cascade classifier also detects and counts all three vehicles.

C. CONTROL OF TRAFFIC FLOW
To control the traffic flow based on the results of the vehicles detection and counting, the procedure that shows the different roads is shown in the Fig. 14.
The block diagram of the control of traffic flow is shown in Fig. 15.
As shown in the above block diagram four images are provided to the proposed technique as an input and the total number of vehicles detected by each road is considered the      output. The output from the four images is supplied to the traffic signal so that it will allow the traffic flow accordingly to maintain a proper traffic flow as well as to minimize the delay. The array consists of 4 elements, i.e, the total number of vehicles from each four roads. In order or set the priority of each road to assure the flow of traffic from that particular side, the algorithm will be used which is robust enough to deal with this scenario. This is the same principle which has been already mentioned in Fig.1. After using different algorithms, the best output in minimum time is generated be the selection sorting algorithm. So, the selection sorting algorithm will be helpful in setting a priority of each road. The reason for using this algorithm is that it performs better on a small data (4 array elements) and it does not need any additional temporary storage. After assigning the priority to each road this output is provided to the traffic signal to maintain the traffic flow accordingly. The road with the higher priority will be open and the traffic will flow through it. The remaining three roads will be in a queue to wait for their turn. In this way the congestion of the traffic is minimized as well as the proper flow of the traffic will occur. After the traffic flow of all four roads the new four images from each road are used as an input and again the priorities will be set according to the density of traffic in each road. The image from each road is initialized and the vehicles will be counted using the proposed technique. The total number of vehicles of each road will be stored in an array. The flow chart is shown in the Fig. 16 that is used to set the priority of roads by using selection sort algorithm.

IV. TESTS AND DISCUSSION
Accuracy test is used for the evaluation of the proposed techniques. Accuracy tests will determine the reliability of the proposed techniques in terms of the Precision, Recall, F Measure and Error Ratio.

A. ACCURACY TEST
The proposed two techniques are evaluated by using the following formulas where, • TP is the number of vehicles detected, • FP is the number vehicles detected but in reality, these are not vehicles, VOLUME 8, 2020 • FN is the number of vehicles present but not detected, • D GT is the total number of vehicles present, and • D Det is the total number of vehicles detected i.e. TP+FP GRAM Road Traffic Monitoring (GRAM RTM) is used for the implementation of the proposed techniques. The M-30 dataset contains a total of 7520 images that are captured on a sunny day. The vehicles are captured from the back view. The camera used in this dataset is the Nikon Coolpix L20 and the resolution of this camera is 800 × 480 @ 30fps. The M-30HD image sequence contains a total of 9390 images that are captured on a cloudy day. The camera used in this dataset is the Nikon DX3100 and the resolution of this camera is 1200 × 720 @ 30fps. The detection and counting of vehicles on different images of the M-30 and M-30HD image sequence are shown in the Figs. 17 and 18 respectively.  The result of the control of traffic flow is shown in the Fig. 19. In the priority diagram, it is shown that the 6 vehicles, 5 vehicles, 4 vehicles and 3 vehicles are present on Road 1, Road 2, Road 3 and Road 4 respectively. In such a scenario, therefore priority of the traffic flow will be based on the greater number of vehicles. Fig. 20 elaborates the behavior of the priority if two or more sides are equally congested. Here 6 vehicles are present on both Road 2 and Road 4 so, the priority will depend on the sequence of the road image provided to the algorithm. In this case the Road 4 image is provided to the algorithm after   Road 2 due to this reason Road 2 will be of higher priority as compared to Road 4 and after that the traffic will flow through Road 1 and Road 3. The performance of the two proposed techniques are compared with the two recent method [1], [2] both by using the GRAM-RTM dataset for the evaluation. The GRAM-RTM dataset [23] is publicly available and the download details for the dataset is provided in the said work.
The comparison will be done on the basics of the parameters i.e. Precision, Recall, F Measure and Error Ratio. It is      The future directions are to implement the proposed techniques in a real time to maintain the traffic flow and to avoid situations of congestions. Also, the priority of traffic flow will be given to the emergency vehicles side in case of same vehicles on two or more sides. Furthermore, algorithm will be developed in the future to update the ROI automatically with the changing weather, to be used in biomedical sensor [51]. Also, the priority for the traffic flow will be changed if there are any emergency vehicles are present.