Image line segment detection method based on LSD algorithm

By combining the LSD algorithm with coordinate information processing, the problems of missed detection and duplication in line segment detection in the existing technology are solved, more accurate and comprehensive wall line segment detection is achieved, and the integrity and consistency of the detection results are improved.

CN114757898BActive Publication Date: 2025-09-26BEIJING RONGWANG XINDA TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210332742.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-31
Publication Date
2025-09-26
Estimated Expiration
2042-03-31

AI Technical Summary

Technical Problem

The existing technologies based on Hough transform and straight line segment detection methods have problems such as missed detection, repeated detection and poor consistency. In particular, it is difficult to accurately detect wall line segments in 2D scanning images of SLAM.

Method used

An image line segment detection method based on the LSD algorithm is adopted. By performing line segment detection on the initial image, the first line segment and coordinate information are obtained, and combined processing is performed based on the coordinate information, including line segment merging, deduplication and replacement, to improve the comprehensiveness and fit of detection.

Benefits of technology

It effectively reduces the detection repetition rate, improves the accuracy and comprehensiveness of line segment detection, ensures that the detection results are well consistent with the actual wall surface, and reduces data redundancy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114757898B_ABST
    Figure CN114757898B_ABST
Patent Text Reader

Abstract

The present invention relates to an image line segment detection method based on the LSD algorithm. The method obtains an initial image of a detection area, performs line segment detection using the LSD algorithm, obtains a first line segment and first coordinate information therein, then performs a combination process on the line segments in the first line segment, obtains a second line segment based on the combination process result, and performs line segment merging processing on the line segments contained in the first line segment detected by the LSD algorithm, such as merging, deduplication, deletion, and replacement, to obtain a second line segment in the image of the area to be detected. This method avoids data redundancy, improves the comprehensiveness and consistency of line segment detection in the area to be detected, and reduces the detection repetition rate, thereby improving the accuracy of line segment detection in the area to be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition, and in particular to an image line segment detection method based on an LSD algorithm. Background Art

[0002] In cleaning robot scenarios, indoor 2D scans based on laser SLAM (Simultaneous Localization And Mapping, SLAM) are scaled representations of the actual space. Considering that 2D scans are only at the pixel level, there is no annotation information for the line segments where the walls are located. However, in practical applications, the annotation information of the wall is needed to complete other tasks, such as determining whether the machine's 2D scan image has rotated or slipped. Therefore, in the absence of wall annotation information, using line segment detection technology to detect line segments (walls) in the scan image has important theoretical research significance and practical value.

[0003] Existing technologies primarily use the Hough Transform and Line Segment Detector (LSD) methods to detect line segments (walls) in scanned images. However, in practical applications, especially when detecting 2D scanned images for SLAM, these methods suffer from defects such as missed detections, duplicate detections, and poor consistency. Summary of the Invention

[0004] Based on the above problems, an image line segment detection method based on the LSD algorithm is provided, which has comprehensive detection, low repetition rate and high fit.

[0005] An image line segment detection method based on an LSD algorithm, comprising:

[0006] Performing line segment detection on an initial image of the area to be detected using an LSD algorithm to obtain first line segment and first coordinate information in the initial image;

[0007] performing a combination process on the first line segments according to the line segment positions determined by the first coordinate information to obtain a combination process result;

[0008] A second line segment of the area to be detected is obtained according to the combined processing result.

[0009] In one embodiment, before performing line segment detection on the initial image using the LSD algorithm to obtain the first line segment and first coordinate information in the initial image, the method further includes:

[0010] Convert the original image to a grayscale image;

[0011] Performing image enhancement processing on the line segments in the grayscale image to obtain the initial image.

[0012] In one embodiment, before performing combination processing on the first line segments according to the line segment positions determined by the first coordinate information to obtain the combination processing result, the method further includes:

[0013] configuring any two line segments included in the first line segments into corresponding line segment combinations; and,

[0014] Obtain the inclination angle of any line segment in the first line segments in the target coordinate system.

[0015] In one embodiment, the combining process of the first line segments according to the line segment positions determined by the first coordinate information to obtain the combined process result includes:

[0016] Traversing the line segment combinations, if two line segments in any line segment combination are parallel, obtaining the center straight line where the two line segments are located according to the coordinate information corresponding to the two line segments;

