A lane line detection method
Through the combination of improved Canny edge detection and region growing methods, the problem of low efficiency of lane line detection in complex environments is solved, and more efficient and accurate lane line detection is achieved.
Patent Information
- Application Number
- CN202210584432.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-05-26
AI Technical Summary
Existing lane line detection methods have low detection efficiency under complex lighting and road conditions. Traditional Canny edge detection and region growing methods have problems of manual intervention and low efficiency.
The improved Canny edge detection algorithm is combined with the region growing method to improve the accuracy and accuracy of lane line detection through distortion correction, grayscale transformation, hybrid filter processing, non-maximum suppression and sliding window technology, combined with least squares fitting. efficiency.
It enhances the retention of edge information, improves the accuracy and efficiency of lane line detection, has better detection results, and can adapt to complex environments.
Smart Images

Figure CN114998853B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of autonomous driving, and in particular relates to a lane line detection method. Background Art
[0002] Lane detection plays an important role in the field of autonomous driving. With the development of artificial intelligence, unmanned driving technology has emerged. This technology originated from the intelligent control system. By controlling multiple sub-functional modules, the car can be unmanned under the command of the system. However, in the driving process of intelligent vehicles, accurately completing the lane detection task is crucial for safe driving.
[0003] At present, detection methods based on computer vision are widely used in lane line detection tasks. Some researchers use the traditional Canny edge detection combined with Hough transform to complete the detection task based on the edge features of the lane line, but the detection effect is not good under complex lighting and road conditions; some researchers use the regional growing method to study the recognition of curves on highways, but the regional growth points need to be manually found, and the detection efficiency is low. In response to the above problems, an improved Canny edge detection algorithm combined with regional growing is proposed to detect lane lines, which enhances edge information, retains more edge details, and has better results than traditional Canny edge detection. Summary of the invention
[0004] The technical purpose of the present invention is to provide a lane line detection method to solve the technical problem of low detection efficiency in the prior art.
[0005] To solve the above problems, the technical solution of the present invention is:
[0006] A lane line detection method comprises the following steps
[0007] S1: Extract each frame of image from the road driving video to obtain the input image and perform distortion correction;
[0008] S2: Perform grayscale transformation on the input image to obtain a grayscale image;
[0009] S3: Perform edge detection on the grayscale transformed input image based on the improved Canny algorithm to obtain an edge image;
[0010] S4: Extract the grayscale image based on the region growing algorithm to obtain the segmented image;
[0011] S5: performing an AND operation on the edge image and the segmented image to obtain a processed image;
[0012] S6: performing inverse perspective transformation on the processed image;
[0013] S7: The lane lines are fitted on the processed image after inverse perspective transformation based on sliding window technology and least squares algorithm.
[0014] In step S1, a mathematical model of geometric correction is constructed, and the parameters of the mathematical model are calculated, and the pixels in the input image are geometrically transformed to achieve distortion correction.
[0015] In step S2, the pixels of the input image are transformed by a linear function, and the linear function formula is:
[0016] g(x,y)=kf(x,y)+b
[0017] Among them, g(x,y) is the transformed grayscale value, f(x,y) is the original grayscale value, k is the slope, and b is the intercept.
[0018] Further preferably, between steps S2 and S3, a hybrid filter needs to be constructed;
[0019] Hybrid filters include median filters and bilateral filters;
[0020] The processing formula of the median filter is:
[0021] g(x,y)=Median[f(m,n)]
[0022] Where m,n∈S st , g(x,y) is the image after median filtering, f(m,n) is the image to be processed, S st represents a window of size u×v;
[0023] The processing formula of the bilateral filter is:
[0024]
[0025] Among them, ω(i,j,k,l) is the weighting coefficient, and its value is determined by the spatial threshold weight and the gray threshold weight;
[0026] The spatial threshold weight is:
[0027]
[0028] The grayscale threshold weight is
[0029]
[0030] Among them, i,j are the pixel coordinates of the field, k,l are the center pixel coordinates, f(i,j) is the gray value at point (i,j), σ d is the spatial domain standard deviation of the Gaussian function.
[0031] Wherein, step S3 includes
[0032] S31: filtering the grayscale transformed input image with a median filter and a bilateral filter in sequence to obtain a denoised image;
[0033] S32: Use the Sobel operator to calculate the gradient of the denoised image;
[0034] S33: Based on the gradient amplitude and direction of the denoised image, non-maximum suppression is performed on the pixel points of the denoised image to obtain a rough image;
[0035] S34: Setting high and low thresholds to filter the rough image, filter out weak edges, and obtain an edge image.
[0036] Wherein, step S7 includes
[0037] S71: Perform pixel histogram statistics on the processed image, find two peak points in the histogram, determine the base window width of the sliding window and the base point coordinates of the left and right sliding windows, and complete the drawing of the sliding window;
[0038] S72: setting the condition of redrawing the sliding window, taking the average value of the pixel coordinates that meet the condition as the base point coordinate of the next window, and iterating the detection in sequence until the cycle number is met and stopping;
[0039] S73: Then, the best matching function is found to fit the curve display image by minimizing the sum of squared errors, and the lane line is obtained by fitting.
[0040] Due to the adoption of the above technical scheme, the present invention has the following advantages and positive effects compared with the prior art: the present invention obtains lane line edge details through an improved Canny algorithm, obtains image segmentation effect through a region growing algorithm, and then combines the processing, and subsequently uses a sliding window and least squares method to fit the lane line. Compared with the prior art, the accuracy of lane line detection is improved. Due to the enhancement of edge information, more edge details are retained, and the detection effect is better and the efficiency is higher. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the following detailed description of the preferred embodiment.The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting the invention.
[0042] Figure 1 A flow chart of a lane line detection method of the present invention;
[0043] Figure 2 It is a flow chart of the improved Canny algorithm of the present invention;
[0044] Figure 3is a flow chart of the region growing algorithm of the present invention;
[0045] Figure 4 This is a flow chart of the detection of the sliding window of the present invention. DETAILED DESCRIPTION
[0046] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.
[0047] In order to simplify the drawings, only the parts related to the present invention are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one of the parts with the same structure or function is schematically drawn or marked. In this article, "one" not only means "only one", but also means "more than one".
[0048] The following is a further detailed description of a lane line detection method proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more apparent from the following description and claims.
[0049] Example
[0050] See also Figures 1 to 4 , this embodiment provides a lane line detection method, comprising the following steps, first, in step S1, the road during the driving of the vehicle is continuously recorded by a camera and its related equipment components, and then each frame of the image is extracted from the road driving video taken by the camera as an input image. Since certain errors will be generated in the manufacturing of the camera and the installation of related equipment components, it is necessary to perform distortion correction on them. In this embodiment, the correction is completed by using a geometric transformation method. Specifically, a mathematical model of geometric correction, i.e., a correction function, is constructed, and the parameters of the conditional calculation mathematical model are used to perform geometric transformation on the pixels in the input image to achieve distortion correction, and the condition is a mapping relationship between the pixel coordinates in the image and the pixel coordinates of the corrected image.
[0051] Then, in step S2, the pixels in the distortion-corrected input image are transformed into grayscale to obtain a grayscale image. The pixels of the input image are transformed by a linear function to highlight the contrast of the image. The linear function formula is:
[0052] g(x,y)=kf(x,y)+b
[0053] Among them, g(x,y) is the transformed grayscale value, f(x,y) is the original grayscale value, k is the slope, and b is the intercept.
[0054] Preferably, before implementing step S3, a hybrid filter needs to be constructed. Specifically, a hybrid filter composed of a median filter and a bilateral filter is used to replace the Gaussian filter in the traditional Canny edge detection algorithm. The reason is that the Gaussian filter also blurs the image while removing noise, causing the image to lose detail information and be affected by illumination, so it is proposed to use a hybrid filter composed of a median filter and a bilateral filter.
[0055] Median filtering takes the median of a neighborhood window as the current grayscale value. The processing formula of the median filter is:
[0056] g(x,y)=Median[f(m,n)]
[0057] Where m,n∈S st , g(x,y) is the image after median filtering, f(m,n) is the image to be processed, S st Represents a window of size u×v.
[0058] The bilateral filter can consider both spatial information and grayscale similarity, which can achieve the purpose of denoising and preserve edge characteristics. The specific processing formula is:
[0059]
[0060] Among them, ω(i,j,k,l) is the weighting coefficient, and its value is determined by the spatial threshold weight and the gray threshold weight.
[0061] The spatial threshold weight is:
[0062]
[0063] The grayscale threshold weight is
[0064]
[0065] Among them, i,j are the pixel coordinates of the field, k,l are the center pixel coordinates, f(i,j) is the gray value at point (i,j), σ d is the spatial domain standard deviation of the Gaussian function.
[0066] Next, see Figure 1 and Figure 2In step S3, the edge detection of the grayscale transformed input image is performed based on the improved Canny algorithm to obtain an edge image. Specifically, the grayscale transformed input image is filtered as the input of the median filter, and the processing result is filtered again as the input of the bilateral filter to obtain a denoised image, so that better denoising can be achieved while retaining edge information. Then, the gradient of the denoised image is calculated using the Sobel operator. Then, the non-maximum suppression algorithm is used. Specifically, after obtaining the amplitude and direction of the gradient, all pixels are traversed to determine whether the pixel is the maximum value of the surrounding pixels with the same gradient direction. The result determines whether to suppress it. The purpose is to suppress all gradient values except the local maximum value, so as to obtain a rough image. Finally, high and low thresholds are set to filter out weak edges, thereby ensuring the validity of edge information. If the current edge pixel is greater than the high threshold, it is considered to be a strong edge and the edge is retained; if it is lower than the low threshold, it is considered to be a weak edge and does not need to be retained, and finally an edge image is obtained.
[0067] See also Figure 3 , enter step S4, step S3 and step S4 are performed simultaneously. Perform inverse perspective transformation on the grayscale image, then perform pixel histogram statistics on the result image, obtain the lane line starting position pixel from the histogram, and determine the seed point (x0, y0). Then set the (x0, y0) neighboring pixel value threshold range, set the difference range with the adjacent pixels, and use this as the growth criterion until the pixels that do not meet the conditions are included, and finally obtain the segmented image.
[0068] After completing step S3 and step S4, the edge image and the segmented image are received respectively, and the edge image and the segmented image are operated pixel by pixel through OpenCV programming to obtain a processed image. Then the processed image is subjected to inverse perspective transformation to obtain a "bird's eye view", which is more convenient for curve detection and fitting, and achieves better detection results.
[0069] See also Figure 1 and Figure 4 Finally, in step S7, the sliding window is used for detection. The specific process is as follows: Figure 4 As shown in the figure, the pixel histogram of the "bird's eye view" after the inverse perspective transformation is counted, and the two peak points in the histogram, i.e., the starting points of the lane lines, are found to determine the base window width of the sliding window and the base point coordinates of the left and right sliding windows, and the sliding window is drawn. At the same time, the condition for redrawing the sliding window, i.e., the minimum number of pixels, is set, and the average value of the pixel coordinates that meet the condition is used as the base point coordinate of the next window. The detection is iterated in sequence until the cycle number is met and stopped. Then, the least squares algorithm is used to find the best matching function fitting curve to display the image and complete the lane line detection task.
[0070] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, if these changes fall within the scope of the claims of the present invention and their equivalents, they still fall within the protection scope of the present invention.
Claims
1. A lane line detection method, characterized in that: The following steps are included S1: Extract each frame of image from the road driving video to obtain the input image and perform distortion correction; S2: Performing grayscale transformation on the input image to obtain a grayscale image; S3: performing edge detection on the input image after grayscale transformation based on the improved Canny algorithm to obtain an edge image; S4: extracting the grayscale image based on a region growing algorithm to obtain a segmented image; S5: performing an AND operation on the edge image and the segmented image to obtain a processed image; S6: performing inverse perspective transformation on the processed image; S7: fitting the processed image after the inverse perspective transformation based on the sliding window technology and the least squares algorithm to obtain the lane line; The step S3 includes S31: filtering the input image after grayscale transformation by the median filter and the bilateral filter in sequence to obtain a denoised image; S32: using the Sobel operator to calculate the gradient of the denoised image; S33: Based on the gradient amplitude and direction of the denoised image, non-maximum suppression is performed on the pixel points of the denoised image to obtain a rough image; S34: setting high and low thresholds to filter the rough image, filter out weak edges, and obtain an edge image; The step S7 includes S71: Perform pixel histogram statistics on the processed image, find two peak points in the histogram, determine the base window width of the sliding window and the base point coordinates of the left and right sliding windows, and complete the drawing of the sliding window; S72: setting the condition of redrawing the sliding window, taking the average value of the pixel coordinates that meet the condition as the base point coordinates of the next window, and iterating the detection in sequence until the cycle number is met and stopping; S73: Then, the best matching function is found to fit the curve display image by minimizing the sum of squared errors, and the lane line is obtained by fitting.
2. The lane line detection method according to claim 1, characterized in that: In the step S1, a mathematical model of geometric correction is specifically constructed, and the parameters of the mathematical model are calculated, and the pixels in the input image are geometrically transformed to achieve distortion correction.
3. The lane line detection method according to claim 1, characterized in that: In step S2, the pixels of the input image are transformed by a linear function, and the linear function formula is: , in, is the gray value after transformation, is the original gray value, is the slope, is the intercept.
4. The lane line detection method according to claim 1, characterized in that: Between steps S2 and S3, a hybrid filter needs to be constructed; The hybrid filter includes a median filter and a bilateral filter; The processing formula of the median filter is: , in, , is the image after median filtering, is the image to be processed, Indicates size Window; The processing formula of the bilateral filter is: , in, is the weighting coefficient, and its value is determined by the spatial threshold weight and the gray threshold weight; The spatial threshold weight is: , The grayscale threshold weight is , in, is the pixel coordinate of the field, is the center pixel coordinate, For point The gray value at is the spatial domain standard deviation of the Gaussian function.
Citation Information
Patent Citations
Three-lane detection method based on image morphological segmentation and region growing
CN105160309A
Laser point cloud and image data fusion-based lane line extraction method
CN107463918A
Lane line detection method and system, and method and system for lane deviation prewarning
WO2015043510A1
