{'fraction_non_alphanumeric': 0.03261461396057933, 'fraction_numerical': 0.011651965588587608, 'mean_word_length': 4.282427379925223, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Real time Detection of Lane Markers in Urban Streets

We present a robust and real time approach to lane marker detection in urban streets. It is based on generating a top view of the road, filtering using selective oriented Gaussian filters, using RANSAC line fitting to give initial guesses to a new and fast RANSAC algorithm for fitting Bezier Splines, which is then followed by a post-processing step. Our algorithm can detect all lanes in still images of the street in various conditions, while operating at a rate of 50 Hz and achieving comparable results to previous techniques.


I. INTRODUCTION
Car accidents kill about 50,000 people each year in the US. Up to 90% of these accidents are caused by driver faults [1]. Automating driving may help reduce this huge number of human fatalities. One useful technology is lane detection which has received considerable attention since the mid 1980s [15], [8], [13], [10], [2]. Techniques used varied from using monocular [11] to stereo vision [5], [6], using lowlevel morphological operations [2], [3] to using probabilistic grouping and B-snakes [14], [7], [9]. However, most of these techniques were focused on detection of lane markers on highway roads, which is an easier task compared to lane detection in urban streets. Lane detection in urban streets is especially a hard problem. Challenges include: parked and moving vehicles, bad quality lines, shadows cast from trees, buildings and other vehicles, sharper curves, irregular/strange lane shapes, emerging and merging lanes, sun glare, writings and other markings on the road (e.g. pedestrian crosswalks), different pavement materials, and different slopes ( fig. 1).
This paper presents a simple, fast, robust, and effective approach to tackle this problem. It is based on taking a topview of the image, called the Inverse Perspective Mapping (IPM) [2]. This image is then filtered using selective Gaussian spatial filters that are optimized to detecting vertical lines. This filtered image is then thresholded robustly by keeping only the highest values, straight lines are detected using simplified Hough transform, which is followed by a RANSAC line fitting step, and then a novel RANSAC spline fitting step is performed to refine the detected straight lines and correctly detect curved lanes. Finally, a cleaning and localization step is performed in the input image for the detected splines.
This work provides a number of contributions. First of all, it's robust and real time, running at 50 Hz on 640x480 images on a typical machine with Intel Core2 2.4 GHz machine. . Second, it can detect any number of lane boundaries in the image not just the current lane i.e. it can detect lane boundaries of neighboring lanes as well. This is a first step towards understanding urban road images. Third, we present a new and fast RANSAC algorithm for fitting splines efficiently. Finally, we present a thorough evaluation of our approach by employing hand-labeled dataset of lanes and introducing an automatic way of scoring the detections found by the algorithm. The paper is organized as follows: section II gives a detailed description of the approach. Section III shows the experiments and results, which is followed by a discussion in section IV. Finally, a conclusion is given in section V.

A. Inverse Perspective Mapping (IPM)
The first step in our system is to take generate a top view of the road image [2]. This has two benefits: 1) We can get rid of the perspective effect in the image, and so lanes that appear to converge at the horizon line are now vertical and parallel. This uses our main assumption that the lanes are parallel (or close to parallel) to the camera. 2) We can focus our attention on only a subregion of the input image, which helps in reducing the run time considerably. To get the IPM of the input image, we assume a flat road, and use the camera intrinsic (focal length and optical center) and extrinsic (pitch angle, yaw angle, and height above ground) parameters to perform this transformation. We start by defining a world frame {F w } = {X w , Y w , Z w } centered at the camera optical center, a camera frame frame X w Y w plane i.e. we allow for a pitch angle α and yaw angle β for the optical axis but no roll. The height of the camera frame above the ground plane is h. Starting from any point in the image plane i P = {u, v, 1, 1}, it can be shown that its projection on the road plane can be found by applying the homogeneous transformation i.e. g P = g i T i P is the point on the ground plane corresponding to i P on the image plane, where {f u , f v } are the horizontal and vertical focal lengths, respectively, {c u , c v } are the coordinates of the optical center, and c 1 = cos α, c 2 = cos β, s 1 = sin α, and s 2 = sin β . These transformations can be efficiently calculated in matrix form for hundreds of points. The inverse of the transform can be easily found to be i g T =   fuc 2 + cuc 1 s 2 cuc 1 c 2 − s 2 fu −cus 1 0 s 2 (cvc 1 − fvs 1 ) c 2 (cvc 1 − fvs 1 ) −fvc 1 − cvs 1 0 where again starting from a point on the ground g P = {x g , y g , −h, 1} we can get its subpixel coordinates on the image frame by i P = i g T g P and then rescale the homogeneous part. Using these two transformations, we can project a window of interest from the input image onto the ground plane. Figure 3 shows a sample IPM image. The left side shows the original image (640x480 pixels), with the region of interest in red, and the right image shows the transformed IPM image (160x120 pixels). As shown, lanes in the IPM image have fixed width in the image and appear as vertical, parallel straight lines.