[0017] respectively obtaining the projection coordinates of the two line segments on the center line;

[0018] A combination processing result of the two line segments is determined according to the projection coordinates of the two line segments on the central straight line.

[0019] In one embodiment, a method for determining whether two line segments in any line segment combination are parallel includes:

[0020] Determining that the two line segments are in an initially parallel relationship based on an included angle between the two line segments being less than or equal to a preset included angle threshold;

[0021] The distance between the two line segments and the straight line is obtained according to the coordinate information and the straight line angle corresponding to the two line segments. If the distance is less than or equal to a preset distance threshold, it is determined that the two line segments are in a parallel relationship.

[0022] In one embodiment, the method of obtaining the distance between the two line segments and the straight line on which the two line segments are located based on the coordinate information and the straight line angle corresponding to the two line segments includes:

[0023] The inclination angle of the angle bisector of the straight line where the two line segments are located in the target coordinate system is obtained by the following formula :

[0024]

[0025] If any of the following conditions are met: 、 、 , the distance between the two line segments is obtained by the following formula :

[0026]

[0027] If the following conditions are not met: 、 、 , the distance between the two line segments is obtained by the following formula :

[0028]

[0029] in, is the coordinate of the endpoint of one of the two line segments, is the inclination angle of the line segment in the target coordinate system, is the endpoint coordinate of the other line segment in the two line segments, is the inclination angle of the other line segment in the target coordinate system, is the distance between the two line segments, is the preset angle threshold, , , .

[0030] In one embodiment, obtaining the center straight line of the two line segments according to the coordinate information corresponding to the two line segments includes:

[0031] If any of the following conditions are met: 、 、 , the straight line equation of the center line of the two line segments is expressed as:

[0032]

[0033] If the following conditions are not met: 、 、 , the straight line equation of the center line of the two line segments is expressed as:

[0034]

[0035] in, , .

[0036] In one embodiment, respectively obtaining the projection coordinates of the two line segments on the center line includes:

[0037] The endpoints of the two line segments are projected onto the center line respectively to obtain the projection coordinates of the two line segments on the center line.

[0038] In one embodiment, determining the combined processing result of the two line segments according to the projection coordinates of the two line segments on the center line includes:

[0039] According to the projection coordinates, the projection line segments corresponding to the two line segments are obtained respectively;

[0040] If at least a portion of the projected line segments have an intersection, determining that a result of combining the two line segments is to generate a new line segment according to the projected coordinates;

[0041] If there is no intersection between the projected line segments and the minimum distance between any projection coordinates is less than or equal to a preset projection threshold, it is determined that the result of the combined processing of the two line segments is to generate a new line segment according to the projection coordinates.

[0042] In one embodiment, obtaining the second line segment of the area to be detected according to the combined processing result includes:

[0043] If at least one of the two line segments has not been subjected to the step of generating a new line segment, in the first line segment, the two line segments and the corresponding coordinate information are replaced with the new line segment to obtain the second line segment and the second line segment coordinate information.

[0044] The above-mentioned image line segment detection method based on the LSD algorithm obtains the initial image of the detection area, performs line segment detection through the LSD algorithm, obtains the first line segment and first coordinate information therein, and then performs combination processing on the line segments in the first line segment, obtains the second line segment according to the combination processing result, and through line segment merging processing, merges, deduplicates, deletes, replaces, etc. the line segments contained in the first line segment detected by the LSD algorithm to obtain the second line segment in the image of the area to be detected, avoids data redundancy, can improve the comprehensiveness and fit of the line segment detection in the area to be detected, and reduce the detection repetition rate, thereby improving the accuracy of the line segment detection in the area to be detected. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 Flowchart of an image line segment detection method based on the LSD algorithm in one embodiment;

[0046] Figure 2 is a schematic diagram of the angle between the straight lines on which two line segments lie in one embodiment;

[0047] Figure 3 A schematic diagram of the distance between two line segments in one embodiment;

[0048] Figure 4 is a schematic diagram of a center line on which two line segments are located in one embodiment;

[0049] Figure 5 A schematic diagram of the projection points of the endpoints of two line segments onto the center line in one embodiment;

[0050] Figure 6 is a schematic diagram of the positional relationship between projection points in one embodiment;

[0051] Figure 7 is a schematic diagram of the minimum endpoint distance between different projection line segments in one embodiment;

