Lane line recognition method, electronic device and storage medium
A lane line recognition method applied to an electronic device is provided. In the method, the electronic device obtains a target image comprising lane lines, and converts the target image into an aerial view of the lane lines. Once a left lane line curve and a right lane line curve are obtained by performing a curve fitting on the lane lines according to pixel points of the aerial view, the electronic device determines whether a recognition of the lane lines is accurate according to the left lane line curve and the right lane line curve.
1 . A lane line recognition method applied to an electronic device, the method comprising:
obtaining a target image comprising lane lines, which comprises a left lane line and a right lane line;
converting the target image into an aerial view of the lane lines;
obtaining a left lane line curve and a right lane line curve by performing a curve fitting on the lane lines according to pixel points of the aerial view; and
determining whether a recognition of the lane lines is accurate according to the left lane line curve and the right lane line curve, and comprising:
determining whether there is an intersection point between the left lane line curve and the right lane line curve;
determining that the identification of the lane lines is inaccurate in response that there is the intersection point between the left lane line curve and the right lane line curve;
in response that there is no intersection point between the left lane line curve and the right lane line curve, determining whether a curvature of the left lane line curve and a curvature of the right lane line curve are the same according to a coefficient of an equation of the left lane line curve and a coefficient of an equation of the right lane line curve; and
determining that the recognition of the lane lines is inaccurate in response that the curvature of the left lane line curve and the curvature of the right lane line curve are different.
2 . The lane line recognition method according to claim 1 , wherein the obtaining of the target image comprising the lane lines comprises:
obtaining an original image by capturing a scene in front of the vehicle;
extracting the lane lines from the original image;
converting the extracted lane lines as a binarized image; and
obtaining the target image by superimposing pixel points in the binarized image.
3 . The lane line recognition method according to claim 1 , wherein the converting of the target image into the aerial view of the lane lines comprises:
determining non-zero pixel points from the target image and taking each of the non-zero pixel points as a target point, the non-zero pixel point being a pixel point of which at least one of an abscissa and an ordinate is not zero;
obtaining an inverse perspective transformation matrix according to a coordinate transformation formula and coordinates of each target point in the target image; and
obtaining the aerial view based on the inverse perspective transformation matrix.
4 . The lane line recognition method according to claim 1 , wherein the obtaining of the left lane line curve and the right lane line curve by performing the curve fitting on the lane lines according to the pixel points of the aerial view comprises:
generating a non-zero pixel point distribution map according to a number of non-zero pixel points in each column in the aerial view, the non-zero pixel point distribution map comprising a first peak value and a second peak value, and the first peak value being located on a left of the second peak value;
determining a first initial position of the left lane line in the aerial view according to the first peak value, and determining a second initial position of the right lane line in the aerial view according to the second peak value;
sliding a first sliding window based on the first initial position, and sliding a second sliding window based on the second initial position;
fitting all non-zero pixel points included in the first sliding window to be a first curve during a sliding of the first sliding window in the aerial view, and taking the first curve as the left lane line curve; and
fitting all non-zero pixel points included in the second sliding window to be a second curve during a sliding of the second sliding window in the aerial view, and taking the second curve as the right lane line curve, wherein a sliding of the second sliding window is adjusted according to the first curve.
5 . The lane line recognition method according to claim 1 , wherein the determining of whether there is the intersection point between the left lane line curve and the right lane line curve comprises:
acquiring a plurality of pixel points on the left lane line curve, acquiring a plurality of pixel points on the right lane line curve; and
determining whether there is the intersection between the left lane line curve and the right lane line curve according to the plurality of pixel points on the left lane line curve and the plurality of pixel points on the right lane line curve.
6 . The lane line recognition method according to claim 1 , wherein the determining of whether the curvature of the left lane line curve and the curvature of the right lane line curve are the same according to the coefficient of the equation of the left lane line curve and the coefficient of the equation of the right lane line curve comprises:
obtaining a coefficient a1 of a highest order term of the equation of the left lane line curve;
obtaining a coefficient a2 of a highest order term of the equation of the right lane line curve;
calculating an absolute value |a1−a2|; and
determining that the curvature of the left lane line curve and the curvature of the right lane line curve are different in response that the absolute value is greater than a preset threshold.
7 . An electronic device comprising:
a storage device;
at least one processor; and
the storage device storing one or more programs, which when executed by the at least one processor, cause the at least one processor to:
obtain a target image comprising lane lines, which comprises a left lane line and a right lane line;
convert the target image into an aerial view of the lane lines;
obtain a left lane line curve and a right lane line curve by performing a curve fitting on the lane lines according to pixel points of the aerial view; and
determine whether a recognition of the lane lines is accurate according to the left lane line curve and the right lane line curve, and comprising:
determining whether there is an intersection point between the left lane line curve and the right lane line curve;
determining that the identification of the lane lines is inaccurate in response that there is the intersection point between the left lane line curve and the right lane line curve;
in response that there is no intersection point between the left lane line curve and the right lane line curve, determining whether a curvature of the left lane line curve and a curvature of the right lane line curve are the same according to a coefficient of an equation of the left lane line curve and a coefficient of an equation of the right lane line curve; and
determining that the recognition of the lane lines is inaccurate in response that the curvature of the left lane line curve and the curvature of the right lane line curve are different.
8 . The electronic device according to claim 7 , wherein the at least one processor acquires the target image comprising the lane lines by:
obtaining an original image by capturing a scene in front of the vehicle;
extracting the lane lines from the original image;
converting the extracted lane lines as a binarized image; and
obtaining the target image by superimposing pixel points in the binarized image.
9 . The electronic device according to claim 7 , wherein the at least one processor converts the target image into the aerial view of the lane lines by:
determining non-zero pixel points from the target image and taking each of the non-zero pixel points as a target point, the non-zero pixel point being a pixel point of which at least one of an abscissa and an ordinate is not zero;
obtaining an inverse perspective transformation matrix according to a coordinate transformation formula and coordinates of each target point in the target image; and
obtaining the aerial view based on the inverse perspective transformation matrix.
10 . The electronic device according to claim 7 , wherein the at least one processor obtains the left lane line curve and the right lane line curve by performing the curve fitting on the lane lines according to the pixel points of the aerial view by:
generate a non-zero pixel point distribution map according to a number of non-zero pixel points in each column in the aerial view, the non-zero pixel point distribution map comprising a first peak value and a second peak value, and the first peak value being located on a left of the second peak value;
determine a first initial position of the left lane line in the aerial view according to the first peak value, and determine a second initial position of the right lane line in the aerial view according to the second peak value;
slide a first sliding window based on the first initial position, and slide a second sliding window based on the second initial position;
fit all non-zero pixel points included in the first sliding window to be a first curve during a sliding of the first sliding window in the aerial view, and take the first curve as the left lane line curve; and
fit all non-zero pixel points included in the second sliding window to be a second curve during a sliding of the second sliding window in the aerial view, and take the second curve as the right lane line curve, wherein a sliding of the second sliding window is adjusted according to the first curve.
11 . The electronic device according to claim 7 , wherein the at least one processor determines whether there is the intersection point between the left lane line curve and the right lane line curve by:
acquiring a plurality of pixel points on the left lane line curve, acquiring a plurality of pixel points on the right lane line curve; and
determining whether there is the intersection between the left lane line curve and the right lane line curve according to the plurality of pixel points on the left lane line curve and the plurality of pixel points on the right lane line curve.
12 . The electronic device according to claim 7 , wherein the at least one processor determines whether the curvature of the left lane line curve and the curvature of the right lane line curve are the same according to the coefficient of the equation of the left lane line curve and the coefficient of the equation of the right lane line curve by:
obtaining a coefficient a1 of a highest order term of the equation of the left lane line curve;
obtaining a coefficient a2 of a highest order term of the equation of the right lane line curve;
calculating an absolute value |a1−a2|; and
determining that the curvature of the left lane line curve and the curvature of the right lane line curve are different in response that the absolute value is greater than a preset threshold.
13 . A non-transitory storage medium having instructions stored thereon, when the instructions are executed by a processor of an electronic device, the processor is caused to perform a lane line recognition method, wherein the method comprises:
obtaining a target image comprising lane lines, which comprises a left lane line and a right lane line;
converting the target image into an aerial view of the lane lines;
obtaining a left lane line curve and a right lane line curve by performing a curve fitting on the lane lines according to pixel points of the aerial view; and
determining whether a recognition of the lane lines is accurate according to the left lane line curve and the right lane line curve, and comprising:
determining whether there is an intersection point between the left lane line curve and the right lane line curve;
determining that the identification of the lane lines is inaccurate in response that there is the intersection point between the left lane line curve and the right lane line curve;
in response that there is no intersection point between the left lane line curve and the right lane line curve, determining whether a curvature of the left lane line curve and a curvature of the right lane line curve are the same according to a coefficient of an equation of the left lane line curve and a coefficient of an equation of the right lane line curve; and
determining that the recognition of the lane lines is inaccurate in response that the curvature of the left lane line curve and the curvature of the right lane line curve are different.
14 . The non-transitory storage medium according to claim 13 , wherein the obtaining of the target image comprising the lane lines comprises:
obtaining an original image by capturing a scene in front of the vehicle;
extracting the lane lines from the original image;
converting the extracted lane lines as a binarized image; and
obtaining the target image by superimposing pixel points in the binarized image.
15 . The non-transitory storage medium according to claim 13 , wherein the converting of the target image into the aerial view of the lane lines comprises:
determining non-zero pixel points from the target image and taking each of the non-zero pixel points as a target point, the non-zero pixel point being a pixel point of which at least one of an abscissa and an ordinate is not zero;
obtaining an inverse perspective transformation matrix according to a coordinate transformation formula and coordinates of each target point in the target image; and
obtaining the aerial view based on the inverse perspective transformation matrix.
16 . The non-transitory storage medium according to claim 13 , wherein the obtaining of the left lane line curve and the right lane line curve by performing the curve fitting on the lane lines according to the pixel points of the aerial view comprises:
generating a non-zero pixel point distribution map according to a number of non-zero pixel points in each column in the aerial view, the non-zero pixel point distribution map comprising a first peak value and a second peak value, and the first peak value being located on a left of the second peak value;
determining a first initial position of the left lane line in the aerial view according to the first peak value, and determining a second initial position of the right lane line in the aerial view according to the second peak value;
sliding a first sliding window based on the first initial position, and sliding a second sliding window based on the second initial position;
fitting all non-zero pixel points included in the first sliding window to be a first curve during a sliding of the first sliding window in the aerial view, and taking the first curve as the left lane line curve; and
fitting all non-zero pixel points included in the second sliding window to be a second curve during a sliding of the second sliding window in the aerial view, and taking the second curve as the right lane line curve, wherein a sliding of the second sliding window is adjusted according to the first curve.
17 . The non-transitory storage medium according to claim 13 ,
wherein the determining of whether the curvature of the left lane line curve and the curvature of the right lane line curve are the same according to the coefficient of the equation of the left lane line curve and the coefficient of the equation of the right lane line curve comprises:
obtaining a coefficient a1 of a highest order term of the equation of the left lane line curve;
obtaining a coefficient a2 of a highest order term of the equation of the right lane line curve;
calculating an absolute value |a1−a2|; and
determining that the curvature of the left lane line curve and the curvature of the right lane line curve are different in response that the absolute value is greater than a preset threshold.
18 . The non-transitory storage medium according to claim 13 , wherein the determining of whether there is the intersection point between the left lane line curve and the right lane line curve comprises:
acquiring a plurality of pixel points on the left lane line curve, acquiring a plurality of pixel points on the right lane line curve; and
determining whether there is the intersection between the left lane line curve and the right lane line curve according to the plurality of pixel points on the left lane line curve and the plurality of pixel points on the right lane line curve.