B. Filtering and Thresholding
The transformed IPM image is then filtered by a two dimensional Gaussian kernel. The vertical direction is a smoothing Gaussian, whose σ y is adjusted according to the required height of lane segment (set to the equivalent of 1m in the IPM image) to be detected: The horizontal direction is a second-derivative of Gaussian, whose σ x is adjusted according to the expected width of the lanes (set to the equivalent of 3 inches in the IPM . The filter is tuned specifically for vertical bright lines on dark background of specific width, which is our assumption of lanes in the IPM image, but can also handle quasi-vertical lines which produce considerable output after the thresholding process. Using this separable kernel allows for efficient implementation, and is much faster than using a non-separable kernel. Figure 4 shows the resulting 2D kernel used (left) and the resulting filtered image (middle). As can be seen from the filtered image, it has high response to lane markers, and so we only retain the highest values. This is done by selecting the q% quantile value from the filtered image, and removing all values below this threshold i.e. we only keep the highest (q − 1)% of the values. In our experiments, q is set to 97.5% in the experiments. The thresholded image is not binarized i.e. we keep the actual pixel values of the thresholded image, which is the input to the following steps. In this step, we use the assumption that the vehicle is parallel/near parallel to the lanes. Figure 4 (right) shows the result after thresholding.

C. Line Detection
This stage is concerned with detecting lines in the thresholded image. We use two techniques: a simplified version of Hough Transform to count how many lines there are in the image, followed by a RANSAC [4] line fitting to robustly fit these lines. The simplified Hough transform gets a sum of values in each column of the thresholded filtered image. This sum is then smoothed by a Gaussian filter, local maxima are detected to get positions of lines, and then this is further refined to get sub-pixel accuracy by fitting a parabola to the local maxima and its two neighbors. At last, nearby lines are grouped together to eliminate multiple responses to the same line. Figure 5 shows the result of this step.
The next step is getting a better fit for these lines using RANSAC line fitting. For each of the vertical lines detected above, we focus on a window around it (white box in left of fig. 6), and run the RANSAC line fitting on that window.

D. RANSAC Spline Fitting
The previous step gives us candidate lines in the image, which are then refined by this step. For each such line, we take a window around it in the image, on which we will be running the spline fitting algorithm. We initialize the spline fitting algorithm with the lines from the previous step, which is a good initial guess for this step, if the lanes are straight. The spline used in these experiments is a third degree Bezier spline [12], which has the useful property that the control points form a bounding polygon around the spline itself.
The third degree Bezier spline is defined by: This forces t 1 = 0 and t n = 1 which corresponds to the first and last point of the spline, respectively. Next, we define the following matrices: and solve for the matrix P using the pseudo-inverse: This gives us the control points for the spline that minimizes the sum of squared error of fitting the sampled points. 3) computeSplineScore(): In normal RANSAC, we would be interested in computing the normal distance from every point to the third degree spline to decide the goodness of that spline, however this would require solving a fifth degree equation for every such point. Instead, we decided to follow a more efficient approach. It computes the score (measure of goodness) of the spline by rasterizing it using an efficient iterative way [12], and then counting the values of pixels belonging to the spline. It also takes into account the straightness and length of the spline, by penalizing shorter and more curved splines. Specifically, the score is computed as: where s is the raw score for the spline (the sum of pixel values of the spline), l' is the normalized spline length measure defined as l ′ = (l/v) − 1 where l is the spline length and v is the image height and so l ′ = 0 means we have a longer spline and l ′ = −1 means a l θ 1 Fig. 7. Spline score computation. shorter spline, θ ′ is the normalized spline "curveness" measure defined by θ ′ = (θ − 1)/2 whereas θ is the mean of the cosine of angles between lines joining the spline's control point i.e. θ = (cos θ 1 + cos θ 2 )/2, and k 1 and k 2 are regularization factors, see figure 7. This scoring formula makes sure we favor longer and straighter splines than shorter and curvier ones, where longer and straighter splines are penalized less than shorted curvier ones. Figure 8 shows a sample result for the algorithm. The left side shows a window of interest (white) around the lines output from the RANSAC line step, with the detected spline in red. The right side shows the four output splines in green.

E. Post-processing
The final step of the algorithm is to post-process the output of the previous stage to try to better localize the spline and extend it in the image, figure 9. This is done both in the IPM image, and in the original image after back projecting the splines from the IPM space to the image space. Here we perform three steps: 1) Localization: We start with the initial spline (blue spline in figure 9), and then we sample points on the spline (blue points), extend a line segment through these sampled points that are normal to the spline tangent direction at that point (black line segments). Then, we get the grayscale profile for this line segment by computing the pixel locations that this line passes through, convolve that with a smoothing Gaussian kernel, and look for local maxima of the result. This should give us better localization for points on the spline to give better fit for the road lanes (green points). In addition, one more check is  so far from the expected location. Finally, we refit the spline with the localized points (green spline).
2) Extension: After the spline's position has been improved, we perform an extension in the IPM and original images, in order to give an even better fit of the lane. This is done similarly by looking both forward and backward from the spline end points along the tangent direction (red points), and creating line segments through the normal direction (red line segments), and finding the peak of convolving the grayscale profile of these segments with the smoothing Gaussian filter. The new peak is not accepted if it's below a certain threshold (homogeneous area with no lines in it), or if the orientation change from the dominant spline orientation exceeds a certain threshold, in which case the extension process stops.
3) Geometric Checks: After each of the previous two steps, we also perform geometrical checks on the localized and extended splines, to make sure they are not very curved or very short, in which case they are replaced by the corresponding line from the RANSAC line fitting stage. Checks are also made to make sure fitted splines are near vertical in the IPM image, otherwise they are rejected as valid splines. Figure 10 shows the results before and after post-processing the splines.