[0052] Figure 8 The original SLAM scan image of Example 1;

[0053] Figure 9 Schematic diagram of the detection result based on Hough transform in Example 1;

[0054] Figure 10 Schematic diagram of the detection results based on the LSD algorithm in Example 1;

[0055] Figure 11 Schematic diagram of the detection results based on the method of the present invention in Example 1;

[0056] Figure 12 This is the original SLAM scan image of Example 2;

[0057] Figure 13 Schematic diagram of the detection result based on Hough transform in Example 2;

[0058] Figure 14 Schematic diagram of the detection results based on the LSD algorithm in Example 2;

[0059] Figure 15 Schematic diagram of the detection results based on the method of the present invention in Example 2;

[0060] Figure 16 This is the original SLAM scan image of Example 3;

[0061] Figure 17 Schematic diagram of the detection result based on Hough transform in Example 3;

[0062] Figure 18 Schematic diagram of the detection results based on the LSD algorithm in Example 3;

[0063] Figure 19 Schematic diagram of the detection results based on the method of the present invention in Example 3. DETAILED DESCRIPTION

[0064] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features therein may be combined with each other.

[0065] In the following description, many specific details are set forth to fully understand the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.

[0066] It should be noted that the terms "first" and "second" as used in the embodiments of the present invention are intended solely to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that the terms "first" and "second" may interchangeably represent a specific order or precedence, where permitted. It should be understood that the objects distinguished by "first" and "second" may be interchangeable, where appropriate, such that the embodiments of the present invention described herein may be implemented in an order other than that illustrated or described herein.

[0067] Before describing the method, a brief introduction to the technologies involved in this project is given.

[0068] Simultaneous Localization and Mapping (SLAM) is primarily used to solve the positioning, navigation, and mapping problems faced by mobile robots operating in unknown environments. Laser SLAM typically involves feature extraction, data association, state estimation, state updates, and feature updates, ultimately resulting in a map of the environment.

[0069] The LSD line segment detection algorithm can obtain high-precision straight line segment detection results in a short time. The algorithm first calculates the gradient size and direction of all points in the image, and then regards adjacent points with small gradient direction changes as a connected domain. According to the rectangularity of each domain, it is determined whether it needs to be disconnected according to the rules to form multiple domains with larger rectangularity. Finally, all the generated domains are improved and screened, and the domains that meet the conditions are retained, which are the final line detection results.

[0070] The following describes an image line segment detection method based on the LSD algorithm in some embodiments of the present invention with reference to the accompanying drawings. It should be noted that this method can be used on a terminal or a server. The following description uses the method applied to a server as an example.

[0071] In one embodiment, Figure 1 As shown, a method for detecting image line segments based on the LSD algorithm is disclosed, the method comprising:

[0072] Step S110 , performing line segment detection on the initial image using an LSD algorithm to obtain first line segments and first coordinate information in the initial image.

[0073] The initial image refers to the scanned image of the area to be detected, which can be a scaled image of the actual space of the area to be detected. For example, the area to be detected can be scanned by laser SLAM to obtain a 2D scan image; or it can be a 2D scan image obtained after preprocessing according to data processing requirements. The area to be detected refers to the target area where image line segment detection is required, such as a room. The area to be detected includes the edge areas of walls, door frames, furniture or other obstacles. Accurately identifying the line segments in these edge areas is conducive to accurate path planning and measurement. For the sake of convenience, the following explanation will take the wall as an example.

[0074] Among them, the LSD algorithm can be used to detect line segments in the initial image.

[0075] The first line segment refers to a set of line segments detected in the initial image, which may include multiple line segments. The first coordinate information refers to a set of the first and last coordinates corresponding to each line segment in the initial image.

[0076] In the existing technology, due to the complexity of the actual situation of the area to be detected and the frequent occurrence of overlapping or broken line segment detection, there will be deviations between the positions of each line segment and the actual wall surface, and line segments will be repeated or discontinuous. Therefore, it is necessary to further optimize the first line segment obtained by the LSD algorithm.

[0077] In the specific implementation, the initial image is input into the LSD algorithm module for processing, and the coordinates of the line segments can be obtained. The coordinates of each line segment can be obtained by using the two coordinate points at both ends of the line segment. express.

