Paper —On-Board Video-Evaluation Algorithm of Transverse Safety Clearance for Ahead Road-Vehicle On-Board Video-Evaluation Algorithm of Transverse Safety Clearance for Ahead Road-Vehicle

—Traffic flows are becoming more intense over time as a result of global automobilization. Road transport specialists are developing and analyzing different approaches to control traffic, to design and to build new highways. De-creasing total amount of accidents and congestion avoidance on a road are the main goals of this research. General traffic flow features and car localization are the most important types of data to be obtained, processed and analyzed in modern conditions as cars are highly maneuverable. Proper usage of this data allows building new high-quality traffic control systems taking in account all of its significant features. We have developed a system for video-processing from camera fixed on car torpedo. Research presented in this paper suggests an algorithm of transverse safety clearance evaluation by analyzing a video from vehicle on-board camera.


Introduction
Computer Vision (CV) has gained a lot of attention and popularity as high-quality data and devices which allow to process and manage them have appeared recently. There is huge variety of problems from defect detecting to self-driving vehicles in computer vision. Industry which offers a new challenging and exciting tasks for developers is the main driver of this field. Driver Assistance Systems (DAS) are one of the biggest achievements in industry and Computer Vision has allowed to drastically increase the quality of such systems for the past years. DAS aims to minimize human error which often leads to road accidents. Modern systems are capable of solving various tasks that are critical for road safety.
Road safety has always been an important part of engineers' work as car accident number increases over time and it leads to death rate on a road to be higher. It is necessary to find new approaches for traffic control problems and try to minimize number of accidents.
Research group by head of A.P. Buslaev and M.V. Yashina have worked on traffic flow models and experimental study on its verification. As a result, Department of Higher Mathematics of ADI developed products that allow to model traffic flows [ [1], [2], [3]], to obtain their characteristics, to extract information about road signs [ [4], [5]], to estimate the distance to the leading vehicle, etc. A big contribution has been made by mobile laboratory which allows to analyze traffic, get characteristics of traffic flow and road pavement. There are many problems that have been solved using intelligent systems, but there arealso a huge amount of task that have been solved with significant constraints or not solved at all. For example, vehicle ahead tracking allows to evaluate the behavior of the driver, as well as the distance to its vehicle, and to warn if an emergency situation is possible. But dangerous driving is not the only cause of an accident. A large amount of accidents caused by incorrect road design.

Problem Specification
Record from an onboard vehicle camera is an input data. Each frame represents vehicle ahead moving the same lane (without lane changing) as the vehicle with a dashcamwithin danger areas. We define these areas as ones with high probability of getting close to road marking or even cross it. Operator (driver of a "follower") tries to keep a safety distance between cars and also the distance which allows to analyze road markings and vehicle ahead. It is necessary to get an estimation of transverse safety clearance ( Figure 2) between marking line and vehicle. We obtain an estimation values when process the video and then plot the graph. This graph represents changing of clearance values. By analyzing this graph, one gets information about danger areas' location.
It is really hard to get an exact value of transverse clearance as input data is a record from a dashcam and its why estimation is utilized. But method also has a big advantage by using an estimation of the value it is possible to process video in real time and get values for a large amount of frames. Researched methods allow to determine clearance between the vehicle and the markings, which helps road workers to identify problem areas on the road. For example, if the graph shows that a car often goes behind the markings on a certain section it is necessary to make a decision to reorganize the traffic on that section or to reconstruct it.