A. Setup
We collected a number of clips on different types of urban streets, with/without shadows, and on straight and curved streets. Unlike previous papers that would just mention rough percentages of detection rates, and in order to get an accurate quantitative assessment of the algorithm, we hand-labeled all visible lanes in four of these clips, totaling 1224 labeled  I   DATASETS   Clip#  name  #frames  #lane boundaries  1  cordova1  250  919  2  cordova2  406  1048  3  washington1  336  1274  4  washington2  232  931  Total  1224  4172 frames containing 4172 marked lanes (table I). The system was prototyped using Matlab, and implemented in C++ using the open source OpenCV library. These clips are quite challenging, for clip #1 has a lot of curvatures and some writings on the street, clip #2 has different pavement types and the sun is facing the vehicle, clip #3 has lots of shadows (at the beginning) and passing cars, and finally clip #4 has street writings and passing vehicles as well ( fig. 1).
The detection results shown in the next section are computed automatically using the hand-labeled data. In each frame, each detected lane boundary is compared to ground truth lanes, and a check is made to decide if it is a correct or false detection. To check if two splines s 1 and s 2 are the same i.e. represent the same lane boundary, we sample points on both of them p 1 i and p 2 i . For every point p 1 i on the first spline, we compute the nearest point p 2 j on the second spline and compute the distance d 1 i between the two points. We do the same for the second spline, where for every such point we get the nearest distance d 2 i to the first spline. We then compute the median distancesd 1 &d 2 and the mean distancesd 1 &d 2 . Now to decide whether they are the same, we require that both be satisfied. In our experiments, we used t 1 = 20 and t 2 = 15.

B. Results
We ran the algorithm in two different modes: 1) 2-lanes mode: detecting only the two lane boundaries of the current lane, which is similar to previous approaches; and 2) alllanes mode: detecting all visible lanes in the image. In the first mode, we just focus on the middle of the IPM image by clipping the left and right parts, while in the second mode we work on the whole IPM image. Tables II and III show results for the two modes. The fist column shows the total number of lane boundaries in each clip, the second shows the number of detected lane boundaries, the third the correct detection rate, followed by the false positive rate, and finally the false positive/frame rate. Figure 11 shows some detection results samples from these clips. The complete videos can be accessed online at http://www.vision.caltech. edu/malaa/research/iv08.

IV. DISCUSSION
The results show the effectiveness of our algorithm in detecting lanes on urban streets with varying conditions. Our algorithm doesn't use tracking yet i.e. these are the results of detecting lanes in each image independently without utilizing any temporal information. However, when detecting only the lane boundaries of the current lane, we achieve comparable results to other algorithms (e.g. [?], [7]), which used both detection and tracking. We also achieve good results for detecting all the visible lane boundaries, which is a first step towards urban road understanding, and which was not attempted before (as far as we know). We get excellent results in clear conditions, however we get some false positives due to stop lines at cross streets, at cross walks, near passing cars, see figure 12.
False positives are mostly found when driving on the right lane of the street with no right lane boundary, and we detect the curb as the right lane boundary ( fig. 12), and that's the reason for the high false positive rate in clip #2. However, this is not a real problem, as the curb is really a lane boundary, but not painted as such, and this won't affect the objectives of the algorithm to detect lane boundaries.
In the current algorithm, we only work on the red channel, which gives us better images for white and yellow lanes than converting it to grayscale. However, there is plenty to be done to further improve this algorithm. We plan on using the color information to classify different lane boundaries: white solid lines, double yellow lines, ..etc. This will also allow us to remove the false positives due to curbs being detected as lanes, as well as confusing writings on the streets, which are usually in yellow and can be filtered out. Furthermore, we plan on employing tracking on top of the detection step, which will help get rid of a lot of these false positives.

V. CONCLUSION
We proposed an efficient, real time, and robust algorithm for detecting lanes in urban streets. The algorithm is based on taking a top view of the road image, filtering with Gaussian kernels, and then using line detection and a new RANSAC spline fitting technique to detect lanes in the street, which is followed by a post-processing step. Our algorithm can detect all lanes in still images of urban streets and works at high rates of 50 Hz. We achieved comparable results to other algorithms that only worked on detecting the current lane boundaries, and good results for detecting all lane boundaries.