[0078] Step S120: performing combination processing on the first line segments according to the line segment positions determined by the first coordinate information to obtain a combination processing result.

[0079] The line segment positions may include the positions of the line segments in the target coordinate system, or the relative positions between the line segments. The relative positions between the line segments may include no intersection, partial intersection, inclusion, etc. Based on the line segment positions, the line segments in the first line segment may be combined.

[0080] Combining processes include, but are not limited to, merging, superimposing, and replacing segments. Combining segments can effectively reduce the number of segments passing through the first segment. Line segments that do not meet requirements can also be deleted based on factors such as segment length and overlap with the wall.

[0081] Specifically, the server may determine the positional relationship between the line segments and the combination processing results of the line segments according to the line segment positions of the line segments in the first line segment.

[0082] Step S130: Obtain a second line segment of the area to be detected according to the combined processing result.

[0083] Specifically, the server may combine the combined line segments in the first line segments to obtain a second line segment. Further, the server may mark the second line segment on the initial image, and the second line segment may be used for path planning of the sweeping robot.

[0084] The above-mentioned image line segment detection method based on the LSD algorithm obtains the initial image of the detection area, performs line segment detection through the LSD algorithm, obtains the first line segment and first coordinate information therein, and then performs combination processing on the line segments in the first line segment, obtains the second line segment according to the combination processing result, and through line segment merging processing, merges, deduplicates, deletes, replaces, etc. the line segments contained in the first line segment detected by the LSD algorithm to obtain the second line segment in the image of the area to be detected, avoids data redundancy, improves the comprehensiveness and fit of the line segment detection in the area to be detected, and reduces the detection repetition rate, thereby improving the accuracy of the line segment detection in the area to be detected.

[0085] In one embodiment, before step S110, the method further includes:

[0086] The original image is converted into a grayscale image; and image enhancement processing is performed on line segments in the grayscale image to obtain the processed initial image.

[0087] In this implementation, the server can preprocess the original image, converting it from RGB to grayscale. Using image enhancement techniques, this technology removes background information from the grayscale image while enhancing the saliency of the line segments (walls). This image enhancement is achieved through image binarization, using a thresholding method to separate the background and line segments in the image.

[0088] The above-mentioned implementation scheme improves the clarity of the initial image through image preprocessing, enhances the saliency of the wall, and thus improves the accuracy of LSD algorithm recognition.

[0089] In one embodiment, before the step of combining the first line segments according to the line segment positions determined by the first coordinate information to obtain a combined processing result in step S130, the method further includes:

[0090] Any two line segments included in the first line segments are configured as corresponding line segment combinations; and an inclination angle of any line segment in the first line segments in a target coordinate system is obtained.

[0091] In this embodiment, the positions between the multiple line segments included in the first line segment are the basis for performing line segment combination processing. In order to determine the combination processing method of each line segment, the server can configure any two line segments in the first line segment as a line segment combination to obtain multiple pairing line segment combinations. During the processing, the server will traverse each line segment combination to obtain the combination processing method of each line segment combination. Therefore, this solution is based on the combination processing method of two line segments in a line segment combination traversed by the server. It should be noted that the order of the front and back is not distinguished under the same line segment combination, that is, the combination (line segment 1, line segment 2) is equivalent to the combination (line segment 2, line segment 1).

[0092] The inclination angle of any line segment in the target coordinate system can be obtained based on the coordinate information of the endpoint of the line segment. The inclination angle can be the angle between the line segment and the x-axis of the target coordinate system, and the range is .

[0093] In the above implementation scheme, the line segments in the first line segment are combined into line segment combinations in pairs, and the line segment combinations are traversed to perform line segment combination processing, which can improve the accuracy of processing and avoid duplication or omission.

[0094] In one embodiment, the step of combining the first line segments determined according to the first coordinate information in step S120 to obtain a combined processing result includes:

[0095] Traverse the line segment combinations, and if two line segments in any line segment combination are parallel, obtain the center straight line where the two line segments are located based on the coordinate information corresponding to the two line segments; obtain the projection coordinates of the two line segments on the center straight line respectively; and determine the combination processing result of the two line segments based on the projection coordinates of the two line segments on the center straight line.

[0096] In this implementation manner, the server traverses the line segment combinations in the first line segment to determine the line segment combination processing method for each line segment combination.

