An algorithm for determining distance of vehicle autonomous driving

By processing the image through the camera and using the BP neural network, the rectangular bright area and the black area are divided, which solves the accuracy problem of the existing automatic driving distance judgment method in low light conditions and realizes a simplified vehicle distance judgment process.

CN114972276BActive Publication Date: 2025-01-21王建波
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210626817.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-05
Publication Date
2025-01-21
Estimated Expiration
2042-06-05

AI Technical Summary

Technical Problem

The existing autonomous driving distance judgment methods rely on complex data processing and huge data pools, making it difficult to accurately judge vehicle distance and lane information under low light conditions.

Method used

Capture the image of the vehicle ahead through the camera, perform Gaussian filtering, grayscale, edge detection and binary processing, divide the rectangular bright area and black area, use BP neural network to train the model, and judge the distance between vehicles.

Benefits of technology

It achieves accurate judgment of vehicle distance and lane information under low-light conditions, reduces dependence on the size of the data pool, and simplifies the ranging process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114972276B_ABST
    Figure CN114972276B_ABST
Patent Text Reader

Abstract

The present invention discloses a vehicle automatic driving distance judgment algorithm, which is characterized in that it includes the following steps: Step 1: image preprocessing is performed on the acquired image of the vehicle in front, and the image is subjected to Gaussian filtering, i.e., Gaussian blurring, to remove the noise of the image; Step 2: the image after Gaussian filtering is subjected to grayscale processing to obtain an image grayscale map, to remove the color information of the image, and to reduce the amount of calculation; Step 3: the edge feature extraction operation in the vertical direction of the image is performed by the edge detection sobel operator; Step 4: the image is converted into a binary map by binarization, i.e., an image with only pixel values ​​of 0 or 1. The present invention relates to the field of automatic driving distance judgment methods, and specifically, to a vehicle automatic driving distance judgment algorithm. The technical problem to be solved by the present invention is to provide a vehicle automatic driving distance judgment algorithm to facilitate automatic driving distance judgment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of autonomous driving distance judgment methods, and in particular, to an algorithm for judging the distance of an autonomous driving vehicle. Background Art

[0002] The distance measurement of autonomous driving vehicles usually uses sensors such as laser radar and infrared to measure the distance. Some car companies use monocular and binocular cameras to imitate vision for distance measurement. For example, Huawei uses CN113091694A to calculate the distance through the parallax of two cameras. The distance measuring device obtains the first imaging size h of the target object from the first camera unit and the first parallax z of the target object from the second camera unit. Then, the distance measuring device determines the second physical size H' and the second baseline length b' of the target object according to the first relationship. Then, the distance measuring device determines the target distance between the target object and the first camera unit or the second camera unit based on at least one of the second physical size H' and the second baseline length b', as well as the first imaging size h and the first parallax z. Because the first imaging size h from the first camera unit, the second physical size H', the first parallax z from the second camera unit, and the first baseline length b satisfy the pre-set first relationship; and the first imaging size h of the first camera unit, the first physical size H, the first parallax z of the second camera unit, and the second baseline length b' satisfy the first relationship. Therefore, the target distance calculated based on the first imaging size h, the second physical size H', the first parallax z and the first baseline length b, or the target distance calculated based on the first imaging size h, the first physical size H, the first parallax z and the second baseline length b' both refer to data based on the monocular ranging principle and data based on the binocular ranging principle.

[0003] For example, Tesla believes that people can drive by observing the surrounding environment with their eyes, so the autonomous driving system can also use the same logic with cameras, so Tesla's cameras are imitating human eyes. The camera can transmit the most realistic road images to the processor, and then convert these images into data. The most difficult part is not how to restore the real image, but how to convert the image into data, which has very high requirements for data processing and storage capabilities.

[0004] Visual solutions are highly dependent on sample data and require large amounts of data for training, continuous optimization, and continuous learning. Therefore, Tesla built a closed-loop framework for data collection and learning early on. It collects data from various driving scenarios through cameras and uploads it to the Tesla cloud, forming a real and huge data pool.