Transverse Clearance Estimation Algorithm
Input data is a fragment of video about 1 min. long. It is necessary to estimate the clearance throughout the video. Each frame is representable as a tensor А(n) = { !,#,$ }, wherei = 1,…,m, j = 1,...,n, ak = 1,...,c. m -number of rows, n -number of columns, c -number of color channels аndn -frame number. Computer vision algorithms should be used for feature extraction from an image. These features will help to estimate safety clearance -distance between vehicle and lane marking lines.
We use a sequence of transformations and apply them to input data. Algorithm based on utilizing of color features. M. V. Yashina et al. have shown in [ [5]] that color features extraction doesn't work properly in some cases as environmental conditions can affect them really much. Image is masked to extract colors of the road marking. This operation leaves on the image only the values that lie within this range, assigning other pixels the values of black color. After the mask is applied, the image translation into Grayscale, Gaussian Blur, Canny Filter and Probabilistic Hough Transform are applied sequentially. In order to convert RGBimage toGrayscale, gray intensity I(x) in pixel xis represented as weighted sum of Red, Green and Blue values: Studies have shown that red and green channels give the best contrast for road marking. That's why ω % andω & are equal to 0.5, а ω ' = 0.
To detect edges on images Canny Filter has been used. This filter detects only road marking as application of mask to the image on the first step left only road markings objects. Canny filter consists of the following steps: 1. Apply GaussianFilterin order to reduce the noise. 2. Applying SobelFilter to detect road marking edges and find intensity gradients of the image. 3. Apply non-maximum suppression to get rid of weak edges. It helps to detect strong gradients while smaller ones getting near-zero values. 4. Doublethresholding. This step helps to classify edges. Find the strongest one, weak and false, which will be assign to zero. 5. Finalize the detection by one more suppresion.
Sobel filter(operator) is a critical part in Canny Edge Detector. It uses two kernels (2) to convolve input image and calculate intensity gradients. (2) Probabilistic Hough Transform allows to find the coordinates of vectors which form straight lines on images after edge detection algorithms. These lines are the boundaries of road markings. Probabilistic Hough Transform is a probabilistic modification of classic Hough Transform. It is faster than the classical method as the transformation is performed not for all points but for a fraction of the total number (α). The main assumption is that it is sufficient to apply the transformation to a part of points from the image, and if there are lines on them, these lines are very likely to correspond to the line found in the original image.
The idea of Hough Transformation is that for each point of the parameter space the number of votes submitted for it is summed up, i.e. the number of points of the source space generating in the response parameter space the responses passing through this point (ρ,θ). Here we use the fact that any two sinusoids in the parameters space intersect in a point (ρ,θ) only when the generating points in the source space lie on a line described by the equation: with parameters (ρ,θ). The function (3) is called a battery function, and its absolute value in a point (ρ,θ) is equal to the number of points of the contour preparation lying on a corresponding line in the initial space of the image.
In the case when m lines are represented in the image, the battery function (3)  -distance from line to origin THETAQ -discrete angle between rows direction and perpendicularto a line from an origin You also need to know the width of the vehicle to understand the clearance (by comparing clearance value with the width of the vehicle). For this purpose, a method based on three rectangles is used. A rectangle is a matrix in which color values are stored. To find the lower boundary, the average value in each row of the matrix is analyzed and the columns are analyzed to determine the vehicle width.
User defines a region of interest and algorithm analyzes only this region on the image. Width of region is n % pixels ( Figure 5). Region height on a first frame equals to the highest possible value as car edges are not known yet. Value that controls a location of bottom border is g. Algorithm analyzes each row of matrix ()*+, [ , ]. For each row from % pixels average intensity is evaluated. Changing one of the pixels in a group will not contribute much to the intensity of the group.
Thus, the measurement stability with respect to camera noise is increased. We can obtain a graph of intensity value change as a result of matrix analysis. In this way you can observe how the color intensity changes depending on the column/rows number.
Then the object boundaries are in areas, where the average color intensity value by row/column has changed quickly.  As we know the upper limit of the vertical area (the beginning of the car) the horizontal specified area (height -& pixels) is cut out of each frame ( Figure 5). This area called the horizontal scanner. It consists of two horizontal areas: left and right. These areas are l pixels above the upper limit (Since in most cases the beginning of the car is the beginning of the shadow under it or the beginning of the car bumper). The algorithm analyzes each pixel column of the left and right areas color matrices. For each column of n & pixels (Figure 5), the average intensity is calculated. The dependence of grey on rows of pixels for the left and right horizontal region -( ) and ) ( ) is constructed (Figure 6).
Then it is necessary to analyze if fast changes of intensity value occur. If the absolute difference of values is greater than ∆ & , we believe that this is the beginning of the car border. If no changes are found, we add columns to the left and right color matrices ()*+, [ , ] and scan the vehicle's width.  The border of the left area is horizontally equal to the left border of the found vehicle. The same procedure applies to the right border.
It is important to evaluate the distance from lane marking line to a car. We have developed a method for estimating the transverse safety clearance. These methods aim to help road workers more effectively analyze safety in certain sections of the road. Based on the obtained dependencies (Figure 10), it is possible to identify danger areas and find an optimal plan to improve the road system. Due to proper image processing it has been shown that feature extraction allows to solve of problems and helps a lot. The big advantage of the model is the interpretability, i.e. each step can be explained. Therefore, it is not a Black Box model when it is a difficult to understand how it works. For example, Deep Neural Networks that sometimes show very high results is a Black Box Model. Developers and engineers can't explain how it works to non-technical specialist because they can't find an intuitive way to explain what does one filter or weight mean. Basically, weights and filters don't really intuitive at all so even the specialists often do not understand how Neural Networks. And you also need to collect a lot of data to train the model, which can be expensive and doesn't live up to expectations.

Conclusion
In this article, we have proposed an algorithm for image processing and pattern recognition of car objects parameters by video from camera fixed on mobile laboratory (car torpedo). As result of this algorithm the function F(n) for estimating the transverse safety clearance is obtained.
Further research is needed on the methods for evaluating the transverse safety clearance using computer vision algorithms. It is necessary to determine the quality of road markings and estimate the safety of road sections of the road, which can be potentially dangerous due to improper design.