[0097] Specifically, the combination processing method is related to the relative positions of the two line segments in the line segment combination. The server determines whether the two line segments are parallel based on the line segment positions and inclinations between them in the target coordinate system. If the two line segments are parallel, the server obtains the center line on which the two line segments lie based on the line segment coordinates and determines the combination processing result for the two line segments based on the projected coordinates of the two line segments on the center line.

[0098] In some embodiments, the parallelism of the line segments can be relatively parallel, and the angle between the two line segments is lower than a preset angle threshold, which can be considered to be a parallel relationship. If the two line segments are not parallel, the server ends the current line segment combination processing and traverses the next set of line segment combinations.

[0099] In some embodiments, the initial image of the area to be detected obtained by the server is a 2D image, and the line segments of the detected image are in the same plane. The distribution of walls is also generally regular, and there is a long distance between parallel walls in a room. Multiple parallel line segments of different walls and multiple parallel line segments of the same wall can be identified by the distance between the parallel line segments. When two line segments in a line segment combination are judged to be parallel, the coordinate information of the two line segments can be combined to determine whether the two line segments correspond to the walls of the same area, so as to determine the combination method of the two line segments. If the distance between the two line segments determined to be parallel is greater than the vertical distance threshold, the server can end the current line segment combination processing and traverse the next set of line segment combinations.

[0100] In some embodiments, the center line can be calculated based on the coordinate information of the two line segments. The center line can be used to project the endpoints of the two line segments to determine the combination processing method of the two line segments. For example, after the two line segments are projected on the center line, they can have no intersection, partial intersection, or a containment relationship. The server can also further judge based on the horizontal distance between the two line segments. If the distance between the two closest projection points on the center line is greater than a preset projection threshold, it means that the horizontal distance between the two line segments is far, and there may be an obstacle or a broken line segment in the middle. It is not appropriate to merge or replace the line segments. The server can then end the current line segment combination processing and traverse the next set of line segment combinations.

[0101] The above-mentioned implementation scheme obtains the combined processing result of two line segments by determining the parallel relationship of any line segment combination and the projection coordinates on the center line, which can quickly identify the line segment combination that needs further analysis and improve processing efficiency.

[0102] In one embodiment, the step of determining whether two line segments in any line segment combination are parallel includes:

[0103] Based on the fact that the straight line angle between the two line segments is less than or equal to a preset angle threshold, the two line segments are determined to be in an initially parallel relationship; based on the coordinate information and straight line angle corresponding to the two straight lines, the distance between the straight lines where the two line segments are located is obtained, and if the distance is less than or equal to the preset distance threshold, the two line segments are determined to be in a parallel relationship.

[0104] In this embodiment, if Figure 2 As shown, two line segments are represented by A and B, and the angle between A and B is It can be calculated by combining the segment equations of the line segments where A and B are located and the inclination angles of A and B in the target coordinate system. Among them, the preset angle threshold can be obtained based on experience or calculation. The threshold can be adjusted according to the actual situation. The smaller the setting, the more nearly the straight lines where the two line segments are located are parallel in reality. Otherwise, the larger the angle between the straight lines where the two line segments are located, the faster the straight lines will intersect. For example, the preset angle threshold can be set to 1 ~10 .

[0105] Specifically, the server can obtain the inclination angle of the angle bisector of the straight line where the two line segments are located in the target coordinate system through the following formula: :

[0106]

[0107] in, is the inclination angle of the line segment A in the target coordinate system, is the inclination angle of the other line segment B in the target coordinate system.

[0108] In some embodiments, as Figure 3 As shown, the server obtains the distance between the two line segments based on their corresponding coordinate information and the angle between the lines. The smaller the preset distance threshold, the smaller the actual distance between the two line segments that are subsequently merged. If the threshold is set too high, two line segments that are far apart may be merged. For example, the preset distance threshold can be set between 1 and 5 cm.

[0109] Specifically, if any of the following conditions are met: 、 、 , the distance between the two line segments is obtained by the following formula :

[0110]

[0111] If the following conditions are not met: 、 、 , the distance between the two line segments is obtained by the following formula :

[0112]

[0113] in, is the coordinate of the endpoint of one of the two line segments, is the inclination angle of the line segment in the target coordinate system, is the endpoint coordinate of the other line segment in the two line segments, is the inclination angle of the other line segment in the target coordinate system, is the distance between the two line segments, is the preset angle threshold, , , .