[0005] This cloud database can provide learning templates for Tesla's intelligent algorithms, giving the algorithms the ability to continuously upgrade. Based on the collected driving data, Tesla will continuously optimize the algorithm through "shadow mode", and finally perform OTA upgrades on each Tesla's FSD autonomous driving. LiDAR sensor LiDAR detects and measures distance through laser beams, and consists of three parts: a laser transmitter, an optical receiver, and an information processing system. LiDAR can calculate the relative distance between the target object and the vehicle by emitting and receiving laser beams, analyzing the return time after the laser encounters the target object, and using the three-dimensional coordinates, reflectivity and other information of a large number of dense points on the surface of the target object collected to quickly rebuild the target's three-dimensional model and various drawing data, establish a three-dimensional point cloud map, and draw an environmental map to achieve the purpose of environmental perception.

[0006] Our research found that during the day, we can observe that the black part of the lower part of the car body, the tires on both sides and the shadow of the car on the ground under the sun will form a rectangular black area, and a rectangular bright area will be formed in the middle. The two will be clearly layered when captured by a camera. As the distance between the car and the vehicle changes, the clear rectangle will deform. Calculations based on the database can assist the laser radar or camera in determining information such as vehicle distance, speed, and lane. Summary of the invention

[0007] The technical problem to be solved by the present invention is to provide a vehicle automatic driving distance judgment algorithm to facilitate automatic driving distance judgment.

[0008] The present invention adopts the following technical solutions to achieve the invention objectives:

[0009] A vehicle automatic driving distance judgment algorithm, characterized by comprising the following steps:

[0010] Step 1: The acquired image of the vehicle in front is subjected to image preprocessing, and Gaussian filtering is performed on the image, i.e., Gaussian blurring, to remove image noise;

[0011] Step 2: The image after Gaussian filtering is grayed to obtain a grayscale image, thereby removing the color information of the image and reducing the amount of calculation;

[0012] Step 3: Use the edge detection sobel operator to extract the vertical edge features of the image;

[0013] Step 4: Convert the image into a binary image through binarization, that is, an image with pixel values ​​of only 0 or 1;

[0014] Step 5: Obtain several rectangular frames by performing a closing operation on the binary image;

[0015] Step 6: By performing contour operation on the image, all contours in the image are obtained, including the region of interest, i.e., the rectangular bright area and the black area;

[0016] The basis for dividing the rectangular bright area and the black area in step 6 is:

[0017] On a sunny day, the shadows of the rear bumper and wheels on both sides of the car on the ground under the sun will form a rectangular black area, and the rear bumper, wheels on both sides of the car and the ground will form a rectangular bright area in the vertical plane.

[0018] Step 7: Find the minimum circumscribed rectangle of the outline and filter according to the aspect ratio of the ROI to determine the rectangular bright area and black area

[0019] Step 8: Determine the rectangular bright area and black area according to the gray value;

[0020]

[0021] The grayscale value of the black area is small, while the grayscale value of the light area is large. The black area and the light area are determined based on this.

[0022] As a further limitation of the technical solution, it also includes step nine: by collecting a large number of sample images of rectangular bright areas and black areas of different sizes and time, using these sample images as input and the vehicle distance corresponding to each image as output, BP neural network training is performed to obtain a BP neural network model for judging the vehicle distance corresponding to the image.

[0023] As a further limitation of the technical solution, it also includes step ten: collecting image data to test the model, comparing and correcting the distance judged by the model for the image with the actual measured distance, continuously adding new sample data, continuously iterating and upgrading the model, and improving the judgment accuracy of the model.

[0024] As a further limitation of the present technical solution, the specific operation of Gaussian filtering in step 1 is:

[0025] Use a template to scan each pixel in the image, and use the weighted average grayscale value of the pixels in the neighborhood determined by the template to replace the value of the central pixel of the template. For mean filtering and box filtering, the weight of each pixel in the neighborhood is equal; in Gaussian filtering, the weight value of the center point will be increased, and the weight value far away from the center point will be reduced. On this basis, the sum of the different weights of each pixel value in the neighborhood is calculated;

[0026] The one-dimensional Gaussian distribution formula is as follows:

[0027]

