Search

CN-115713743-B - Line detection method and device, chip, device and storage medium

CN115713743BCN 115713743 BCN115713743 BCN 115713743BCN-115713743-B

Abstract

The application provides a line detection method, a device, a chip, equipment and a storage medium, wherein the method comprises the steps of determining that a step record exists in a previous-stage adjacent pixel which is different from a current pixel, determining that the current pixel and the previous-stage adjacent pixel with the step record are edge pixels, wherein the step record at least comprises starting point coordinates, first direction marks and second direction marks of corresponding detected lines, the first direction marks represent the line types of the lines as the first types, the second direction marks represent the current detection directions of the lines, determining target pixels of the lines from the current pixels and the next-stage adjacent pixels with the step record according to the position relation between the current pixels and the previous-stage adjacent pixels, determining that the target pixels are edge pixels, and outputting at least the starting point coordinates and the end point coordinates of the lines based on the determination that the target pixels are the end points of the lines, so that more accurate line detection results can be obtained.

Inventors

  • XIE YONG

Assignees

  • 哲库科技(上海)有限公司

Dates

Publication Date
20260505
Application Date
20221123

Claims (20)

  1. 1. A method of line detection, the method comprising: Determining a target pixel to be added with the line from the current pixel and the next line pixel of the current pixel according to the step record of the previous-stage adjacent pixel of a different line from the current pixel and the position relation between the previous-stage adjacent pixel with the step record and the current pixel, wherein the target pixel is an edge pixel, the current pixel and the previous-stage adjacent pixel with the step record are edge pixels, the step record at least comprises a starting point coordinate of the corresponding detected line, a first direction mark and a second direction mark, the first direction mark represents the line type of the line as a first type, the first type is a vertical line, and the second direction mark is used for representing the current detection direction of the line; Outputting at least a start point coordinate and an end point coordinate of the line based on determining that the target pixel is the end point of the line; And determining a target pixel of the line from the current pixel and a next line of pixels of the current pixel according to the step record and the position relation between the previous adjacent pixel with the step record and the current pixel, wherein the method comprises the following steps: Determining candidate pixels from the pixels in the next row of the current pixels according to the position relation, the first direction marks and the second direction marks in the step record, wherein the corresponding candidate pixels are different from the second direction marks and/or the position relation; And determining the target pixel according to the edge characteristic data of the candidate pixel, wherein the edge characteristic data comprises a numerical value indicating whether the candidate pixel is an edge pixel or not.
  2. 2. The method of claim 1, wherein the step of determining the position of the substrate comprises, Determining a candidate pixel from the next row of pixels of the current pixel according to the first direction mark and the second direction mark when the position relation is that the previous-stage adjacent pixel with the step record is right above the current pixel; And determining a pixel as the target pixel from at least one candidate pixel which is an edge pixel under the condition that the at least one candidate pixel is the edge pixel.
  3. 3. The method according to claim 2, wherein the method further comprises: determining whether a horizontal right neighboring pixel of the current pixel is an edge pixel if each of the candidate pixels is a non-edge pixel; Based on the fact that the horizontal right adjacent pixel of the current pixel is determined to be an edge pixel, taking the previous-stage adjacent pixel with the step record as an end point of the line, and outputting at least a start point coordinate and an end point coordinate of the line; The current pixel is taken as the target pixel and as an end point of the line based on determining that a horizontal right neighboring pixel of the current pixel is a non-edge pixel.
  4. 4. The method of claim 1, wherein the step of determining the position of the substrate comprises, Determining a candidate pixel from a next row of pixels of the current pixel according to the first direction mark and the second direction mark in the case that the positional relationship is that a previous-stage adjacent pixel having the step record is above and to the left of the current pixel; And determining a pixel as the target pixel from at least one candidate pixel which is an edge pixel under the condition that the at least one candidate pixel is the edge pixel.
  5. 5. The method according to claim 4, wherein the method further comprises: in the case that each candidate pixel is a non-edge pixel, determining whether the current pixel can be a target pixel; Based on determining that the current pixel can be the target pixel, taking the target pixel as an end point of the line; Based on determining that the current pixel is not available as the target pixel, taking a previous-stage adjacent pixel with the step record as an end point of the line, and outputting at least a start point coordinate and an end point coordinate of the line.
  6. 6. The method of claim 1, wherein the step of determining the position of the substrate comprises, Determining a candidate pixel from a next row of pixels of the current pixel according to the first direction mark and the second direction mark based on determining that a horizontal right neighboring pixel of the current pixel is a non-edge pixel in a case that the positional relationship is that a preceding-stage neighboring pixel having the step record is above right of the current pixel; And determining a pixel as the target pixel from at least one candidate pixel which is an edge pixel under the condition that the at least one candidate pixel is the edge pixel.
  7. 7. The method of claim 6, wherein the method further comprises: And based on the fact that any pixel in the next row of pixels of the current pixel and the horizontal right adjacent pixel of the current pixel are edge pixels, taking the previous-stage adjacent pixel with the step record as the end point of the line, and outputting at least the start point coordinate and the end point coordinate of the line.
  8. 8. The method of claim 6, wherein the method further comprises: based on the fact that the horizontal right adjacent pixel of the current pixel is determined to be an edge pixel and the next row of pixels of the current pixel are all non-edge pixels, taking the previous-stage adjacent pixel with the step record as an end point of the line, and outputting at least a start point coordinate and an end point coordinate of the line; Based on determining that a horizontal right adjacent pixel of the current pixel and a next row of pixels of the current pixel are both non-edge pixels, and the current pixel can be used as a target pixel, using the target pixel as an end point of the line; And based on the fact that the horizontal right adjacent pixel of the current pixel and the next line pixel of the current pixel are non-edge pixels, and the current pixel cannot be used as a target pixel, taking the previous-stage adjacent pixel with the step record as the end point of the line, and outputting at least the starting point coordinate and the end point coordinate of the line.
  9. 9. The method according to any one of claims 1 to 8, further comprising: generating a step record of the target pixel based on determining that the target pixel is not available as an end point of the line; and determining the next target pixel to be added to the line until the end point of the line is determined.
  10. 10. The method according to any one of claims 1 to 8, further comprising: and acquiring edge characteristic data of a first window size, wherein the edge characteristic data comprises a numerical value indicating whether the current pixel and the adjacent pixel of the current pixel are edge pixels or not, and the adjacent pixel of the current pixel comprises a front-stage adjacent pixel and a rear-stage adjacent pixel.
  11. 11. The method according to any one of claim 1 to 8, wherein, And in the case that the number of the previous-stage adjacent pixels with the step record is greater than 1, determining the target pixels to be added with the corresponding lines in parallel for different previous-stage adjacent pixels with the step record.
  12. 12. A method of line detection, the method comprising: Determining whether the current pixel is increased to be a target pixel of the line according to a step record of a front-level adjacent pixel of a different line from the current pixel and the position relation between the front-level adjacent pixel with the step record and the current pixel when the horizontal left-side adjacent pixel and/or the horizontal right-side adjacent pixel of the current pixel are/is a non-edge pixel, wherein the current pixel and the front-level adjacent pixel with the step record are/is edge pixels, the step record at least comprises a starting point coordinate of a corresponding detected line, a first direction mark and a second direction mark, the first direction mark represents the line type of the line as a second type, the second type is a transverse line, and the second direction mark represents the current detection direction of the line; Based on determining that the current pixel is increased to the target pixel and a line termination condition is met, taking the current pixel as an end point of the line, and outputting a start point coordinate and an end point coordinate of the line.
  13. 13. The method according to claim 12, wherein the method further comprises: Searching a second endpoint pixel in the horizontal direction from the first endpoint pixel according to the horizontal direction pointed by the current detection direction when the line termination condition is not met and the target pixel is the first endpoint pixel of the line, wherein the pixels on the horizontal line, in which the first endpoint pixel and the second endpoint pixel are connected, are all edge pixels; and under the condition that the previous-stage adjacent pixels of a row different from the second endpoint pixel have step records, generating step records of the current pixel according to the step records of the previous-stage adjacent pixels of the second endpoint pixel, and generating step records of the second endpoint pixel according to the step records of the previous-stage adjacent pixels of the current pixel.
  14. 14. The method of claim 13, wherein the method further comprises: Generating a step record of the second endpoint pixel from the step record of the preceding neighboring pixel of the current pixel in the case that the preceding neighboring pixel of a different line from the second endpoint pixel does not have the step record, and And under the condition that the front-stage adjacent pixels in a row different from the second endpoint pixels do not have step records and the rear-stage adjacent pixels in a row different from the current pixel are edge pixels, taking the second endpoint pixels as starting points of new lines to generate step records of the current pixel for recording information of the new lines, wherein the rear-stage adjacent pixels of the edge pixels and the front-stage adjacent pixels of the current pixel with the step records are in the same column.
  15. 15. The method according to claim 12, wherein the method further comprises: Under the condition that the previous adjacent pixels of different rows with the current pixel do not have step records, taking the current pixel as a first end pixel of the row, and searching a second end pixel of the horizontal direction from the first end pixel according to the horizontal direction pointed by the line detection direction, wherein the pixels on the horizontal line connected with the first end pixel and the second end pixel are all edge pixels; generating a step record of the current pixel according to the step record of the preceding adjacent pixel of the different line of the second endpoint pixel under the condition that the preceding adjacent pixel of the different line of the current pixel does not have the step record, the preceding adjacent pixel of the different line of the second endpoint pixel has the step record, and the following adjacent pixel of the different line of the second endpoint pixel is an edge pixel; Wherein the subsequent neighboring pixel that is an edge pixel is in the same column as the previous neighboring pixel of the second endpoint pixel having the step record.
  16. 16. The method of claim 15, wherein the method further comprises: generating a step record of the current pixel according to the step record of the preceding-stage adjacent pixel in a different row from the second endpoint pixel when the preceding-stage adjacent pixel in a different row from the first endpoint pixel does not have the step record, the preceding-stage adjacent pixel in a different row from the second endpoint pixel has the step record, and the following-stage adjacent pixel in a different row from the second endpoint pixel is a non-edge pixel; wherein the subsequent stage neighboring pixels that are non-edge pixels are in the same column as the previous stage neighboring pixels of the second endpoint pixels having the step record.
  17. 17. The method of claim 15, wherein the method further comprises: And under the condition that the previous-stage adjacent pixels of the different rows with the first endpoint pixels do not have step records and the previous-stage adjacent pixels of the different rows with the second endpoint pixels do not have step records, taking the second endpoint pixels as starting points of new lines, and generating step records of the current pixels to record information of the new lines.
  18. 18. The method of claim 15, wherein the method further comprises: When the previous-stage adjacent pixels of the different rows from the first endpoint pixels do not have step records, the previous-stage adjacent pixels of the different rows from the second endpoint pixels do not have step records, and the next-stage adjacent pixels of the different rows from the second endpoint pixels are edge pixels, the current pixels are used as starting points of new lines, and step records of the second endpoint pixels are generated and used for recording information of the new lines; wherein an included angle between a direction from the second endpoint pixel to the next-stage adjacent pixel which is an edge pixel and a direction from the current pixel to the second endpoint pixel is smaller than 90 degrees.
  19. 19. The method of claim 12, wherein the line is preferentially updated in a horizontal direction until it cannot be updated.
  20. 20. The method of claim 12, wherein the step of determining the position of the probe is performed, And under the condition that the horizontal left adjacent pixel and the horizontal right adjacent pixel of the current pixel are non-edge pixels, based on the fact that the previous-stage adjacent pixel with the step record of the current pixel is determined to be located in the vertical direction of the current pixel, taking the previous-stage adjacent pixel with the step record as the end point of the line, and outputting the start point coordinate and the end point coordinate of the line.