[0114] In some embodiments, as Figure 4 As shown, the server can obtain the center straight line of the two line segments based on the coordinate information corresponding to the two line segments.

[0115] Specifically, if any of the following conditions are met: 、 、 , the straight line equation of the center line of the two line segments is expressed as:

[0116]

[0117] If the following conditions are not met: 、 、 , the straight line equation of the center line of the two line segments is expressed as:

[0118]

[0119] in, , .

[0120] In some embodiments, as Figure 4 As shown, the step of respectively obtaining the projection coordinates of the two line segments on the center line includes projecting the endpoints of the two line segments onto the center line respectively to obtain the projection coordinates of the two line segments on the center line.

[0121] In some embodiments, as Figure 5 As shown, the server can obtain the projection line segments corresponding to the two line segments on the center line according to the projection coordinates. Specifically, the server can project the endpoints of the two line segments onto the center line to obtain the projection coordinates of the two line segments on the center line, and then obtain the projection line segments. Figure 6 As shown, the server can identify whether two line segments have no intersection, intersection, or inclusion relationship based on the relationship between the projected line segments, and generate a new line segment.

[0122] Figure 6 -(1), line segments A and B do not intersect on the center line, then the server can make further judgments, if Figure 7In the case shown, the distance between the two closest projection points of line segment A and line segment B is less than or equal to the preset projection threshold, indicating that the line segment is broken. The server can splice line segment A, line segment B and the broken area to obtain a new line segment. d If it is greater than the preset projection threshold, it is considered that the possibility of line segment breakage is low, and the server can end the current line segment combination processing and traverse the next set of line segment combinations.

[0123] The preset projection threshold may be 1 to 3 cm.

[0124] Figure 6 -(2), there is a portion of intersection between the projected line segments of line segments A and B. The server can determine that the combined processing result of the two line segments is to generate a new line segment based on the projected coordinates, that is, to splice the two line segments to obtain a new line segment.

[0125] Figure 6 -In (3), the projected line segment of line segment A is included in the projected line segment of line segment B. The server can determine that the combined processing result of the two line segments is to generate a new line segment based on the projection coordinates, that is, line segment B is a new line segment.

[0126] In the above-mentioned implementation scheme, the server obtains the projected line segment between the two line segments based on the angle and coordinate information of the two line segments, and then determines the positional relationships such as line segment breakage, intersection and inclusion, and determines different line segment combination methods respectively, thereby improving the accuracy of line segment recognition and thus improving the accuracy of the line segment combination results.

[0127] In one embodiment, the step of obtaining the second line segment of the area to be detected according to the combined processing result, determined in step S130, includes:

[0128] If at least one of the two line segments has not been subjected to the step of generating a new line segment, in the first line segment, the two line segments and the corresponding coordinate information are replaced with the new line segment to obtain the second line segment and the second line segment coordinate information.

[0129] In this embodiment, the line segments in the first line segment are randomly combined in pairs to form a line segment combination. Therefore, the same line segment may form a line segment combination with multiple line segments. Each line segment combination will be traversed, and each line segment has the possibility of being detected repeatedly. Therefore, after determining the line segments in a line segment combination and generating a new line segment, the server can further confirm that the two line segments included in the line segment combination have not been traversed and executed to the step of generating a new line segment. In this case, it can be considered that there is no repeated detection of these two line segments. If both line segments have already appeared in other line segment combinations that have been traversed and executed to generate new line segments, the server can determine that there is a duplicate of the two line segments, and can terminate the processing of this line segment combination and traverse the next set of line segment combinations.

[0130] In some embodiments, the server may combine the detected line segments of each first line segment into a new line segment combination to obtain a second line segment. In other cases, the server may replace the corresponding line segment combination with each detected new line segment in the first line segment to obtain the second line segment. Various combinations are possible and are not specifically limited here. By replacing the original line segment combination with a new line segment, redundant and duplicate line segments can be eliminated and broken line segments can be spliced ​​together, thereby improving the quality of each line segment in the second line segment and its fit with the actual wall.

[0131] In some embodiments, the server may combine the line segments in the second line segment into a line segment combination, and perform line segment combination processing according to the above steps until the number of line segments finally obtained no longer changes, so that the number of line segments in the area to be detected is minimized, thereby improving the efficiency of subsequent data processing.

