Road centerline extraction method, computer device and storage medium
By acquiring and processing the road centerline in the image and restoring it using the relevant line segments of the intersection, the problem of low efficiency and low accuracy of road centerline extraction in the existing technology is solved, and more efficient and accurate road centerline extraction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2023-12-26
- Publication Date
- 2026-07-24
AI Technical Summary
Existing methods for extracting road centerlines are inefficient or inaccurate, manual annotation is labor-intensive and resource-intensive, and image processing is easily affected by noise.
By acquiring the image to be processed, centerline extraction is performed. The target intersection is determined using the relevant line segments of the initial centerline, and then restored to its original shape, thereby improving extraction efficiency and accuracy.
It effectively restores the original shape of road intersections and improves the efficiency and accuracy of road centerline extraction.
Smart Images

Figure CN117934588B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method for extracting the center line of a road, a computer device, and a storage medium. Background Technology
[0002] With the rapid development of technology, road centerline extraction technology is being applied to more and more scenarios, such as vehicle navigation, 3D scene modeling, and urban planning.
[0003] Current methods for extracting road centerlines mainly fall into two categories: manual annotation extraction and image processing extraction. Manual annotation extraction requires manually marking the road surface and then determining the centerline based on the center points of different roads. While manual annotation extraction can guarantee high accuracy, it is extremely resource-intensive and inefficient. Image processing extraction is easily affected by factors such as image noise, making it difficult to guarantee the accuracy of centerline extraction.
[0004] Therefore, existing methods for extracting road centerlines suffer from problems such as low efficiency or low accuracy. Summary of the Invention
[0005] The main technical problem addressed by this application is to provide a method, computer equipment, and storage medium for extracting road centerlines, which can improve the efficiency and accuracy of road centerline extraction.
[0006] To address the aforementioned issues, the first aspect of this application provides a method for extracting road centerlines. This method includes: acquiring an image to be processed, wherein the image contains a road in a target scene; extracting the centerline from the image to obtain an initial centerline of the road; using relevant line segments from each intersection along the initial centerline to determine target intersections in the road that meet the intersection merging conditions; and restoring the target intersections to obtain the final centerline of the road.
[0007] To address the aforementioned problems, a second aspect of this application provides a computer device comprising a memory and a processor coupled to each other, wherein the memory stores program data and the processor executes the program data to implement any step of the aforementioned method for extracting the road centerline.
[0008] To address the aforementioned problems, a third aspect of this application provides a computer-readable storage medium storing program data executable by a processor, the program data being used to implement any step of the road centerline extraction method described above.
[0009] The above scheme involves acquiring an image to be processed, which contains roads in the target scene; extracting the centerline of the image to obtain the initial centerline of the road; using the relevant line segments of each intersection in the initial centerline to determine the target intersections in the road that meet the intersection merging conditions; and restoring the target intersections to obtain the final centerline of the road. By restoring the target intersections, the original shape of the road intersections can be effectively restored, making the extracted centerline of the road at the intersections more consistent with the original shape of the intersections, thereby improving the efficiency and accuracy of road centerline extraction.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in this application, the accompanying drawings required in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Among them:
[0012] Figure 1 This is a flowchart illustrating the first embodiment of the method for extracting the road centerline of this application;
[0013] Figure 2 This is an example schematic diagram of an embodiment of the image to be processed in this application;
[0014] Figure 3 This is an example schematic diagram of an embodiment of the initial centerline of this application;
[0015] Figure 4 This is a flowchart illustrating an embodiment of step S13 of this application;
[0016] Figure 5 This is an example schematic diagram of an embodiment of the relevant line segment in this application;
[0017] Figure 6 This is a schematic diagram illustrating another embodiment of the line segment related to this application;
[0018] Figure 7 This is a schematic diagram of an example of the previous embodiment of the intersection restoration in this application;
[0019] Figure 8 This is a schematic diagram of an example of an embodiment of the intersection restoration of this application;
[0020] Figure 9 This is a flowchart illustrating the second embodiment of the method for extracting the road centerline of this application;
[0021] Figure 10 This is a schematic diagram of an example of a previous embodiment of the deburring process in this application;
[0022] Figure 11 This is a schematic diagram of an example of a deburring process according to this application;
[0023] Figure 12 This is an example schematic diagram of a previous embodiment of the de-aliasing process in this application;
[0024] Figure 13 This is a schematic diagram of an example embodiment after the de-aliasing process of this application;
[0025] Figure 14 This is an example schematic diagram of a previous embodiment of the intersection point merging in this application;
[0026] Figure 15 This is a schematic diagram of an example of an embodiment after the intersection point is merged in this application;
[0027] Figure 16 This is a schematic diagram of an embodiment of the road centerline extraction device of this application;
[0028] Figure 17 This is a schematic diagram of the structure of an embodiment of the computer device of this application;
[0029] Figure 18 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0031] The terms "first" and "second" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus.
[0032] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0033] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0034] This application provides the following embodiments, and each embodiment is described in detail below.
[0035] It is understood that the method for extracting the road centerline in this application can be executed by a computer device, which can be any device with processing capabilities, such as a mobile phone, computer, server, etc., and this application does not impose any restrictions on it.
[0036] The centerline referred to in this application can refer to the line in the middle area of the road. It can be understood that any line located in the middle area of the road can be used as the centerline of this application. The centerline is not necessarily a line located in the center of the road in the standard sense. This application does not impose any restrictions on this.
[0037] Please see Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the road centerline extraction method of this application. The method may include the following steps:
[0038] S11: Obtain the image to be processed, which contains roads in the target scene.
[0039] It can take pictures of the target area to obtain a processed image of the road in the target scene.
[0040] In some implementations, the image to be processed can be a remote sensing image or an aerial image, and may contain roads in the target area where the road centerline needs to be extracted.
[0041] In some implementations, please refer to Figure 2 The image to be processed can be binarized by setting the pixels with the road as the foreground to 255 (i.e., white) and the remaining pixels as the background to 0 (i.e., black), thus obtaining a binary image of the image to be processed. In the binary image, the area of the road can be represented by pixels 255 (i.e., white). The following section uses the binary image as the image to be processed for subsequent processing.
[0042] S12: Extract the centerline of the image to be processed to obtain the initial centerline of the road.
[0043] Before step S12, the image to be processed can be dilated to reduce the centerline bifurcation caused by road holes during the subsequent centerline extraction process.
[0044] Then, the centerline of the image to be processed is extracted to obtain the initial centerline of the road. Specifically, a thinning method (also known as the morphological skeleton method) can be used to extract the centerline of the image to be processed to obtain the initial centerline of the road. The thinning method is a morphological processing method that repeatedly erodes the light stripes, stripping away the boundaries of the light stripes to obtain a single-pixel-width connected line of light stripes (also known as the skeleton). This method uses the thinning curve of the light stripe region as the centerline of the light stripes through thinning techniques. There are many thinning methods, all of which can achieve the extraction of the road centerline. This application does not limit this method.
[0045] In some application scenarios, taking the Zhang-Suen thinning algorithm as an example, the Zhang-Suen thinning algorithm can be used to extract the centerline of the image to be processed, so as to extract the road centerline and obtain a binary image of the road centerline with a width of one pixel, which is the initial centerline of the road.
[0046] The Zhang-Suen thinning algorithm can include the following steps: marking the boundary points to be deleted; deleting the marked points; continuing to mark the remaining boundary points to be deleted; deleting the marked points. This basic process is repeated until there are no more points to be deleted, at which point the algorithm terminates, generating the skeleton of the region, which is the initial centerline of the road.
[0047] As an example, please refer to Figure 3 By refining the road region of a binary image, the output image can be obtained as the skeleton of the refined binary image, which is the initial centerline of the road.
[0048] S13: Using the relevant line segments of each intersection in the initial centerline, determine the target intersections in the road that meet the intersection merging conditions.
[0049] Multiple segments of the initial centerline can be obtained to determine the relevant segments belonging to each intersection. Then, using the relevant segments of each intersection in the initial centerline, such as obtaining the included angle of the relevant segments of the intersection, it can be determined whether each intersection in the road meets the intersection merging condition. If the intersection merging condition is met, the intersection is determined as the target intersection. Thus, target intersections in the road that meet the intersection merging condition can be determined in this way.
[0050] In some embodiments, please refer to Figure 4 This embodiment can further extend step S13 of the above embodiment. Using the relevant line segments of each intersection in the initial centerline, the target intersections in the road that meet the intersection merging conditions are determined. This embodiment may include the following steps:
[0051] S131: Determine the adjacent line segments and extended line segments of each intersection of the initial centerline, wherein the adjacent line segment is the first line segment connected to the intersection point of the intersection, and the extended line segment is the second line segment of the intersection along the extension direction of the adjacent line segment.
[0052] In the image of the initial center line, multiple segments of the initial center line can be obtained, such as each straight line in the initial center line.
[0053] In the image of the initial centerline, the adjacent line segments and extended line segments of each intersection of the initial centerline are determined. An intersection can be an area connected by at least three segmented line segments, and the point where they connect or intersect is the intersection point. Intersections include, but are not limited to, road intersections such as "+", "Y", and "T" shapes.
[0054] The adjacent segment is the first segment connecting to the intersection, that is, the first segment extending outward from the intersection point. It can be considered the first segment, i.e., the adjacent segment. The extended segment is the second segment along the extension direction of the adjacent segment from the intersection point. The direction in which the intersection point continues to extend towards the adjacent segment is the extension direction. The next segment can be obtained in the extension direction as the second segment, i.e., the extended segment corresponding to the nearest segment. A set of adjacent segments and extended segments can be determined separately for each segment extending from the intersection point.
[0055] As an example, such as a Y-shaped intersection, three sets of adjacent line segments and extended line segments can be obtained. See subsequent steps for details. Figure 5 The included angle can be obtained by using the adjacent line segments (L11, L21) and extended line segments (L12, L22) of the two groups respectively.
[0056] S132: Use the first included angle between adjacent line segments and the second included angle between extended line segments to determine whether the intersection meets the conditions for intersection merging.
[0057] In some implementations, prior to step S132, a first included angle between any two groups of adjacent line segments at the intersection and a second included angle between extended line segments can be obtained.
[0058] Two adjacent points can be selected from at least two adjacent line segments at the intersection. One of these two adjacent points is the intersection point, and the other can be another segment endpoint of the adjacent line segment (such as the point closest to the intersection), or a point other than the intersection point; this application does not impose any restrictions on this. The following explanation uses the example of the other point being another segment endpoint of the adjacent line segment.
[0059] Simultaneously, two extension points can be selected on at least two extension segments at the intersection; wherein, one of the two extension points is the same as one of the two adjacent points, and the same point can be another adjacent point outside the intersection. The two extension points can be two segment endpoints of the extension segment or points selected on the extension segment; this application does not impose any restrictions on this. The following explanation uses the example where the other one can be two segment endpoints of the extension segment, and the same point can be another adjacent point outside the intersection.
[0060] In one application scenario, a neighboring line segment consists of two neighboring points, and an extended line segment consists of two extended points.
[0061] Then, the angle between two adjacent points can be calculated to obtain the first included angle; and the angle between two extended points can be calculated to obtain the second included angle.
[0062] Please see Figure 6 As an example, in a Y-shaped intersection with a centerline, any two sets of adjacent line segments and extended line segments can be obtained. The two adjacent line segments include a first adjacent line segment L11 and a second adjacent line segment L12. The two adjacent points selected on the first adjacent line segment L11 are (p11, p12), where p11 is the intersection point and p12 is the point adjacent to the intersection point on the first adjacent line segment L11. The two adjacent points selected on the second adjacent line segment L12 are (p21, p22). Here, p21 is the intersection point (the same point as p11), and p22 is the point adjacent to the intersection point on the second adjacent line segment L12.
[0063] The first included angle between two adjacent line segments (L11, L12) can be obtained by using two adjacent points (p11, p12) on the first adjacent line segment L11 and two adjacent points (p21, p22) on the second adjacent line segment L12. The first included angle can be obtained using the following formula:
[0064] Angle intersection =Angle(Line1) (p11,p12) Line 2 (p21,p22) ).
[0065] In the above formula, Line1 (p11,p12) Line 2 is the first adjacent line segment L11 formed by two adjacent points (p11, p12). (p21,p22) Let L12 be the second nearest line segment formed by two adjacent points (p21, p22). Angle() is the angle calculation function, and Line1 and Line2 represent the line segment calculation functions. intersection This is the first included angle.
[0066] The two extended line segments include a first extended line segment L21 and a second extended line segment L22. Two extension points are selected on the first extended line segment L21: (p12, p13), where p13 is an adjacent point of p12 on the first extended line segment L21. Two extensions are selected on the second extended line segment L22: (p22, p23), where p23 is an adjacent point of p22 on the second extended line segment L22.
[0067] By extending the first extension segment L21 from two points (p12, p13) and the second extension segment L22 from two adjacent points (p22, p23), the second included angle between the two extended segments (L21, L22) can be obtained. The second included angle can be obtained using the following formula:
[0068] Angle direction =Angle(Line3) (p12,p13) Line 4 (p22,p23) ).
[0069] In the above formula, Line 3 (p12,p13) Line 4 is the first extended line segment L21 formed by the two extended points (p12, p13). (p22,p23) The second extension line segment L22 is formed by two extensions (p22, p23). Angle() is the angle calculation function, and Line3 and Line4 represent the line segment calculation functions. direction This is the second included angle.
[0070] S133: In response to the intersection merging condition being met, determine the intersection as the target intersection.
[0071] The conditions for intersection merging include: the first included angle. intersection The angle is greater than the first angle threshold angle_inter, and the second included angle Angle directionLess than the second angle threshold angle_line.
[0072] The first angle threshold and the second angle threshold can be determined according to the specific application scenario, such as empirical values or training values, and this application does not impose any restrictions on them.
[0073] When the first included angle of the adjacent line segment and the second included angle of the extended line segment satisfy the intersection merging condition, the intersection is determined as the target intersection in response to satisfying the intersection merging condition.
[0074] The above scheme determines whether an intersection meets the conditions for merging by using relevant line segments at the intersection. If the conditions for merging are met, it means that the two center lines containing the adjacent line segments and the extended line segments can be merged into one center line. Thus, the target intersection can be restored and merged to obtain a more accurate road center line.
[0075] S14: Restore the target intersection to obtain the final centerline of the road.
[0076] The target intersection can be reconstructed using the corresponding line segments to obtain the reconstructed target points, thereby obtaining the final centerline of the road. The initial centerline and final centerline referred to in this application can both be in the form of images, and this application is not limited to this.
[0077] In some implementations, the target intersection can be restored using the two adjacent line segments or the two adjacent points of each of the two adjacent line segments.
[0078] The two adjacent line segments include a first adjacent line segment and a second adjacent line segment. The first length ratio of the first adjacent line segment to the main line segment and the second length ratio of the second adjacent line segment to the main line segment can be obtained, where the main line segment is the total length of the two adjacent line segments. Then, using the first product of the first length ratio and a first preset point of the first adjacent line segment, and the second product of the second length ratio and a second preset point of the second adjacent line segment, the target restoration point of the intersection is obtained, thus obtaining the final centerline of the road. The target restoration point is used to replace the neighboring points of the two adjacent points of the first and second adjacent line segments that belong to the intersection. The first and second preset points are the neighboring points of the two adjacent points that do not belong to the intersection. For example, if the target restoration point is used to replace the neighboring point of the two adjacent points that is the intersection, the first and second preset points are the neighboring points of the non-intersection points.
[0079] In some implementations, the target restoration point of the intersection can be obtained using the first and second adjacent line segments using the following formula:
[0080]
[0081] In the above formula, Pm represents the target restoration point, which can be used to replace the neighboring point p11 of the first adjacent line segment and the neighboring point p21 of the second adjacent line segment, that is, to replace the original intersection point of the intersection and restore the intersection point. Here, Len() represents the length calculation function, len(Line1... (p11,p12) ) is the length of the first adjacent line segment, len(Line1) (p21,p22) ) is the length of the second adjacent line segment, len(Line1) (p11,p12) )+len(Line1 (p21,p22) ) represents the total length, p12 represents the first preset point, and p22 represents the second preset point.
[0082] As an example, please refer to Figures 7 to 8 During the refinement process, the lines of the road intersections are refined to extract the initial center line. Before the intersection is restored, the intersection point located on the initial center line of the intersection will be located in the middle of the intersection area, which does not match the actual shape of the road line. After the intersection is restored through the above steps, the extraction result of the intersection point is more consistent with the original shape of the intersection.
[0083] The above scheme involves acquiring an image to be processed, which contains roads in the target scene; extracting the centerline of the image to obtain the initial centerline of the road; using the relevant line segments of each intersection in the initial centerline to determine the target intersections in the road that meet the intersection merging conditions; and restoring the target intersections to obtain the final centerline of the road. By restoring the target intersections, the original shape of the road intersections can be effectively restored, making the extracted centerline of the road at the intersections more consistent with the original shape of the intersections, thereby improving the efficiency and accuracy of road centerline extraction.
[0084] In some embodiments, before step S13, any of the processing steps, such as merging the multiple segments and intersections of the obtained initial centerline, can be performed before steps S13 to S14 are executed. For a detailed implementation of any of the processing steps, such as merging the multiple segments and intersections of the obtained initial centerline, please refer to the following embodiments.
[0085] Please see Figure 9 , Figure 9 This is a flowchart illustrating a second embodiment of the method for extracting the road centerline according to this application. The method may include the following steps:
[0086] S21: Obtain multiple segments of the initial centerline.
[0087] In some embodiments, before step S13 described above, step S21 of this embodiment can be performed to obtain multiple segmented lines of the initial centerline.
[0088] In some implementations, the pixel type of each pixel on the initial centerline can be determined. The pixel type is determined by the number of pixels in a preset neighborhood of each pixel on the initial centerline. The preset neighborhood can be the eight-neighborhood of a pixel, and the preset pixels can be pixels with a pixel value of 1. For example, if the initial centerline is a binary image, pixels located on the centerline can be represented by 1, and pixels not on the centerline can be represented by 0. The number of pixels with a pixel value of 1 in the eight-neighborhood of each pixel can then be counted. The pixel type can be determined based on the count of pixels with a pixel value of 1 in the eight-neighborhood of each pixel.
[0089] In some implementations, the number of pixels of a preset neighboring pixel can be obtained using the following formula:
[0090]
[0091] In the above formula, neighbor(i,j) represents the number of pixels of the center line within the eight-neighbor area of the pixel at coordinate (i,j), A represents the binary image of the initial center line, and x and y are used to limit the eight-neighbor area of the pixel (i,j).
[0092] The pixel type includes at least one of endpoint, connection point, and intersection point. The number of pixels is a first quantity; if the first quantity is 1, the pixel is an endpoint. The number of pixels is a second quantity; if the second quantity is 2, the pixel is a connection point. The number of pixels is a third quantity; if the third quantity is greater than 2, the pixel is an intersection point. This determines the pixel type of each pixel on the initial centerline. The pixel type can be determined based on the number of pixels using the following formula:
[0093]
[0094] Where Point(i,j) represents the pixel type of pixel (i,j), and neighbor(i,j) represents the number of pixels of the pixel at coordinate (i,j) within the center line of its eight neighborhood.
[0095] Then, using the pixel type of each pixel, the initial center line is segmented to obtain multiple segmented line segments. Specifically, line segments are diffused from endpoints or intersections to diffusion points, which are adjacent points of the initial point, such as pixels within an eight-neighborhood. If a diffusion point is a connection point, line segment diffusion continues to other diffusion points; if a diffusion point is an endpoint or intersection, line segment diffusion stops, resulting in multiple segmented line segments.
[0096] The above scheme divides the initial center line into segments by utilizing the pixel type of each pixel, resulting in multiple segments of the initial center line. The center line can be divided into segments based on endpoints or intersections to obtain multiple segments.
[0097] In some implementations, please refer to Figures 10 to 11 It can perform deburring on multiple segmented line segments. The length of the vectorized line segments (i.e., segmented line segments) after segmentation is judged. It is determined whether the length of the segmented line segment is less than the length threshold. If the length of the segmented line segment is less than the length threshold, the segmented line segment is deleted in response to the length of the segment being less than the length threshold, thereby reducing the burrs generated during the center line generation process.
[0098] In some implementations, the initial centerline is segmented using the pixel type of each pixel. After obtaining multiple segments of the initial centerline, dealiasing can be performed on these segments, such as using the Douglas-Peucker Algorithm (also known as the Lamer-Douglas-Peucker Algorithm, Iterative Fitting Algorithm, Split and Merge Algorithm, etc.). The Douglas-Peucker Algorithm is a polyline compression algorithm that can transform curves into polylines, thereby reducing the amount of data. The basic idea of this algorithm is to find some key points on the curve and use these key points to approximate the original curve.
[0099] Specifically, the starting and ending points (e.g., A and B) of each segmented line segment (such as the curve segmented by intersections or endpoints mentioned above) can be obtained and connected to form the connecting line AB. Additionally, the maximum distance Dmax from pixel C of each segmented line segment to the connecting line AB can be obtained.
[0100] If the maximum distance Dmax is less than the preset difference D, which means that all the pixels of the curve or segment can be represented or replaced by the connecting line AB, then in response to the maximum distance Dmax being less than the preset difference D, the other pixels of the segment except for the first and last points (A, B) are removed, thereby reducing the amount of data of the segment and achieving a better compression effect.
[0101] If the maximum distance Dmax is not less than the preset difference D, then in response to the maximum distance Dmax being not less than the preset difference D, the pixel point C corresponding to the maximum distance Dmax is taken as the dividing point, and the segmented line segment is divided according to the dividing point C to obtain two new segmented line segments (AC and CB). Then, the steps of obtaining the connecting line of the first and last points of each segmented line segment and subsequent steps are repeated for these two segmented line segments (AC and CB) until all curves, i.e. segmented line segments, can be replaced by straight line segments.
[0102] As an example, please refer to Figures 12 to 13 By employing the above methods, the amount of data processed can be reduced, and vector merging of segmented line segments can reduce the jaggedness of the initial centerline. Furthermore, it effectively reduces the size of vector files, improves modeling efficiency, enhances the realism of the centerline, and facilitates the selection of adjacent and extended line segments at intersections in subsequent road intersection reconstruction.
[0103] In some embodiments, before step S13 described above, steps S22 to S23 may be performed to merge the intersection points.
[0104] S22: Using multiple segmented line segments, determine the endpoint distance of at least one set of intersections, where the endpoint distance is the distance between the intersection points of each set of intersections.
[0105] After obtaining the segmented line, any two different intersections can be grouped together, such as two intersections that are close in location. The distance between the intersection points of each group of intersections is then calculated to obtain the endpoint distance.
[0106] The method determines whether the endpoint distance meets a distance condition, which includes the endpoint distance being less than a preset distance threshold. The preset distance threshold can be determined based on the specific application scenario, such as an empirical value or a training value, and this application does not impose any restrictions on it.
[0107] If the endpoint distance meets the distance condition, then proceed to step S23 below.
[0108] S23: In response to the endpoint distance satisfying the distance condition, merge the intersections of each group of intersections to obtain merged intersections.
[0109] If the distance between the endpoints meets the distance condition, it means that two intersections in a set of intersections can divide an intersection into two intersections. Therefore, the intersections of each set of intersections are merged to obtain a merged intersection, which can be used to replace the intersections of that set of intersections.
[0110] In some implementations, preset statistical values, such as average values, of the intersection points of each group of intersections can be used as the merged intersections. This process can be expressed by the following formula:
[0111]
[0112] Among them, merge point(i,j) This indicates a merged intersection, where point(i) represents intersection i, point(j) represents intersection j, and len(point(i), point(j)) represents the endpoint distance between intersection i and intersection j. k This indicates the preset distance threshold.
[0113] Please refer to the above plan. Figures 14 to 15 By using multiple segmented line segments, the endpoint distance of at least one set of intersections is determined. The endpoint distance is the distance between the intersection points of each set of intersections. In response to the endpoint distance satisfying the distance condition, the intersection points of each set of intersections are merged to obtain merged intersections, which can effectively reduce the phenomenon of one intersection becoming two intersections.
[0114] In some embodiments, different segmented line segments can also be merged using the above method. For example, the segment distance between at least one group of segmented line segments can be obtained, where the segment distance is the distance between the endpoints of each group of segmented line segments. Any two different segmented line segments can be considered as one group of segmented line segments, such as two segmented line segments that are close in position, or segmented line segments located at an intersection. The endpoints of the segmented line segments are taken as the segment endpoints, thereby obtaining the distance between the endpoints of each group of segmented line segments, and thus obtaining the segment distance.
[0115] Then, it is determined whether the line segment distance meets the line segment condition, which includes the endpoint line segment being less than a preset line segment threshold. The preset line segment threshold can be determined according to the specific application scenario, such as an empirical value or a training value, etc., and this application does not impose any restrictions on it.
[0116] If the segment distance satisfies the segment condition, it means that the segment endpoints of a group of segmented segments can divide a segment into two segments. Therefore, in response to the segment distance satisfying the segment condition, the segment endpoints of each group of segmented segments are merged to obtain merged endpoints. If the average value of the segment endpoints is used as the merged endpoint, the merged endpoint can be used to replace the segment endpoints of that group of segmented segments, which can effectively reduce the phenomenon of a segmented segment becoming two or more segmented segments.
[0117] The method for extracting the road centerline described in this application can be used in fields such as vehicle navigation, 3D scene modeling, and urban planning. For example, after extracting the binary image of the final road centerline, vectorization is added, and the resulting vectorized image can be directly used for subsequent city-level 3D scene modeling. This application is not limited to this.
[0118] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0119] In relation to the above embodiments, this application also provides a road centerline extraction device, which can be used to implement the road centerline extraction method of any of the above embodiments.
[0120] Please see Figure 16 , Figure 16This is a schematic diagram of an embodiment of the road centerline extraction device of this application. The road centerline extraction device 30 includes: an acquisition module 31, an extraction module 32, an intersection module 33, and a restoration module 34. The acquisition module 31, extraction module 32, intersection module 33, and restoration module 34 are interconnected.
[0121] The acquisition module 31 is used to acquire the image to be processed, wherein the image to be processed contains roads in the target scene.
[0122] The extraction module 32 is used to extract the centerline of the image to be processed, so as to obtain the initial centerline of the road.
[0123] The intersection module 33 is used to determine the target intersection in the road that meets the intersection merging conditions by using the relevant line segments of each intersection in the initial centerline.
[0124] The restoration module 34 is used to restore the target intersection and obtain the final centerline of the road.
[0125] The specific implementation of this embodiment can be referred to the implementation process of the above embodiments, and will not be repeated here.
[0126] Regarding the above embodiments, this application provides a computer device; please refer to [link / reference]. Figure 17 , Figure 17 This is a schematic diagram of the structure of a computer device according to an embodiment of the present application. The computer device 40 includes a memory 41 and a processor 42, wherein the memory 41 and the processor 42 are coupled to each other. The memory 41 stores program data, and the processor 42 is used to execute the program data to implement the steps of any embodiment of the road centerline extraction method described above.
[0127] In this embodiment, processor 42 can also be referred to as a CPU (Central Processing Unit). Processor 42 may be an integrated circuit chip with signal processing capabilities. Processor 42 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The general-purpose processor can be a microprocessor, or processor 42 can be any conventional processor.
[0128] The methods described in the above embodiments can be implemented as computer programs; therefore, this application proposes a computer-readable storage medium. Please refer to [link to relevant documentation]. Figure 18 , Figure 18 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 50 stores program data 51 that can be executed by a processor. The program data 51 can be executed by the processor to implement the steps of any embodiment of the road centerline extraction method described above.
[0129] In this embodiment, the computer-readable storage medium 50 can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or a medium that can store program data 51. Alternatively, it can be a server that stores the program data 51. The server can send the stored program data 51 to other devices for execution, or it can run the stored program data 51 itself.
[0130] In some embodiments, the functions or modules of the apparatus provided in the above embodiments of this application can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0131] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0132] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0133] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0134] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0135] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application.
[0136] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, and thus stored in a computer-readable storage medium for execution by a computing device, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Therefore, this application is not limited to any particular hardware and software combination.
[0137] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for extracting the centerline of a road, characterized in that, include: Obtain an image to be processed, wherein the image to be processed contains roads in the target scene; The centerline of the road is extracted from the image to be processed. Using the relevant line segments of each intersection in the initial centerline, the target intersections in the road that meet the intersection merging conditions are determined, including: The adjacent line segments and extended line segments of each intersection of the initial center line are determined, wherein the adjacent line segment is a first line segment connecting to the intersection point of the intersection, and the extended line segment is a second line segment of the intersection along the extension direction of the adjacent line segment. Using the first included angle between the adjacent line segments and the second included angle between the extended line segments, it is determined whether the intersection meets the intersection merging condition; In response to the fulfillment of the intersection merging condition, the intersection is determined to be the target intersection; The target intersection is restored to obtain the final centerline of the road.
2. The method according to claim 1, characterized in that, Before determining whether the intersection meets the intersection merging condition using the first included angle between the adjacent line segments and the second included angle between the extended line segments, the process includes: Two adjacent points are selected on at least two adjacent line segments at the intersection; and two extension points are selected on at least two extended line segments at the intersection; wherein one of the two extension points is the same as one of the two adjacent points. The first included angle is obtained using the two adjacent points; and the second included angle is obtained using the two extended points.
3. The method according to claim 2, characterized in that, One of the two adjacent points is the intersection point of the intersection, and one of the two extended points is the same as the adjacent point of the two adjacent points that is not the intersection point; And / or, the intersection merging condition includes: the first included angle is greater than a first angle threshold, and the second included angle is less than a second angle threshold.
4. The method according to claim 1, characterized in that, Two adjacent line segments include a first adjacent line segment and a second adjacent line segment; the restoration of the target intersection to obtain the final centerline of the road includes: The first length ratio between the first adjacent line segment and the bus segment, and the second length ratio between the second adjacent line segment and the bus segment are obtained respectively, wherein the bus segment is the total length of the two adjacent line segments; By using the first product of the first length ratio and the first preset point of the first adjacent line segment, and the second product of the second length ratio and the second preset point of the second adjacent line segment, the target restoration point of the intersection is obtained, thereby obtaining the final centerline of the road; The target restoration point is used to replace the neighboring point that is an intersection point among the two neighboring points of the first neighboring line segment and the second neighboring line segment. The first preset point and the second preset point are the neighboring points that are not intersection points among the two neighboring points.
5. The method according to claim 1, characterized in that, Before determining the target intersection in the road that meets the intersection merging conditions using the relevant line segments of each intersection in the initial centerline, the process includes: Obtain multiple segmented lines of the initial centerline; and, Using the multiple segmented line segments, determine the endpoint distance of at least one set of intersections, where the endpoint distance is the distance between the intersection points of each set of intersections; In response to the endpoint distance satisfying the distance condition, the intersection points of each group of intersections are merged to obtain merged intersections.
6. The method according to claim 5, characterized in that, The process of obtaining multiple segmented line segments of the initial centerline includes: Determine the pixel type of each pixel of the initial center line; wherein the pixel type is determined by the number of pixels of each pixel of the initial center line in a preset neighborhood; Using the pixel type of each pixel, the initial center line is segmented to obtain multiple segmented line segments of the initial center line.
7. The method according to claim 6, characterized in that, The pixel type includes at least one of endpoint, connection point, and intersection point. If the number of pixels is a first number, the pixel is an endpoint; if the number of pixels is a second number, the pixel is a connection point; if the number of pixels is a third number, the pixel is an intersection point. The step of segmenting the initial center line using the pixel type of each pixel to obtain multiple segmented line segments of the initial center line includes: Starting from the endpoint or intersection point, the line segment spreads towards the diffusion point. If the diffusion point is a connection point, the line segment spread continues to other diffusion points. If the diffusion point is an endpoint or intersection point, the line segment spread stops to other diffusion points, so as to obtain multiple segmented line segments. And / or, after segmenting the initial center line using the pixel type of each pixel to obtain multiple segmented lines of the initial center line, the process includes: Obtain the connecting line between the first and last points of each segmented line segment; and obtain the maximum distance from the pixel point of each segmented line segment to the connecting line. In response to the maximum distance being less than a preset difference, all pixels of the segmented line segment except for the first and last points are removed; or, in response to the maximum distance being not less than the preset difference, the pixel corresponding to the maximum distance is used as the dividing point, and the segmented line segment is divided according to the dividing point to obtain two new segmented line segments, and the steps of obtaining the connecting line of the first and last points of each segmented line segment and subsequent steps are re-executed.
8. A computer device, characterized in that, The method includes a memory and a processor coupled to each other, the memory storing program data and the processor executing the program data to implement the steps of the method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The system stores program data that can be executed by a processor, the program data being used to implement the steps of the method according to any one of claims 1 to 7.