[0028] The two-dimensional Gaussian distribution formula is as follows:

[0029]

[0030] The center position of the template is used as the coordinate origin for sampling, and the coordinates of each position are substituted into the Gaussian function G. Each value obtained is arranged according to the position to obtain the template.

[0031] As a further limitation of the present technical solution, the grayscale processing of the image in step 2 is as follows:

[0032] f(x,y)=0.3R(x,y)+0.59G(x,y)+0.11B(x,y) (2-1)

[0033] Where: f(x,y) is the value of the pixel after grayscale;

[0034] R(x,y), G(x,y), and B(x,y) are the pixel values ​​of the red, green, and blue color channels respectively;

[0035] The pixel values ​​of the red, green, and blue color channels are multiplied by the corresponding coefficients, and finally the grayscale value of the pixel is calculated.

[0036] The Sobel operator in step 3 is mainly used to obtain the first-order gradient of a digital image, and its common application is edge detection and extraction of an image;

[0037] The sobel operator uses two 3*3 matrix operators to convolve with the original image to obtain the horizontal G(x) and vertical G(y) gradient values ​​respectively. If the gradient value is greater than a certain threshold, the point is considered to be an edge point.

[0038] The Sobel operator is derived in the x and y directions:

[0039]

[0040]

[0041] The final result is:

[0042]

[0043] Only the vertical edges need to be extracted, so only G y That is, the vertical edge of the image can be extracted.

[0044] As a further limitation of the present technical solution, the image binarization in step 4 is a process of setting the grayscale value of the pixel points on the image to 0 or 255, that is, making the entire image present an obvious black and white effect;

[0045] Each pixel in a binary image has only two possible values: either pure black (0) or pure white (1).

[0046]

[0047] Where: f(i) is an image;

[0048] i is the pixel value of the pixel;

[0049] T is the judgment threshold;

[0050] The image binarization method uses the maximum inter-class variance method OTSU, and finds a threshold value so that the sum of the variances of the two parts of pixels greater than and less than the threshold is the largest. The purpose is to remove as much information as possible and only retain the most basic information;

[0051] For image I(x,y), the proportion of foreground pixels in the entire image is ω0, and its average grayscale is μ0. The proportion of background pixels in the entire image is ω1, and its average grayscale is μ1. The total average grayscale of the image is μ, and the inter-class variance is g.

[0052] Assuming that the background of the image is dark, and the size of the image is M×N, the number of pixels whose grayscale value is less than the threshold T in the image is recorded as N0, and the number of pixels whose grayscale value is greater than the threshold T is recorded as N1, then:

[0053] ω0=N0 / M×N

[0054] ω1=N1 / M×N

[0055] N0+N1=M×N

[0056] ω0+ω1=1

[0057] μ=ω0*μ0+ω1*μ1 (4-2)

[0058] g=ω0(μ0-μ)^2+ω1(μ1-μ)^2 (4-3)

[0059] Substituting formula (4-2) into formula (4-3), we get the equivalent formula:

[0060] g=ω0ω1(μ0-μ1)^2 (4-4)

[0061] The traversal method is used to obtain the threshold T that maximizes the inter-class variance g, which is what we are looking for.

[0062] As a further limitation of the present technical solution, the specific steps of step 5 are as follows: the process of dilating and then corroding the image is called a closing operation, which first dilates to fill small holes in the connected domain, expands the boundary of the connected domain, and connects two adjacent connected domains, and then uses an erosion operation to reduce the expansion of the connected domain boundary and the increase in area caused by the dilation operation. It has the functions of filling small holes in objects, connecting adjacent objects and smoothing boundaries, and its mathematical expression is as follows:

[0063] dst=close(src,element)=erode(dilate(src,element)) (5-1).

[0064] As a further limitation of the present technical solution, the specific steps of BP neural network training in step nine are as follows:

[0065] The transfer function used by the BP network is a nonlinear transformation function - the Sigmoid function, which is characterized by the fact that the function itself and its derivatives are continuous, so it is very convenient to process. The unipolar S-type function is defined as follows:

[0066] f(x)=1 / (1+e -x ) (9-1)

[0067] When using the S-type activation function, input:

[0068] net=x1w1+x2w2+…+x n w n

[0069] The output is:

[0070] y = f(net) = 1 / (1+e -net ) (9-2)

[0071] Then, the derivative of the output y is:

[0072] F′(net)=1 / (1+e -net )-1 / (1+e -net ) 2 =y(1-y) (9-3)

[0073] The first step is to initialize the network, assign a random number in the interval (-1,1) to each connection weight, set the error function e, give the calculation accuracy εε and the number of learning times M;

[0074] The second step is to calculate and select the kth input sample and the corresponding expected output:

[0075] x(k)=(x1k,x2k,...,x n k)

[0076] d(k)=(d1k,d2k,...,d q k)

[0077] The third step is to calculate the input and output of each neuron in the hidden layer:

[0078]

[0079] ho h (k) = f(hi h (k)) h=1,2,...p

[0080]

[0081] yo o (k) = f(yi o (k)) o=1,2,...p

[0082] The fourth step is to use the expected output and actual output of the network to calculate the partial derivatives of the error function with respect to each neuron in the output layer:

[0083]

[0084]

[0085]

[0086]

[0087] The fifth step is to use the δ of each neuron in the output layer o (k) and the output of each neuron in the hidden layer to correct the connection weight w ho (k)

[0088]

[0089]

[0090] The sixth step is to use the δ of each neuron in the hidden layer h (k) and the input of each neuron in the input layer to correct the connection weights:

[0091]

[0092]

[0093] Step 7: Calculate the global error

[0094]

[0095] The eighth step is to determine whether the network error meets the requirements. When the error is greater than the preset accuracy or the number of learning times is greater than the set maximum value, the algorithm ends. Otherwise, select the next learning sample and the corresponding expected output, return to the third step, and enter the next round of learning.

[0096] Compared with the prior art, the advantages and positive effects of the present invention are:

[0097] This method divides the surrounding black area and the middle rectangular bright area. The two will be clearly layered when captured by a camera, which is convenient for camera capture. The amount of information is small, which is convenient for building a database and does not require a huge data pool. Simple ranging is not convenient for determining information such as lane vehicle posture. The deformation of the clear rectangular bright area can facilitate measurement. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] Figure 1 This is a diagram of the BP neural network training steps of the present invention.

[0099] Figure 2 It is a schematic diagram of the rectangular bright area and black area of ​​the present invention. DETAILED DESCRIPTION

[0100] A specific implementation of the present invention is described in detail below in conjunction with the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific implementation.

[0101] Embodiment 1:

[0102] The present invention comprises the following steps:

[0103] Step 1: The acquired image of the vehicle in front is subjected to image preprocessing, and Gaussian filtering is performed on the image, i.e., Gaussian blurring, to remove image noise;

[0104] Step 2: The image after Gaussian filtering is grayed to obtain a grayscale image, thereby removing the color information of the image and reducing the amount of calculation;

[0105] Step 3: Use the edge detection sobel operator to extract the vertical edge features of the image;

[0106] Step 4: Convert the image into a binary image through binarization, that is, an image with pixel values ​​of only 0 or 1;

[0107] Step 5: Obtain several rectangular frames by performing a closing operation on the binary image;

[0108] Step 6: By performing contour operation on the image, all contours in the image are obtained, including the region of interest, i.e., the rectangular bright area and the black area;

[0109] The basis for dividing the rectangular bright area and the black area in step 6 is:

[0110] On a sunny day, the shadows of the rear bumper and wheels on both sides of the car on the ground under the sun will form a rectangular black area, and the rear bumper, wheels on both sides of the car and the ground will form a rectangular bright area in the vertical plane.

[0111] Step 7: Find the minimum circumscribed rectangle of the outline and filter according to the aspect ratio of the ROI to determine the rectangular bright area and black area

[0112] Step 8: Determine the rectangular bright area and black area according to the gray value;

[0113]

[0114] The grayscale value of the black area is small, while the grayscale value of the light area is large. The black area and the light area are determined based on this.

[0115] Embodiment 2 is a further elaboration on the basis of Embodiment 1:

[0116] The method also includes step nine: by collecting a large number of sample images of rectangular bright areas and black areas of different sizes and time, using these sample images as input and the vehicle distance corresponding to each image as output, BP neural network training is performed to obtain a BP neural network model for judging the vehicle distance corresponding to the image.

[0117] Embodiment 3 is a further elaboration on the basis of Embodiment 2:

[0118] It also includes step ten: collecting image data to test the model, comparing and correcting the distance judged by the model for the image with the actual measured distance, continuously adding new sample data, continuously iterating and upgrading the model, and improving the judgment accuracy of the model.

[0119] Gaussian filtering is a linear smoothing filter that is suitable for eliminating Gaussian noise and is widely used in the denoising process of image processing. Gaussian filtering is the process of weighted averaging the entire image. The value of each pixel is obtained by weighted averaging the value of itself and other pixels in the neighborhood.

[0120] The specific operation of Gaussian filtering in step 1 is:

[0121] Use a template to scan each pixel in the image, and use the weighted average grayscale value of the pixels in the neighborhood determined by the template to replace the value of the central pixel of the template. For mean filtering and box filtering, the weight of each pixel in the neighborhood is equal; in Gaussian filtering, the weight value of the center point will be increased, and the weight value far away from the center point will be reduced. On this basis, the sum of the different weights of each pixel value in the neighborhood is calculated;

[0122] The one-dimensional Gaussian distribution formula is as follows:

[0123]

[0124] The two-dimensional Gaussian distribution formula is as follows:

[0125]

[0126] The center position of the template is used as the coordinate origin for sampling, and the coordinates of each position are substituted into the Gaussian function G. Each value obtained is arranged according to the position to obtain the template.

[0127] The output template has two forms:

[0128] (1) Decimal type: The value is calculated directly without any processing.

[0129] (2) Integer type: Normalize the obtained value, that is, normalize the value in the upper left corner to 1, divide each other coefficient by the coefficient in the upper left corner, and then round it up. When using an integer template, you need to add a coefficient in front of the template, which is the reciprocal of the sum of the template coefficients.

[0130] For example: Generate a template with a Gaussian kernel of 3*3 and σ=0.8

[0131] Decimal template:

[0132] 0.057118 0.12476 0.057118 0.12476 0.2725 0.12476 0.057118 0.12476 0.057118

[0133] Integer template:

[0134] 1 2.1842 1 2.1842 4.7707 2.1842 1 2.1842 1

[0135] After rounding and adding coefficients, we get the final result:

[0136]

[0137] In actual use, Gaussian filtering may use convolution kernels of different sizes. The convolution kernels may be 3×3, 5×5, or 7×7. In Gaussian filtering, the width and height of the kernel can be different, but they must be odd numbers.

[0138] Image grayscale means that the image has no color information. For example, the original color image is composed of three colors, RGB (that is, each pixel has three values). Now the image is grayscaled, and each pixel has only one value (0-255) to represent the depth of the color.

[0139] For color images, the color is determined under a three-dimensional coordinate system (that is, the RGB model), while the coordinates of grayscale images are determined under a one-dimensional coordinate system with a value range of 0-255.

[0140] The grayscale processing method of the image in step 2 is:

[0141] f(x,y)=0.3R(x,y)+0.59G(x,y)+0.11B(x,y) (2-1)

[0142] Where: f(x, y) is the value of the pixel after grayscale;

[0143] R(x, y), G(x, y), and B(x, y) are the pixel values ​​of the red, green, and blue color channels respectively;

[0144] The pixel values ​​of the red, green, and blue color channels are multiplied by the corresponding coefficients, and finally the grayscale value of the pixel is calculated.

[0145] The Sobel operator in step 3 is mainly used to obtain the first-order gradient of a digital image, and its common application is edge detection and extraction of an image;

[0146] The sobel operator uses two 3*3 matrix operators to convolve with the original image to obtain the horizontal G(x) and vertical G(y) gradient values ​​respectively. If the gradient value is greater than a certain threshold, the point is considered to be an edge point.

[0147] The Sobel operator is derived in the x and y directions:

[0148]

[0149]

[0150] The final result is:

[0151]

[0152] Only the vertical edges need to be extracted, so only G y That is, the vertical edge of the image can be extracted.

[0153] The image binarization in step 4 is to set the grayscale value of the pixel on the image to 0 or 255, that is, to make the entire image appear in obvious black and white effect;

[0154] Each pixel in a binary image has only two possible values: either pure black (0) or pure white (1).

[0155]

[0156] Where: f(i) is an image;

[0157] i is the pixel value of the pixel;

[0158] T is the judgment threshold;

[0159] The image binarization method uses the maximum inter-class variance method OTSU, and finds a threshold value so that the sum of the variances of the two parts of pixels greater than and less than the threshold is the largest. The purpose is to remove as much information as possible and only retain the most basic information;

[0160] For image I(x,y), the proportion of foreground pixels in the entire image is ω0, and its average grayscale is μ0. The proportion of background pixels in the entire image is ω1, and its average grayscale is μ1. The total average grayscale of the image is μ, and the inter-class variance is g.

[0161] Assuming that the background of the image is dark, and the size of the image is M×N, the number of pixels whose grayscale value is less than the threshold T in the image is recorded as N0, and the number of pixels whose grayscale value is greater than the threshold T is recorded as N1, then:

[0162] ω0=N0 / M×N

[0163] ω1=N1 / M×N

[0164] N0+N1=M×N

[0165] ω0+ω1=1

[0166] μ=ω0*μ0+ω1*μ1 (4-2)

[0167] g=ω0(μ0-μ)^2+ω1(μ1-μ)^2 (4-3)

[0168] Substituting formula (4-2) into formula (4-3), we get the equivalent formula:

[0169] g=ω0ω1(μ0-μ1)^2 (4-4)

[0170] The traversal method is used to obtain the threshold T that maximizes the inter-class variance g, which is what we are looking for.

[0171] The specific steps of step 5 are as follows: the process of dilating and then corroding the image is called a closing operation. First, dilation is performed to fill small holes in the connected domain, expand the boundary of the connected domain, and connect two adjacent connected domains. Then, the expansion of the connected domain boundary and the increase in area caused by the dilation operation are reduced by the corrosion operation. It has the functions of filling small holes in objects, connecting adjacent objects and smoothing boundaries. Its mathematical expression is as follows:

[0172] dst=close(src,element)=erode(dilate(src,element))(5-1).

[0173] Image contour is a reflection of the discontinuity of local characteristics of the image. Contour extraction adopts the method of hollowing out internal points. If the target pixel in the image after the closing operation is black and the eight pixels adjacent to it are all black, then the target pixel is deleted (set to white), and each pixel on the boundary is traversed to obtain a new target image.

[0174] Find the convex hull of the obtained contour. The convex hull is a convex polygon formed by connecting the outermost points of the point set on a given two-dimensional plane. It can contain all the points in the point set. Calculate the angle of the convex hull line for the obtained convex hull points. Rotate the convex hull points according to the calculated convex hull line angle.

[0175] Get the maximum and minimum values ​​of the rotated point in the x and y directions respectively; use the obtained maximum and minimum values ​​to calculate the area of ​​the minimum enclosing rectangle at this time. Thus, the coordinates of the four points of the minimum enclosing rectangle are determined.

[0176] The rectangular frames are screened according to the aspect ratio of the ROI. First, various rectangular frames with angles are removed, and then the final ROI area is determined according to the aspect ratio.

[0177] BP neural network is a multi-layer feedforward neural network, and its main characteristics are: the signal is forward propagated, while the error is backward propagated. Specifically, for the following neural network model with only one hidden layer: the process of BP neural network is mainly divided into two stages. The first stage is the forward propagation of the signal, from the input layer through the hidden layer, and finally to the output layer; the second stage is the backward propagation of the error, from the output layer to the hidden layer, and finally to the input layer, and the weights and biases from the hidden layer to the output layer, and the weights and biases from the input layer to the hidden layer are adjusted in turn.

[0178] The specific steps of BP neural network training in step nine are as follows:

[0179] The transfer function used by the BP network is a nonlinear transformation function - the Sigmoid function, which is characterized by the fact that the function itself and its derivatives are continuous, so it is very convenient to process. The unipolar S-type function is defined as follows:

[0180] f(x)=1 / (1+e -x ) (9-1)

[0181] When using the S-type activation function, input:

[0182] net=x1w1+x2w2+…+x n w n

[0183] The output is:

[0184] y = f(net) = 1 / (1+e -net ) (9-2)

[0185] Then, the derivative of the output y is:

[0186] F′(net)=1 / (1+e -net )-1 / (1+e -net ) 2 =y(1-y) (9-3)

[0187] The first step is to initialize the network, assign a random number in the interval (-1,1) to each connection weight, set the error function e, give the calculation accuracy εε and the number of learning times M;

[0188] The second step is to calculate and select the kth input sample and the corresponding expected output:

[0189] x(k)=(x1k,x2k,...,x n k)

[0190] d(k)=(d1k,d2k,...,d q k)

[0191] The third step is to calculate the input and output of each neuron in the hidden layer:

[0192]

[0193] ho h (k) = f(hi h (k)) h=1,2,...p

[0194]

[0195] yo o (k) = f(yi o (k)) o=1,2,...p

[0196] The fourth step is to use the expected output and actual output of the network to calculate the partial derivatives of the error function with respect to each neuron in the output layer:

[0197]

[0198]

[0199]

[0200]

[0201] The fifth step is to use the δ of each neuron in the output layer o (k) and the output of each neuron in the hidden layer to correct the connection weight w ho (k)

[0202]

[0203]

[0204] The sixth step is to use the δ of each neuron in the hidden layer h (k) and the input of each neuron in the input layer to correct the connection weights:

[0205]

[0206]

[0207] Step 7: Calculate the global error

[0208]

[0209] The eighth step is to determine whether the network error meets the requirements. When the error is greater than the preset accuracy or the number of learning times is greater than the set maximum value, the algorithm ends. Otherwise, select the next learning sample and the corresponding expected output, return to the third step, and enter the next round of learning.

[0210] This method divides the surrounding black area and the middle rectangular bright area. The two will be clearly layered when captured by a camera, which is convenient for camera capture. The amount of information is small, which is convenient for building a database and does not require a huge data pool. Simple ranging is not convenient for determining information such as lane vehicle posture. The deformation of the clear rectangular bright area can facilitate measurement.

[0211] The above disclosure is only a specific embodiment of the present invention, but the present invention is not limited thereto, and any changes that can be conceived by those skilled in the art should fall within the protection scope of the present invention.

Claims

1. A vehicle automatic driving distance judgment algorithm, characterized in that: The following steps are involved: Step 1: The acquired image of the vehicle in front is subjected to image preprocessing, and Gaussian filtering is performed on the image, i.e., Gaussian blurring, to remove image noise; Step 2: The image after Gaussian filtering is grayed to obtain a grayscale image, thereby removing the color information of the image and reducing the amount of calculation; Step 3: Use the edge detection sobel operator to extract the vertical edge features of the image; Step 4: Convert the image into a binary image through binarization, that is, an image with pixel values ​​of only 0 or 1; Step 5: Obtain several rectangular frames by performing a closing operation on the binary image; Step 6: By performing a contour operation on the image, all contours in the image are obtained, which include the region of interest, that is, the rectangular bright area and the black area; as the distance between the vehicles changes, the rectangular bright area and the black area are deformed; The basis for dividing the rectangular bright area and the black area in step 6 is: On a sunny day, the shadows of the rear bumper and wheels on both sides of the car under the sun will form a rectangular black area on the ground, and the rear bumper, wheels on both sides of the car and the ground will form a rectangular bright area in the vertical plane; Step 7: Find the minimum circumscribed rectangle of the outline, and screen according to the aspect ratio of the region of interest ROI to determine the rectangular bright area and black area; Step 8: Determine the rectangular bright area and black area according to the gray value; (8-1) The grayscale value of the black area is small, while the grayscale value of the bright area is large, and the black area and the bright area are determined based on this; The method also includes step nine: by collecting a large number of sample images of rectangular bright areas and black areas of different sizes and time, using these sample images as input and the vehicle distance corresponding to each image as output, performing BP neural network training to obtain a BP neural network model for judging the vehicle distance corresponding to the image; The method also includes step 10: collecting image data to test the model, comparing and correcting the distance determined by the model for the image with the actual measured distance, continuously adding new sample data, continuously iterating and upgrading the model, and improving the judgment accuracy of the model; The rectangular bright area and the black area obtained by division are easy to be captured by the camera due to obvious stratification; the amount of information of the rectangular bright area and the black area is small, which is convenient for building a database without requiring a huge data pool; By deforming the clear rectangular bright area, it is convenient to measure and determine information including the lane and vehicle posture.

2. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: The specific operation of Gaussian filtering in step 1 is: Use a template to scan each pixel in the image, and use the weighted average grayscale value of the pixels in the neighborhood determined by the template to replace the value of the central pixel of the template. For mean filtering and box filtering, the weight of each pixel in the neighborhood is equal; in Gaussian filtering, the weight value of the center point will be increased, and the weight value away from the center point will be reduced. On this basis, the sum of the different weights of each pixel value in the neighborhood is calculated.

3. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: The grayscale processing method of the image in step 2 is: (2-1) in: is the value of the pixel after grayscale; , , They are the pixel values ​​of the red, green, and blue color channels respectively; The pixel values ​​of the red, green, and blue color channels are multiplied by the corresponding coefficients, and finally the grayscale value of the pixel is calculated.

4. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: In step 3, the Sobel operator is used to obtain the first-order gradient of the digital image, and its common application is to perform edge detection and extraction on the image; The sobel operator uses two 3*3 matrix operators to convolve with the original image to obtain the horizontal and vertical gradient values ​​respectively. If the gradient value is greater than a certain threshold, the point is considered to be an edge point.

5. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: The image binarization in step 4 is to set the grayscale value of the pixel on the image to 0 or 255, that is, to make the entire image appear in obvious black and white effect; Each pixel in a binary image has only two possible values: either pure black (0) or pure white (1). (4-1) in: It’s an image; is the pixel value of the pixel; is the judgment threshold; The image binarization method selects the maximum inter-class variance method OTSU, and finds a threshold value so that the sum of the variances of the two parts of pixels greater than and less than the threshold value is the maximum; For images The proportion of foreground pixels in the entire image is ω0, and its average grayscale is μ0. The proportion of background pixels in the entire image is ω1, and its average grayscale is μ1. The total average grayscale of the image is μ, and the inter-class variance is g. Assume that the background of the image is dark, the size of the image is M×N, and the grayscale value of the pixel in the image is less than the threshold The number of pixels is recorded as N0, and the pixel grayscale is greater than the threshold The number of pixels is recorded as N1, then: ω0=N0 / M×N ω1=N1 / M×N N0+N1=M×N ω0+ω1=1 μ=ω0*μ0+ω1*μ1 (4-2) g=ω0(μ0-μ)^2+ω1(μ1-μ)^2 (4-3) Substituting formula (4-2) into formula (4-3), we get the equivalent formula: g=ω0ω1(μ0-μ1)^2 (4-4) The traversal method is used to obtain the threshold that maximizes the inter-class variance g , which is what you seek.

6. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: The specific steps of step five are as follows: the process of first dilating and then corroding the image is called a closing operation. Dilation is first performed to fill small holes in the connected domain, expand the boundary of the connected domain, and connect two adjacent connected domains. Then, the corrosion operation is used to reduce the expansion of the boundary of the connected domain and the increase in area caused by the dilation operation, which has the effect of filling small holes in objects, connecting adjacent objects and smoothing boundaries.

7. The vehicle automatic driving distance determination algorithm according to claim 1, characterized in that: The transfer function adopted by the BP neural network in step nine is the nonlinear transformation function Sigmoid function.

Citation Information

Patent Citations

  • Distance measuring method and distance measuring device

    CN113091694A

  • Vehicle detecting method based on Gauss difference multi-scale edge fusion

    CN103927526A

  • Method for distinguishing tree species based on leaf pictures

    CN114565525A