[0132] In some implementations, the server can filter the length of new line segments, set a corresponding length threshold, and retain only line segments longer than the length threshold to reduce data redundancy and invalid line segments. For example, the length threshold can be set to 0-5 cm.

[0133] In one embodiment, the server uses the above-mentioned image line segment detection method based on the LSD algorithm for wall detection, and compares it with the traditional LSD algorithm. It is found that the traditional LSD algorithm also has a serious problem. Almost all the left and right sides of the wall are marked, which causes the problem of repeated detection. The image line segment detection method based on the LSD algorithm of the present invention combines the coordinate information to perform line segment combination processing on the basis of LSD detection to obtain the line segments corresponding to the wall, which has the best effect in line segment detection. On the one hand, it inherits the advantages of the LSD algorithm and performs more comprehensive detection of line segments, reducing missed detections. On the other hand, the detected line segments are de-redundant and merged and broken operations are performed, so that the detected line segments have good integrity and continuity, which reduces the problem of repeated line segment detection, makes the detected image purer, and the detected line segments have good fit with the original wall.

[0134] The following are some specific examples:

[0135] In order to compare the detection effects of different methods, Examples 1 to 3 are given below, representing different scenarios from simple to complex. The line segments detected based on Hough transform, LSD algorithm and the method of the present invention are redrawn onto the original image to observe the positional relationship between the detected line segments and the original wall. The values ​​of the various thresholds involved in each embodiment are as follows: Preset angle threshold =8 , the preset distance threshold D=4cm, the preset projection threshold is 2cm, and the preset length threshold is 3cm.

[0136] When analyzing the effectiveness of each method, the following aspects are mainly used for judgment: (1) whether the detected line segment coincides with the actual wall surface in the original image; (2) whether the detected line segment is incomplete; (3) whether the detected line segment is strictly broken.

[0137] In the indoor 2D laser SLAM scans, the walls are continuous and sufficiently long. If the detection performance of each algorithm is significant, the average number of detected line segments per image can be used as a metric to determine detection effectiveness. A method with good line segment detection performance will detect an appropriate number of line segments, whose lengths match the wall length in the image. If a detection method detects an excessive number of line segments, this may be due to duplicate or disjointed line segments.

[0138] Example 1:

[0139] like Figures 8-11 As shown, the detection method of the present invention is most effective in line segment detection. It not only has the advantages of the LSD algorithm, but also has a more comprehensive detection of line segments with almost no missed detections. At the same time, it removes redundancy and closes broken lines on the detected line segments, reducing the problem of repeated line segment detection and making the detected image purer.

[0140] Example 2:

[0141] like Figures 12-15 As shown, the detection method of the present invention has the best detection results, and the detected line segments are more complete and continuous.

[0142] Example 3:

[0143] like Figures 16-19 As shown, the detection method of the present invention has the best recognition effect, the detected line segments have good fit with the original wall surface, and also have better continuity.

[0144] In addition to Examples 1-3 above, a large sample size statistical analysis was performed on multiple sets of 2D laser SLAM scans. Line segment detection was performed on each image using the Hough transform, the LSD algorithm, and the method of the present invention. The average number of line segments contained in each image using different methods was counted. The statistical results are shown in the following table:

[0145] Table 1 Average number of line segment detections under different methods in 2D laser SLAM images

[0146] method Average number of segments Hough transform algorithm 135.64 LSD algorithm 174.35 Method of the present invention 108.68

[0147] As shown in the table above, the method of the present invention detected the fewest line segments and achieved the best experimental results. This is because the method not only removed redundant line segments but also spliced ​​broken line segments. Compared to the LSD algorithm, the method of the present invention detected 37.7% fewer line segments.

[0148] The various technical features of the above-described embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the various technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0149] The above-described embodiments merely illustrate several implementations of the present invention. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the patent for this invention shall be determined by the appended claims.

Claims