Description

Line detection method and device, chip, device and storage medium Technical Field The present application relates to image processing technology, and relates to, but is not limited to, line detection methods and apparatus, chips, devices, and storage media. Background The line feature detection algorithm is widely applied in the image field, and the detected line features (such as line segments) are used as a bottom layer operator of a subsequent algorithm, so that the line feature detection algorithm has certain application potential in multiple fields. For example, line features are used for facial anti-distortion, line feature tracking matching, or three-dimensional (Three Dimensional, 3D) feature reconstruction, etc. The line feature has stronger local invariance and scale robustness properties relative to the point feature, and is taken as a very important algorithm direction in the fields of unmanned laser and visual navigation (navigation), urban mapping (mapping), augmented Reality (Augmented Reality, AR)/Virtual Reality (VR) algorithms and Computer Vision (CV) algorithms in recent years. Among other things, higher precision line features are beneficial for improving the performance of the application. Disclosure of Invention In view of this, the line detection method, the device, the chip, the device and the storage medium provided by the application can obtain more accurate line detection results, thereby being beneficial to improving the performance of application scenes based on line characteristics. According to a first aspect, the embodiment of the application provides a line detection method, which comprises the steps of determining a target pixel to be added with a line from a current pixel and a next line pixel of the current pixel according to a step record of a previous-level adjacent pixel of a line different from the current pixel and a position relation between the previous-level adjacent pixel with the step record and the current pixel, wherein the target pixel is an edge pixel, and outputting at least a starting point coordinate and an end point coordinate of the line based on the determination that the target pixel is an end point of the line, wherein the current pixel and the previous-level adjacent pixel with the step record are edge pixels, the step record at least comprises a starting point coordinate of the line which corresponds to detection, a first direction mark and a second direction mark, the first direction mark represents the line type of the line as a first type, and the second direction mark is used for representing the current detection direction of the line; The method comprises the steps of recording whether a line currently being detected is a first type line or a second type line (namely a first direction mark) through step recording, determining whether to adopt a detection rule of the second type line or a detection rule of the first type line according to the first direction mark when the line is grown (namely line detection), and obtaining a more accurate line detection result, so that the method is beneficial to improving the performance of an application scene based on line characteristics. In a second aspect, the embodiment of the application provides another line detection method, which comprises the steps of determining whether a current pixel is added as a target pixel of a line according to a step record of a previous-stage adjacent pixel of a different line from the current pixel and the position relation between the previous-stage adjacent pixel with the step record and the current pixel when the horizontal left adjacent pixel and/or the horizontal right adjacent pixel of the current pixel are/is non-edge pixels, taking the current pixel as an end point of the line based on the fact that the current pixel is added as the target pixel and a line termination condition is met, and outputting a start point coordinate and an end point coordinate of the line, wherein the current pixel and the previous-stage adjacent pixel with the step record are/is/are edge pixels, the step record at least comprises the start point coordinate, a first direction mark and a second direction mark of the line which correspond to the detected line, the first direction mark represents the line type of the line as a second type, and the second direction mark represents the current detection direction of the line. In a third aspect, an embodiment of the present application provides a method for detecting a line, including a step in the method for detecting a line of a first type based on determining that a first direction mark of a step record of a preceding adjacent pixel of a different line from a current pixel represents the line of the first type, and a step in the method for detecting a line of a second type based on determining that the first direction mark represents the line of the second type, wherein the current pixel and the preceding adjacent pixel having the step rec