1. A method for detecting line segments in an image based on an LSD algorithm, characterized in that: include: Performing line segment detection on an initial image of the area to be detected using an LSD algorithm to obtain first line segment and first coordinate information in the initial image; configuring any two line segments included in the first line segments into corresponding line segment combinations; and, Obtaining an inclination angle of any line segment in the first line segments in a target coordinate system; Performing a combination process on the first line segments based on the line segment positions determined by the first coordinate information to obtain a combination process result, specifically: traversing the line segment combinations, and if two line segments in any line segment combination are parallel, obtaining a center line on which the two line segments are located based on the coordinate information corresponding to the two line segments; obtaining the projection coordinates of the two line segments on the center line; and determining a combination process result of the two line segments based on the projection coordinates of the two line segments on the center line; A second line segment of the area to be detected is obtained according to the combined processing result.

2. The image line segment detection method based on the LSD algorithm according to claim 1, characterized in that: Before performing line segment detection on the initial image using the LSD algorithm to obtain the first line segment and first coordinate information in the initial image, the method further includes: Convert the original image to a grayscale image; Performing image enhancement processing on the line segments in the grayscale image to obtain the initial image.

3. The image line segment detection method based on the LSD algorithm according to claim 1, characterized in that: Methods for determining whether two line segments in any line segment combination are parallel include: Determining that the two line segments are in an initially parallel relationship based on an included angle between the two line segments being less than or equal to a preset included angle threshold; The distance between the two line segments and the straight line is obtained according to the coordinate information and the straight line angle corresponding to the two line segments. If the distance is less than or equal to a preset distance threshold, it is determined that the two line segments are in a parallel relationship.

4. The image line segment detection method based on the LSD algorithm according to claim 3, characterized in that: The method for obtaining the distance between the straight lines on which the two line segments lie based on the coordinate information and the straight line angle corresponding to the two line segments includes: The inclination angle θ of the angle bisector of the straight line where the two line segments are located in the target coordinate system is obtained by the following formula: c : If any of the following conditions is met: |90°-θ1|≤θ0, |90°-θ2|≤θ0, |90°-θ c |≤θ0, the distance D between the two line segments is obtained by the following formula: If the following conditions are not met: |90°-θ2|≤θ0, |90°-θ2|≤θ0, |90°-θ c |≤θ0, the distance D between the two line segments is obtained by the following formula: Wherein, (x1, y1) and (x2, y2) are the endpoint coordinates of one of the two line segments, θ1 is the inclination angle of the one line segment in the target coordinate system, (x3, y3) and (x4, y4) are the endpoint coordinates of the other line segment, θ2 is the inclination angle of the other line segment in the target coordinate system, D is the distance between the two line segments, θ0 is the preset angle threshold, and k1 = tanθ c , 5. The image line segment detection method based on the LSD algorithm according to claim 4, characterized in that: The obtaining, based on the coordinate information corresponding to the two line segments, the center straight line where the two line segments are located, includes: If any of the following conditions is met: |90°-θ1|≤θ0, |90°-θ2|≤θ0, |90°-θ c |≤θ0, the straight line equation of the center line of the two line segments is expressed as: If the following conditions are not met: |90°-θ1|≤θ0, |90°-θ2|≤θ0, |90°-θ c |≤θ0, the straight line equation of the center line of the two line segments is expressed as: y=k2x+b in, 6. The image line segment detection method based on the LSD algorithm according to any one of claims 3 to 5, characterized in that: The step of respectively obtaining the projection coordinates of the two line segments on the center line includes: The endpoints of the two line segments are projected onto the center line respectively to obtain the projection coordinates of the two line segments on the center line.

7. The image line segment detection method based on the LSD algorithm according to any one of claims 3 to 5, characterized in that: Determining the combined processing result of the two line segments according to the projection coordinates of the two line segments on the center line includes: According to the projection coordinates, the projection line segments corresponding to the two line segments are obtained respectively; If at least a portion of the projected line segments have an intersection, determining that a result of combining the two line segments is to generate a new line segment according to the projected coordinates; If there is no intersection between the projected line segments and the minimum distance between any projection coordinates is less than or equal to a preset projection threshold, it is determined that the result of the combined processing of the two line segments is to generate a new line segment according to the projection coordinates.

8. The image line segment detection method based on the LSD algorithm according to claim 7, characterized in that: Obtaining a second line segment of the area to be detected according to the combined processing result includes: If at least one of the two line segments has not been subjected to the step of generating a new line segment, in the first line segment, the two line segments and the corresponding coordinate information are replaced with the new line segment to obtain the second line segment and the second line segment coordinate information.

Citation Information

Patent Citations

  • Visual edge inspection method based on EDLines and LSM

    CN111754422A