Laser line center extraction method based on line laser sensor and chip
By calculating the grayscale abrupt change in laser line and boundary determination threshold within a preset pixel area, identifying the upper and lower boundary pixels of the laser line, and using the grayscale centroid method to calculate the center point, the problem of long time consumption and large error in traditional methods is solved, and fast and accurate laser line center extraction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- AMICRO SEMICONDUCTOR CO LTD
- Filing Date
- 2025-01-24
- Publication Date
- 2026-07-31
AI Technical Summary
Traditional light stripe center extraction algorithms require traversing every pixel in the image, which is time-consuming. Furthermore, fitting the laser line boundary is time-consuming when there are too many pixels in a single column or when there is sensor distortion. Existing technologies may introduce too many invalid pixels to process.
The laser line center extraction method based on a line laser sensor calculates the gray-scale abrupt change of the laser line by traversing each column of pixels within a preset pixel area, searches for the upper and lower boundary pixels of the laser line based on the relationship between the gray-scale abrupt change and a preset boundary judgment threshold, identifies the center point of the laser line within a consecutive preset number of columns, and calculates the center point using the gray-scale centroid method.
It improves the accuracy and speed of laser line center point extraction, reduces pixel traversal time, eliminates multipath and reflection interference, and optimizes laser line boundary extraction effect.
Smart Images

Figure CN122492799A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of laser data processing, and in particular to a method and chip for laser line center extraction based on a line laser sensor. Background Technology
[0002] Traditional light stripe center extraction algorithms require traversing every pixel in the image to obtain the laser line center coordinates, which is very time-consuming. Chinese invention patent application number 202211119924.4 first sets the initial pixel position in a column as the search center. Then, starting from the search center, it searches upwards along the current column for pixels within a search radius, and then downwards along the same column for pixels within a search radius. Based on the difference in brightness values between the upwardly and downwardly searched pixels at the search centers determined in two adjacent search states, and the inter-frame matching relationship formed by the same type of values in the same column of pixels in the current frame image relative to the reference frame image, the convex hull center pixels in the current column are selected to update the convex hull center pixels previously determined in the current column of the current frame image.
[0003] If we only consider the laser line itself, defining a minimum rectangular area within it would only occupy one-fifth or even less of the entire image frame. If we only consider the laser line width, taking an image size of 680*380 as an example, the laser line width is generally less than 30 pixels. Therefore, the effective range of the laser line segment image is 30 / 380, occupying less than 10% of the effective size. It's clear that traversing all pixels is meaningless. Furthermore, the Chinese invention patent with patent application number 202211119924.4, in order to form a convex hull, starts from the center of the convex hull and follows... The current column searches for pixels with decreasing brightness values on both the top and bottom sides, as well as the set of pixels formed by the convex hull center. Moreover, for each column of the current frame image, the robot traverses the search radius starting from a fixed initial pixel position and counts the number of overexposed pixels. Thus, it traverses a fixed image area in the laser line width direction. It may introduce too many pixels according to the processing rule model adapted to bright and dark frame images. In the case of too many pixels in a single column and distortion of the sensor's camera, it will generally fit the boundary of each laser line segment, but fitting is time-consuming. Summary of the Invention
[0004] This application aims to provide a method and chip for laser line center extraction based on a line laser sensor, and the specific technical solution is as follows:
[0005] A laser line center extraction method based on a line laser sensor includes the following steps: Step A: Within the current column of the laser image, starting from the search starting point, traverse each pixel point according to a preset pixel region and calculate the current laser line grayscale change amount. Search for the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and a preset boundary judgment threshold, and then proceed to Step B; wherein, the laser image is a laser line distribution image acquired in real time by a line laser sensor; Step B: Determine whether the laser line center has been extracted within a consecutive preset number of columns in the laser image. If the upper and lower boundary pixels of the laser line are both present, proceed to step C; otherwise, proceed to step D. Step C: Determine if a laser line has been identified from the laser image; and for each column, calculate the center point of the laser line between the upper and lower boundary pixels using the gray-scale centroid method. Step D: Based on the upper and lower boundary pixels of the laser line, set the search starting point in the next column, update the next column to the current column, and then proceed to step A. The neighborhood of both the upper and lower boundary pixels of the laser line extends into the next column.
[0006] This application performs steps A to D to traverse each column of pixels within a preset pixel area to calculate the current grayscale change in the laser line. Based on the relationship between the current grayscale change in the laser line and a preset boundary judgment threshold, it searches for the upper and lower boundary pixels of the laser line. This is achieved by amplifying the changes in grayscale values to search for the upper and lower boundary pixels of the laser line. Compared to existing technologies, it does not rely solely on grayscale values to determine boundaries. Then, when the upper and lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image, a laser line is identified within the laser image. The center point of the laser line is calculated between the upper and lower boundary pixels using the grayscale centroid method, improving the accuracy of laser line center point extraction and filtering out laser lines generated by multiple paths. Therefore, it is not necessary to traverse all pixels in the laser image. Instead, the laser line can be identified by searching for the upper and lower boundary pixels of the laser line within a preset pixel area based on the relationship between the current grayscale change of the laser line and the preset boundary judgment threshold. When the upper and lower boundary pixels of the laser line are found in a preset number of consecutive columns in the laser image, the laser line can be identified, reducing the time consumption and accelerating the extraction of the accurate center point of the laser line in a local pixel area. It also eliminates interference laser lines caused by multipaths or reflections.
[0007] Considering the continuity of the laser line in the image, we choose to search for the upper and lower boundary pixels of the laser line in the next column based on the searched upper and lower boundary pixels, and calculate the center point of the laser line using the gray-scale centroid method. Thus, when searching for the laser line and its center point, we search for the next boundary pixel in its neighborhood based on the boundary pixel, and then calculate the center point of the laser line based on the searched upper and lower boundary pixels. Therefore, it is not necessary to traverse all pixels, which accelerates the extraction of the center points of each column of a continuous laser line.
[0008] Further, in step A, the method of searching for the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold includes: for each pixel traversed, selecting a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel in the current column of the laser image to form a preset pixel region, and calculating the current laser line grayscale change amount once based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel; if the current laser line grayscale change amount calculated twice is greater than the preset boundary judgment threshold, then the currently traversed pixel required to calculate the current laser line grayscale change amount first is set as the upper boundary pixel of the laser line, and the currently traversed pixel required to calculate the current laser line grayscale change amount later is set as the lower boundary pixel of the laser line. Thus, the upper and lower boundary pixels of the laser line distributed in the current column are searched sequentially within the current column, defining the boundary of the laser line within the current column and eliminating laser line interference caused by multipath.
[0009] Furthermore, the pixels currently traversed that are first required to calculate the grayscale change of the current laser line and the pixels currently traversed that are subsequently required to calculate the grayscale change of the current laser line are located at different positions. Each currently traversed pixel corresponds to a first calculated pixel, a second calculated pixel, and a third calculated pixel, forming two different preset pixel regions. This ensures that the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are located in two different preset pixel regions. Within the current column, the area between the upper boundary pixel of the laser line and the lower boundary pixel of the laser line is used to distribute the laser line.
[0010] Further, in step D, the method of setting the search starting point in the next column based on the upper and lower boundary pixels of the laser line includes: if the upper and lower boundary pixels of the laser line are found in the current column, then one pixel in the neighborhood of the upper and lower boundary pixels of the laser line in the next column and one pixel in the neighborhood of the lower boundary pixels of the laser line in the next column are both set as the search starting point in the next column; if no upper or lower boundary pixels of the laser line are found in the current column, then the pixels in the first row of the next column are configured as the search starting point in the next column. This ensures that the next execution of step A starts from the first row of the next column, traversing each pixel according to the preset pixel region and calculating the current laser line grayscale change, instead of re-traversing the laser image from the first row of the first column, thereby accelerating the traversal speed.
[0011] Further, in step A, the method for searching for upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold further includes: when a pixel in the neighborhood of the laser line upper boundary pixel is configured as the first search starting point, in the next column, starting from the first search starting point, for each pixel traversed, a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel are selected in the next column of the laser image to form a preset pixel region, and the current laser line grayscale change amount is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel; when the current laser line grayscale change amount is greater than the preset boundary judgment threshold, the currently traversed pixel is set as the upper boundary pixel of the laser line; thus, an upper boundary pixel of the laser line is searched out, establishing the correspondence between the first search starting point, the preset pixel region, the current laser line grayscale change amount, and the upper boundary pixel of the laser line.
[0012] When a pixel in the neighborhood of the lower boundary pixel of the laser line is configured as the second search starting point, in the next column, starting from the second search starting point, for each pixel traversed, a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel are selected in the next column of the laser image to form a preset pixel region. The current laser line grayscale change is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. When the current laser line grayscale change is greater than a preset boundary determination threshold, the currently traversed pixel is set as the lower boundary pixel of the laser line. The search starting point in the next column includes both the first search starting point and the second search starting point. This process searches for a lower boundary pixel of the laser line, establishing the correspondence between the second search starting point, the preset pixel region, the current laser line grayscale change, and the lower boundary pixel of the laser line.
[0013] Further, the method for constructing the preset pixel region includes: within a column of the laser image, setting a pixel in the preset column direction whose distance from the currently traversed pixel is equal to a preset pixel distance as a first calculated pixel; setting a pixel in the preset column direction whose distance from the currently traversed pixel is equal to a preset pixel distance as a first calculated pixel; setting a pixel in the preset column direction whose distance from the currently traversed pixel is equal to half of the preset pixel distance as a second calculated pixel; and setting a pixel in the opposite direction of the preset column direction whose distance from the currently traversed pixel is equal to half of the preset pixel distance as a third calculated pixel; then, the first calculated pixel and the third calculated pixel constitute two boundary points of the preset pixel region, such that the second calculated pixel and the currently traversed pixel divide the preset pixel region into four equal parts within a column.
[0014] Further, in step A, the method for calculating the current grayscale change amount of the laser line includes: traversing pixels row by row within a column of the laser image; setting a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel from top to bottom in the column of the laser image according to a preset pixel distance; and extracting the grayscale values of the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel, respectively; subtracting the grayscale value of the first calculated pixel from the grayscale value of the currently traversed pixel to obtain a first preset grayscale difference; subtracting the grayscale value of the second calculated pixel from the grayscale value of the third calculated pixel to obtain a second preset grayscale difference; and adding the first preset grayscale difference and the second preset grayscale difference to obtain the current grayscale change amount of the laser line. This achieves the calculation of the current grayscale change amount of the laser line within a preset pixel area according to a preset pixel distance, thus optimizing the extraction effect of the upper and lower boundary pixels of the laser line.
[0015] Further, in step B, the method for determining whether the upper and lower boundary pixels of the laser line have been found in a consecutive preset number of columns in the laser image includes: Step B1, starting from the search starting point, continuously traversing each column of pixels in the laser image and counting the number of columns traversed in the laser image, and counting the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found, and then executing step B2; Step B2, determining whether the number of columns traversed in the laser image is less than a preset number, if yes, executing step B3, otherwise executing step B4; Step B3, determining whether the upper and lower boundary pixels of the laser line have been found in the current column of the laser image, if yes, executing step D, otherwise executing step B6; Step B4, determining the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found. If the quantity is less than a preset number, proceed to step B3; otherwise, proceed to step B5. Step B5: Determine that the upper and lower boundary pixels of the laser line are found within a preset number of consecutive columns in the laser image. Clear the number of columns traversed within the laser image and the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found. Then proceed to step C. Step B6: Configure the first row of pixels in the next column as the search starting point for the next column, update the next column to the current column, clear the number of columns traversed within the laser image, and clear the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found. Then proceed to step A, so that subsequent step B can determine that the upper and lower boundary pixels of the laser line are found within a preset number of consecutive columns in the laser image. This eliminates noise interference in laser line recognition by searching for the upper and lower boundary pixels of the laser line within a preset number of consecutive columns.
[0016] Further, after determining the laser line identified from the laser image by executing step C once, the process is as follows: Step C1: Determine the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column of the laser image, then set the search starting point in the next column within the neighborhood of the upper boundary pixel and the lower boundary pixel of the laser line, and update the next column to the current column, then execute step C2; Step C2: In the current column of the laser image, starting from the search starting point, continuously traverse each column of pixels in the laser image and count the number of columns traversed in the laser image, and count the laser line... The number of columns in the image where the upper and lower boundary pixels of the laser line have been found is counted, and step C3 is executed; Step C3: Determine if the number of columns traversed in the laser image is less than a preset number. If yes, proceed to step C4; otherwise, proceed to step C5; Step C4: Determine if the upper and lower boundary pixels of the laser line have been found in the current column of the laser image. If yes, proceed to step C1; otherwise, proceed to step C7; Step C5: Determine if the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found is less than a preset number. If yes, proceed to step C5; Execute step C4, otherwise execute step C6; Step C6: Determine if a laser line is currently identified from the laser image, clear the number of columns traversed within the laser image to zero, and clear the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found to be zero, then execute step C1; Step C7: Determine if laser line identification fails in the current column, and count the number of columns where laser line identification failed, then execute step C8; Step C8: Determine if the number of columns where laser line identification failed is greater than or equal to a preset number, if yes, execute step C9, otherwise execute step C10; C9. Determine that no upper or lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image, thus determining that a laser line is segmented in the current column. At the same time, clear the number of columns where laser line identification failed, and then proceed to step C10. Step C10: Clear the number of columns traversed in the laser image, clear the number of columns in the laser image where upper and lower boundary pixels of the laser line have been found, update the first row of pixels in the next column as the search starting point, update the next column as the current column, and then proceed to step C2.In summary, whenever it is determined that no laser line exists in the current column and the currently traversed pixel is identified as noise, it is determined that not all laser line upper and lower boundary pixels are found in a consecutive preset number of columns in the laser image, and it is also determined that no laser line upper or lower boundary pixels are found in the current column of the laser image. Therefore, to prove that the laser line is segmented by failing to identify the laser line through a consecutive preset number of columns, the first row of pixels in the next column is configured as the search starting point in the next column, and the next column is updated to the current column. Then, the traversal of each column of the laser image continues until a preset number of steps C4 are executed consecutively and it is determined that no laser line is found in the current column of the laser image. Only by identifying the upper and lower boundary pixels of the laser line can a laser line segmentation be confirmed. After each execution of steps C7 and C9, which determine that laser line recognition in the current column has failed and that laser line segmentation has been confirmed, the number of columns traversed in the laser image is reset to zero, as are the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found. Then, step C2 is executed to start from the search starting point of the next column. A preset number of consecutive columns and the upper and lower boundary pixels of the laser line in each column are counted again to identify the laser line from the laser image. This effectively addresses interference caused by multipath or reflection and improves the accuracy of laser line recognition.
[0017] A chip is disclosed, electrically connected to a line laser sensor or disposed within a line laser sensor; characterized in that the chip is configured to perform the laser line center extraction method to identify laser lines from a laser image and calculate the center points of each column of laser lines. The chip disclosed in this application traverses each column of pixels within a preset pixel area by performing steps A to D to calculate the current grayscale change in the laser line and searches for the upper and lower boundary pixels of the laser line based on the relationship between the current grayscale change in the laser line and a preset boundary judgment threshold, thereby searching for the upper and lower boundary pixels of the laser line by amplifying the change in grayscale values; compared with the prior art, the chip disclosed in this application does not rely solely on grayscale values to determine boundaries.
[0018] The chip disclosed in this application determines that a laser line has been identified in the laser image when it searches for both the upper and lower boundary pixels of the laser line within a consecutive preset number of columns. It then calculates the center point of the laser line between the upper and lower boundary pixels using the gray-scale centroid method, improving the accuracy of laser line center point extraction and filtering out laser lines generated by multiple paths. Therefore, the chip disclosed in this application does not need to traverse all pixels in the laser image. Instead, it searches for the upper and lower boundary pixels of the laser line within a preset pixel area based on the relationship between the current gray-scale change in the laser line and a preset boundary judgment threshold. When the upper and lower boundary pixels of the laser line are found within a consecutive preset number of columns in the laser image, the laser line can be identified. This reduces the time spent processing pixels and enables the chip to accelerate the extraction of accurate laser line center points within local pixel areas of the laser image, while also eliminating interfering laser lines generated by multiple paths or reflections. Attached Figure Description
[0019] Figure 1 This is a schematic flowchart of a laser line center extraction method based on column traversal, as disclosed in an embodiment of this application.
[0020] Figure 2 This is a schematic flowchart of the execution method of step B disclosed in another embodiment of this application.
[0021] Figure 3 This is another embodiment of the present application, which discloses a method for identifying a laser line again or determining that a laser line appears in a segment in the current column after identifying a laser line once in a laser image. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be described in detail below with reference to the accompanying drawings. To further illustrate the embodiments, this application provides accompanying drawings. These drawings are part of the disclosure of this application and are mainly used to illustrate the embodiments, and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these drawings, those skilled in the art should be able to understand other possible implementation methods and the advantages of this application.
[0023] A robot using a line laser sensor for navigation and positioning emits a laser line through a laser emitter inside the line laser sensor, and a camera lens inside the line laser sensor receives the laser line reflected from the surface of an obstacle and generates a laser image in the internal controller. Due to distortion caused by the camera lens, the laser line segment presented in the laser image is not a horizontal line segment, but a curved line segment with width. If we only consider this laser line, the smallest rectangular area defined by the laser line actually only occupies one-fifth or even less of the entire laser image frame. The width of the laser line is generally less than 30 pixels, less than 10% of the laser line length. It can be seen that the width of the laser line does not have a significant impact on the direction of the laser line. Therefore, it is meaningless to traverse all pixels in the laser line, and it actually slows down the efficiency of the robot's navigation and positioning using the line laser sensor.
[0024] Furthermore, each pixel in a laser line segment presented in a laser image has a certain grayscale value. Generally, a threshold is set for darker laser lines to identify distant laser lines, and a threshold is set for brighter laser lines to identify medium- and short-range laser lines. The threshold for darker laser lines is lower than that for brighter laser lines. When a laser line is very far away, it is very dark, meaning its grayscale value is small. Since a laser line segment is continuous, the grayscale values within that segment should be similar. Similarly, when the laser is very close, the grayscale value will be larger. If only the grayscale value of a single pixel is thresholded, it is difficult to capture the large grayscale changes that occur at the boundaries of the laser line, thus failing to accurately capture the boundary positions of the laser line and being susceptible to interference from laser lines generated by multiple paths.
[0025] To accurately and quickly locate the boundaries of laser lines and extract their center points (which are also the center points of a single column of laser stripes), this application discloses a laser line center extraction method based on a line laser sensor. The execution subject of the laser line center extraction method is a device that assembles a line laser sensor, which can be a robot or other intelligent device with positioning and navigation functions. Since the significance of extracting the center point of a laser line is mostly for locating objects in the environment for navigation and obstacle avoidance, the execution subject of the laser line center extraction method is generally set as a robot. The robot is equipped with a line laser sensor to acquire laser images. A controller is installed inside the robot and is electrically connected to the line laser sensor. The controller is configured to execute the laser line center extraction method to traverse the laser image column by column to obtain the center points of the laser lines. Only one laser emitter is installed in the line laser sensor, so at most one center point, at most one upper boundary point, and at most one lower boundary point are selected for each column in the laser image.
[0026] In this application, as Figure 1 As shown, the laser line center extraction method includes:
[0027] Step A: Within the current column of the laser image, starting from the search starting point, traverse each pixel according to the preset pixel region and calculate the current laser line grayscale change amount. Based on the grayscale values of each pixel within the preset pixel region, calculate the current laser line grayscale change amount. Search for the upper and lower boundary pixels of the laser line according to the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold, thereby finding the upper and lower boundary pixels of the laser line within the preset pixel region. Then proceed to Step B. The laser image is a laser line distribution image obtained in real time by a line laser sensor. The current laser line grayscale change amount is used to represent the grayscale value change rate within a preset pixel region in the current column of the laser image. A preset pixel region may span multiple rows but will not cover the entire column. The pixels within the preset pixel region are the pixels required to calculate the current laser line grayscale change amount. The preset pixel region is a local pixel region within a column of the laser image. Searching for the upper and lower boundary pixels of the laser line within the preset pixel region is equivalent to obtaining the optimal solution for the laser line distribution position from the local pixel region. The distance between the pixels used to calculate the laser line grayscale change amount is greater than one pixel. By appropriately increasing the distance between pixels, the laser line part (i.e., the proportion of higher grayscale values in the formula) is highlighted, significantly amplifying the grayscale value change, optimizing the calculation method of the grayscale value change rate, and filtering out laser lines generated by multiple paths and other interference points.
[0028] In step A, when the robot acquires a laser image, it traverses the laser image column by column, and the currently traversed column is designated as the current column. The laser lines that may exist within the current column have at least two grayscale values, distributed between the upper and lower boundary pixels of the laser line. This allows for the effective calculation of the grayscale abrupt change in the current laser line. For each pixel in a column, a row-by-row traversal is performed with the aim of calculating the grayscale abrupt change in the current laser line until the upper and lower boundary pixels of the laser line are found within the column. Within the current column, all pixels between the upper and lower boundary pixels of the laser line will be used in subsequent calculations of the laser line's center point. When the upper and lower boundary pixels of the laser line are found, it is determined that a laser line may exist in the current column, and the boundary of the laser line within the current column is defined. This is only a preliminary result to narrow down the traversal and judgment range. The laser line is only officially confirmed after traversing multiple columns. Simultaneously, a new search starting point is set within the cross-column neighborhood of the upper and lower boundary pixels of the laser line to continue searching for the upper and lower boundary pixels of the laser line in the next column.
[0029] Step B: Determine whether the upper and lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image. If yes, proceed to step C; otherwise, proceed to step D. The conditions for step B include finding both the upper and lower boundary pixels of the laser line in a preset number of columns, and ensuring that these preset number of columns are consecutively arranged in the laser image; the upper boundary pixel of the laser line found in the next or previous column must be the same as the upper boundary pixel found in the current column, and the lower boundary pixel of the laser line found in the next or previous column must be the same as the lower boundary pixel found in the current column. Understandably, with the preset quantity preferably being 3, if the robot finds both the upper and lower boundary pixels of the laser beam in three consecutive columns, it executes step C. If the robot has not yet found both the upper and lower boundary pixels of the laser beam in three consecutive columns, for example, if it has only found both the upper and lower boundary pixels of the laser beam in one or two consecutive columns, it executes step D to continue traversing the next column. However, it may also fail to find both the upper and lower boundary pixels of the laser beam in three consecutive columns, in which case step D also needs to be executed to continue traversing the next column.
[0030] Step C: Determine if a laser line has been identified within the laser image. At this point, a laser line has been truly identified by searching for the upper and lower boundary pixels of the laser line within a predetermined number of consecutive columns in the laser image. The optimal solution for the laser line distribution position is obtained from the local pixel region. For example, if the laser line hits a relatively flat and complete obstacle, step C will result in a continuous laser line within the laser image. For each column, the center point of the laser line is calculated using the gray-scale centroid method between the upper and lower boundary pixels of the laser line. In some implementations, the center point of the laser line is calculated by calling each pixel between the upper and lower boundary pixels of the laser line using the gray-scale centroid method, thus obtaining the center point of the laser line in each column, which is equivalent to the center point of the laser stripes within a column.
[0031] Schematic, the coordinates of the center point of each laser line in the column direction are Y, and the coordinates of the center point of the laser line in the column direction are calculated using the gray-scale centroid method:
[0032]
[0033] The column coordinates of the upper boundary pixel of the laser beam are m, the column coordinates of the lower boundary pixel of the laser beam are n, and the column coordinates of the i-th pixel (where i is the top-to-bottom index within the same column) between the upper and lower boundary pixels of the laser beam are y. i y iAt the upper boundary pixel of the laser line, yi is equal to m; at the lower boundary pixel of the laser line, yi is equal to n; gray i It represents the grayscale value of the i-th pixel between the upper boundary pixel of the laser beam and the lower boundary pixel of the laser beam.
[0034] Step D: Based on the upper and lower boundary pixels of the laser beam, set the search starting point in the next column, update the next column to the current column, and then execute Step A. Specifically, if the upper and lower boundary pixels of the laser beam are found in the current column, set the search starting point in the next column within the neighborhood of the upper and lower boundary pixels, respectively. The neighborhoods of both the upper and lower boundary pixels extend into the next column. If no upper or lower boundary pixels are found in the current column, directly set the search starting point in the next column. Then execute Step A, ensuring that the next execution of Step A will repeat steps A through D from the search starting point in the next column.
[0035] If the robot has not yet found the upper and lower boundary pixels of the laser line in all three consecutive columns (for example, if it has only found them in one or two consecutive columns), step D is required to perform column switching traversal. At this point, the direction of the laser line in one or two consecutive columns has been captured. Specifically, step D sets a search starting point in the next column within the neighborhood of the upper boundary pixel and a search starting point in the next column within the neighborhood of the lower boundary pixel. The reason for using the upper and lower boundary pixels of the laser line found in the current column to predict the upper and lower boundary pixels of the laser line in the next column is because the laser line is continuous. Precisely because the laser line is continuous, when step B determines that only one or two consecutive columns have been found, a search starting point in the next column needs to be set, the next column updated to the current column, and then step A is executed. When a robot uses a line laser sensor for navigation and positioning, when the laser line hits a relatively flat and complete obstacle, a continuous laser line will be collected from the laser image. Therefore, step D can predict the location of the next laser line in the neighborhood of the upper and lower boundaries based on the trend of the laser line that has been found.
[0036] Furthermore, after the robot has identified the laser line from the laser image, it continues to set the search starting point in the next column within the neighborhood of the upper boundary pixel of the laser line and the neighborhood of the lower boundary pixel of the laser line, and updates the next column to the current column, then executes step A; until step B determines that the robot cannot find the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in all three consecutive columns, or find the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column, then step D needs to be executed to continue traversing the next column. Since there are no upper boundary pixel of the laser line and the lower boundary pixel of the laser line as references for the searched laser line positions in the current column, it is not possible to directly set the search starting point in the next column within the neighborhood of the upper boundary pixel of the laser line and the neighborhood of the lower boundary pixel of the laser line. Instead, the first row position of the next column is selected as the search starting point in the next column.
[0037] This application performs steps A to D to traverse each column of pixels within a preset pixel area to calculate the current grayscale change in the laser line. Based on the relationship between the current grayscale change in the laser line and a preset boundary judgment threshold, it searches for the upper and lower boundary pixels of the laser line. This is achieved by amplifying the changes in grayscale values to search for the upper and lower boundary pixels of the laser line. Compared to existing technologies, it does not rely solely on grayscale values to determine boundaries. Then, when the upper and lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image, a laser line is identified within the laser image. The center point of the laser line is calculated between the upper and lower boundary pixels using the grayscale centroid method, improving the accuracy of laser line center point extraction and filtering out laser lines generated by multiple paths. Therefore, it is not necessary to traverse all pixels in the laser image. Instead, the laser line can be identified by searching for the upper and lower boundary pixels of the laser line within a preset pixel area based on the relationship between the current grayscale change of the laser line and the preset boundary judgment threshold. When the upper and lower boundary pixels of the laser line are found in a preset number of consecutive columns in the laser image, the laser line can be identified, reducing the time consumption and accelerating the extraction of the accurate center point of the laser line in a local pixel area. It also eliminates interference laser lines caused by multipaths or reflections.
[0038] Considering the continuity of the laser line in the image, we choose to search for the upper and lower boundary pixels of the laser line in the next column based on the searched upper and lower boundary pixels, and calculate the center point of the laser line using the gray-scale centroid method. Thus, when searching for the laser line and its center point, we search for the next boundary pixel in its neighborhood based on the boundary pixel, and then calculate the center point of the laser line based on the searched upper and lower boundary pixels. Therefore, it is not necessary to traverse all pixels, which accelerates the extraction of the center points of each column of a continuous laser line.
[0039] Generally, if the grayscale value of the currently traversed pixel is greater than a first preset grayscale value threshold and less than a second preset grayscale value threshold, then it is determined that a first candidate laser line exists at the currently traversed pixel; wherein the second preset grayscale value threshold is greater than the first preset grayscale value threshold. If the grayscale value of the currently traversed pixel is greater than the second preset grayscale value threshold, then it is determined that a second candidate laser line exists at the currently traversed pixel. The distance between the obstacle that causes the first candidate laser line to be reflected and the line laser sensor is less than the distance between the obstacle that causes the second candidate laser line to be reflected and the line laser sensor. If the grayscale value of the currently traversed pixel is less than the first preset grayscale value threshold, then it is determined that no laser line exists at the currently traversed pixel. In step A, the preset boundary determination threshold for searching for upper and lower boundary pixels of the laser line is set to be greater than the first preset grayscale value threshold and less than or greater than the second preset grayscale value threshold. Schematic, the first preset grayscale value threshold is used to represent the judgment threshold for darker laser lines, and the first preset grayscale value threshold is equal to the grayscale value 80; the second preset grayscale value threshold is used to represent the judgment threshold for brighter laser lines, and the second preset grayscale value threshold is equal to the grayscale value 200; the preset boundary determination threshold is equal to the grayscale value 150.
[0040] As one embodiment, in step A, the method for searching the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold includes: for each pixel traversed, selecting a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel in the current column of the laser image to form a preset pixel region, wherein the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are all located in the same column, and starting from the currently traversed pixel, according to the requirement of the second-order partial derivative calculation for the function change rate, expanding sequentially from the large coordinate to the small coordinate in the column direction to obtain the first calculated pixel, the second calculated pixel, and the third calculated pixel; and calculating the current laser line grayscale change amount once based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel, wherein there are at least two grayscale values among the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel.
[0041] The robot traverses multiple pixels within the current column of the laser image, sequentially setting up two preset pixel regions to calculate the grayscale change of the current laser line twice. If both calculated grayscale changes exceed a preset boundary threshold, the pixel required for the first calculation is set as the upper boundary pixel of the laser line, and the pixel required for the second calculation is set as the lower boundary pixel. This process sequentially searches for the upper and lower boundary pixels of the laser line within the current column, defining the laser line's boundary within the column and eliminating interference from multipath propagation.
[0042] Specifically, during the process of the robot traversing each pixel in the current column of the laser image row by row, for each pixel traversed, a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel are set in the same column of the laser image, and the gray-scale change amount of the current laser line is calculated once. By traversing multiple pixels, after the first calculation of the gray-scale change amount of the current laser line and the search for a boundary pixel based on the relationship between the gray-scale change amount of the current laser line and a preset boundary judgment threshold, the first searched boundary pixel is recorded as the upper boundary pixel of the laser line. Then, in order to search for the lower boundary pixel of the laser line in the current column, the pixels in the current column are traversed again, and new first calculated pixels, new second calculated pixels, the currently traversed pixel, and new third calculated pixels are set, and the gray-scale change amount of the current laser line is calculated again, until a boundary pixel is searched based on the relationship between the gray-scale change amount of the current laser line and the preset boundary judgment threshold, and the second searched boundary pixel is recorded as the lower boundary pixel of the laser line.
[0043] In the above embodiment, the pixels currently traversed that are required to calculate the grayscale change of the current laser line first and the pixels currently traversed that are required to calculate the grayscale change of the current laser line later are located at different positions. Each currently traversed pixel corresponds to a first calculated pixel, a second calculated pixel, and a third calculated pixel, forming two different preset pixel regions. The coordinates in the column direction are different in the different preset pixel regions, while the coordinates in the row direction are the same in the different preset pixel regions, so that the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are located in two different preset pixel regions. In the current column, the area between the upper boundary pixel of the laser line and the lower boundary pixel of the laser line is used to distribute the laser line.
[0044] Since only one laser emitter is used to emit a laser line towards the obstacle and the laser line acquired in the laser image has width, at most one center point and two boundary points can be selected for each laser line in a column. This expands two preset pixel regions to search for the upper and lower boundary pixels of the laser line, respectively. Since the laser line is continuously distributed along its length, the positions of the upper and lower boundary pixels of the previous column are combined to predict the laser line of the next column. Then, a first calculated pixel, a second calculated pixel, and a third calculated pixel are expanded column by column to form the preset pixel region of the next column.
[0045] In addition, in step A, the method of searching for the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold further includes: if the current laser line grayscale change amount is calculated to be greater than the preset boundary judgment threshold only once, then the currently traversed pixel is set as the upper boundary pixel of the laser line, and the boundary point of the laser image pointed to by the traversal direction in the current column is set as the lower boundary pixel of the laser line. The laser line distributed between the upper and lower boundary pixels of the laser line in the current column may be a large spot, which is sufficient to configure the image boundary as the laser line boundary.
[0046] As one embodiment, in step D, the method for setting the search starting point in the next column based on the upper boundary pixel of the laser line and the lower boundary pixel of the laser line includes:
[0047] After executing step B, when jumping to execute step D, the robot searches for the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column.
[0048] If the robot finds the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column, it sets one pixel in the neighborhood of the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the next column as the search starting point in the next column. This results in two search starting points in the next column, so that the next execution of step A starts from one pixel in the neighborhood of the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the next column, respectively. At the same time, it traverses each pixel according to the preset pixel area and calculates the grayscale change of the current laser line. Then, by executing steps B to D, the upper boundary pixel of the laser line and the lower boundary pixel of the laser line can be found in the next column.
[0049] Specifically, a pixel in the neighborhood of the upper boundary pixel of the laser line in the next column is a pixel in the next column that is adjacent to the upper boundary pixel of the laser line searched in the current column, including a pixel in the four-neighbor or eight-neighbor neighborhood, but not any pixel in the next column, even though the current column and the next column are two adjacent columns in the laser image; similarly, a pixel in the neighborhood of the lower boundary pixel of the laser line in the next column is a pixel in the next column that is adjacent to the lower boundary pixel of the laser line searched in the current column, mainly selecting a pixel in the next column that is within the eight-neighbor neighborhood of the lower boundary pixel of the laser line searched in the current column.
[0050] If no upper or lower boundary pixel of the laser line is found in the current column, there may be noise or interference from multipath laser lines. The first row of pixels in the next column is configured as the search starting point in the next column. The already found upper and lower boundary pixels of the laser line are not used. The next step A is executed starting from the first row of the next column, traversing each pixel according to the preset pixel area and calculating the grayscale change of the current laser line, instead of traversing the laser image again starting from the first row of the first column, so as to speed up the traversal.
[0051] Based on the above embodiments, in step A, the method for searching the upper boundary pixel of the laser line and the lower boundary pixel of the laser line according to the relationship between the current grayscale change amount of the laser line and the preset boundary determination threshold further includes:
[0052] Step D sets the search starting point in the next column based on the upper and lower boundary pixels of the laser beam. Specifically, if the upper and lower boundary pixels of the laser beam are found in the current column, two search starting points are obtained in the next column, and the next column is updated to match the current column. Then, step A is executed. The search starting point in the next column includes a first search starting point and a second search starting point.
[0053] When re-executing step A, if a pixel in the neighborhood of the laser line boundary pixel is configured as the first search starting point, then in the next column, starting from the first search starting point, for each pixel traversed, the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are selected in the next column of the laser image to form a preset pixel region. The current laser line grayscale change amount is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. When the current laser line grayscale change amount is greater than the preset boundary judgment threshold, the currently traversed pixel is set as the laser line boundary pixel. Here, the current laser line grayscale change amount is calculated only once within the corresponding preset pixel region to search for a laser line boundary pixel, thus establishing the correspondence between the first search starting point, the preset pixel region, the current laser line grayscale change amount, and the laser line boundary pixel.
[0054] When re-executing step A, if a pixel in the neighborhood of the lower boundary pixel of the laser line is configured as the second search starting point, then in the next column, starting from the second search starting point, for each pixel traversed, the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are selected in the next column of the laser image to form a preset pixel region. The current laser line grayscale change amount is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. When the current laser line grayscale change amount is greater than the preset boundary judgment threshold, the currently traversed pixel is set as the lower boundary pixel of the laser line. Here, the current laser line grayscale change amount is calculated only once within the corresponding preset pixel region to search for a lower boundary pixel of the laser line, establishing the correspondence between the second search starting point, the preset pixel region, the current laser line grayscale change amount, and the lower boundary pixel of the laser line.
[0055] Schematic illustration: The configuration of the first or second search starting point includes: the neighborhood of the upper or lower boundary pixel of the laser line in the next column can be a 5*1 area, representing the neighborhood of a search starting point that is horizontally adjacent to the upper or lower boundary pixel of the laser line and located in the next column. The neighborhood of the search starting point covers two pixels upwards and two pixels downwards, forming a 5*1 area in the next column. Due to camera lens distortion, the search starting point of the neighborhood of the upper or lower boundary pixel of the laser line in the next column is not necessarily distributed horizontally with the upper or lower boundary pixel of the laser line. Instead, it is represented as follows: the column direction coordinate of the upper boundary pixel of the laser line in the 4th column is 123, the column direction coordinate of the first search starting point in the 5th column is 124, and it is speculated that the column direction coordinate of the first search starting point in the 6th column is 125.
[0056] It should be noted that the method for constructing the preset pixel region includes: within a column of the laser image, a pixel whose distance from the currently traversed pixel in the preset column direction is equal to a preset pixel distance is set as a first calculated pixel; a pixel whose distance from the currently traversed pixel in the preset column direction is equal to a preset pixel distance is set as a first calculated pixel; a pixel whose distance from the currently traversed pixel in the preset column direction is equal to half of the preset pixel distance is set as a second calculated pixel; and a pixel whose distance from the currently traversed pixel in the opposite direction of the preset column direction is equal to half of the preset pixel distance is set as a third calculated pixel. Schematic, the preset column direction is vertically upward, the preset pixel distance is equal to the value 2, and within the preset pixel region, when the coordinate of the currently traversed pixel in the preset column direction is y, the coordinate of the first calculated pixel in the preset column direction is y+2, the grayscale value of the first calculated pixel is f(y+2), the grayscale value of the second calculated pixel is f(y+1), the grayscale value of the currently traversed pixel is f(y), and the grayscale value of the third calculated pixel is f(y-1). Then, the first and third calculated pixels are used to form two boundary points of the preset pixel region, so that the second calculated pixel and the currently traversed pixel divide the preset pixel region into four equal parts in a column.
[0057] In the foregoing embodiments, the method for calculating the grayscale change of the current laser line in step A is mainly based on the first calculated pixel point, the second calculated pixel point, the currently traversed pixel point, and the third calculated pixel point to calculate the grayscale change of the current laser line column by column, and can distinguish between calculation in the preset pixel area used to obtain the upper boundary pixel point and calculation in the preset pixel area used to obtain the lower boundary pixel point.
[0058] The method for calculating the grayscale change of the current laser line specifically includes: traversing the pixels row by row in a column of the laser image, setting the first calculation pixel, the second calculation pixel, the currently traversed pixel, and the third calculation pixel in a column of the laser image from top to bottom according to a preset pixel distance, and extracting the grayscale values f(y+2), f(y+1), f(y), f(y), and f(y-1) of the first calculation pixel, respectively.
[0059] The grayscale value of the first calculated pixel is subtracted from the grayscale value of the currently traversed pixel to obtain the first preset grayscale difference f(y+2)-f(y). This increases the pixel distance between the two points whose grayscale values differ to a distance of 2 pixels, compared to the calculation method of the second-order partial derivative.
[0060] The grayscale value of the second calculated pixel is subtracted from the grayscale value of the third calculated pixel to obtain the second preset grayscale difference f(y+1)-f(y-1). This increases the pixel distance between the two points whose grayscale values differ to a distance of 2 pixels relative to the second-order partial derivative calculation method.
[0061] The first preset grayscale difference and the second preset grayscale difference are added together to obtain the current laser line grayscale change amount f(y+2)-f(y)+f(y+1)-f(y-1). This enables the calculation of the current laser line grayscale change amount within a preset pixel area according to a preset pixel distance, thereby optimizing the extraction effect of the upper and lower boundary pixels of the laser line.
[0062] As one example, such as Figure 2 As shown, in step B, the method for determining whether the upper boundary pixels of the laser line and the lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image includes:
[0063] Step B1: Starting from the search starting point, continuously traverse each column of pixels in the laser image and count the number of columns traversed in the laser image. Also count the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found, and then execute step B2. When the robot continuously traverses each column of pixels in step B1, it needs to calculate the current grayscale change of the laser line in each column of the laser image according to step A, and search for the upper and lower boundary pixels of the laser line based on the relationship between the current grayscale change of the laser line and the preset boundary judgment threshold. It may not be possible to find the upper and lower boundary pixels of the laser line in every column, and the upper and lower boundary pixels of the laser line may not have been found before executing step B1.
[0064] Step B2: Determine whether the number of columns traversed in the laser image is less than the preset number. If yes, proceed to step B3; otherwise, proceed to step B4. The preset number is preferably 3. Each time a column is traversed, count the number of columns traversed and determine whether the number of columns traversed is less than the preset number.
[0065] Step B3: Determine whether the upper and lower boundary pixels of the laser line are found in the current column of the laser image. That is, determine whether the upper and lower boundary pixels of the laser line are found in the current column at the same time. If yes, proceed to step D; otherwise, proceed to step B6 to continue traversing the next column and recount the number of related columns.
[0066] If the robot determines in step B3 that it has found the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column of the laser image, it means that there may be a laser line in the current column, but the preset number of columns have not been traversed yet. It needs to traverse the next column by executing step D, but it will not reset the number of columns traversed in the laser image to zero, nor will it reset the number of columns in the laser image where the upper boundary pixel of the laser line and the lower boundary pixel of the laser line have been found to zero.
[0067] If the robot determines in step B3 that no upper or lower boundary pixels of the laser line are found in the current column of the laser image, it determines that there is no laser line in the current column and identifies the currently traversed pixels as noise, which needs to be filtered out. At the same time, in order to continuously traverse a preset number of columns with upper and lower boundary pixels of the laser line in the laser image, if noise appears in the current column, the number of columns traversed in the laser image will be reset to zero, and the number of columns in the laser image with upper and lower boundary pixels of the laser line will be reset to zero before traversing the next column.
[0068] Step B4: Determine whether the number of columns in the laser image that have been searched for the upper and lower boundary pixels of the laser line is less than the preset number. If yes, proceed to step B3; otherwise, proceed to step B5.
[0069] Step B3: Whenever the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in a column, the number of columns in which the upper boundary pixel of the laser line and the lower boundary pixel of the laser line have been found is counted once. Then, step B4: It is determined whether the number of columns in the laser image in which the upper boundary pixel of the laser line and the lower boundary pixel of the laser line have been found has reached a preset number. The preset number is preferably 3, so that the validity of the traversed laser line is determined by using 3 consecutive columns as a reference column number.
[0070] Step B5: Determine if the upper and lower boundary pixels of the laser line are found in every consecutive preset number of columns in the laser image. The preset number is preferably 3. When the upper and lower boundary pixels of the laser line are found in every 3 consecutive columns, it is determined that a laser line has been identified once in the laser image. Then, the number of columns traversed in the laser image is reset to zero, and the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found is also reset to zero. Then, step C is executed. This eliminates the interference of noise on the laser line identification by searching for the upper and lower boundary pixels of the laser line in every consecutive preset number of columns.
[0071] Step B6: Configure the first row of pixels in the next column as the search starting point of the next column, update the next column to the current column, clear the number of columns traversed in the laser image to zero, clear the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been searched to zero, and then execute step A, so that the subsequent step B can determine that the upper and lower boundary pixels of the laser line have been searched in a consecutive preset number of columns in the laser image.
[0072] It should be noted that each time a laser line boundary pixel and a laser line boundary pixel are found in the current column of the laser image, it is determined that a column in the laser image has been identified as having laser line boundary pixels and laser line boundary pixels. Cases where laser line boundary pixels and laser line boundary pixels are not found in all consecutive preset number of columns in the laser image include: starting from the first column, the number of columns in the laser image where laser line boundary pixels and laser line boundary pixels are found is less than the preset number, and / or laser line boundary pixels and laser line boundary pixels are not found in all consecutive preset number of columns in the laser image.
[0073] As one embodiment, after determining the laser line currently identified from the laser image by performing step C once, in order to further determine the continuity of the currently identified laser line, such as... Figure 3 As shown, the laser line center extraction method has the following characteristics:
[0074] Step C1: Determine the upper and lower boundary pixels of the laser line within the current column of the laser image. Then, within the neighborhood of the upper and lower boundary pixels, set the search starting point for the next column and update the next column to the current column, equivalent to executing step D. Then execute step C2. It should be noted that the current column can predict the position of the next column's pixels because the laser line is continuous. When the laser line hits a relatively flat and complete obstacle, a continuous laser line will be obtained. Therefore, the position of the next laser line can be predicted based on the already found laser line's trajectory.
[0075] Step C2: Within the current column of the laser image, starting from the search starting point, continuously traverse each column of pixels in the laser image and count the number of columns traversed. Also count the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found, and then proceed to step C3. When the robot continuously traverses each column of pixels in step C2, it needs to calculate the current laser line grayscale change in each column of the laser image according to step A, and search for the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change and the preset boundary judgment threshold. It may not be possible to find the upper and lower boundary pixels of the laser line in every column, but the upper and lower boundary pixels of the laser line have already been searched once before step C1.
[0076] Step C3: Determine whether the number of columns traversed within the laser image is less than a preset number. If yes, proceed to step C4; otherwise, proceed to step C5. The preset number is preferably 3. Each time a column is traversed, count the number of columns traversed and determine whether the number of columns traversed is less than the preset number. This is to determine whether the robot continues to traverse 3 columns after performing step C once and searching for the upper and lower boundary pixels of the laser line.
[0077] Step C4: Determine whether the upper and lower boundary pixels of the laser line are found in the current column of the laser image. If yes, execute step C1; otherwise, execute step C7. Thus, if the number of columns traversed in the laser image is less than a preset number and the upper and lower boundary pixels of the laser line are found in the current column of the laser image, execute step C1 to traverse the next column until the number of columns traversed in the laser image reaches the preset number. Then, combine with step C4 to determine whether the upper and lower boundary pixels of the laser line are found in a preset number of consecutive columns in the laser image, or whether the upper and lower boundary pixels of the laser line are not found in a preset number of consecutive columns in the laser image.
[0078] If the number of columns traversed within the laser image is less than a preset number, and no upper or lower boundary pixels of the laser line are found in the current column of the laser image, it is determined that there is no laser line in the current column, and the currently traversed pixels are identified as noise. Thus, it is determined that no laser line has been identified from the laser image. If the robot fails to identify the laser line in the current column, step C7 is executed to count the number of columns where laser line identification failed (also counted as the number of times laser line identification failed) and the robot continues to traverse the next column until the number of columns traversed within the laser image reaches the preset number.
[0079] Step C5: Determine if the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found is less than a preset number. If yes, proceed to step C4; otherwise, proceed to step C6. Each time an upper and lower boundary pixel of the laser line is found in a column, count the number of columns where the upper and lower boundary pixels of the laser line have been found, and determine if the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found is less than a preset number. The preset number is preferably 3, so that the validity of the traversed laser line is determined by using the 3 columns traversed sequentially as a reference column number.
[0080] Step C6: Determine that a laser line has been identified again in the laser image. At this point, it has been proven that a laser line has been identified in two consecutive columns. Clear the number of columns that have been traversed in the laser image to zero, and clear the number of columns in the laser image that have already found the upper and lower boundary pixels of the laser line to zero, to prevent affecting the statistical results of the next execution of step C2. Then execute step C1 to traverse the next column.
[0081] Step C7: Determine if laser line recognition fails in the current column and count the number of columns where laser line recognition failed. Specifically, each time step C4 determines that no upper or lower boundary pixels of the laser line are found in the current column of the laser image, the number of columns where laser line recognition failed is counted once, and this count is recorded in step C7. Then, step C8 is executed. Simultaneously, step C7 also determines that no laser line exists in the current column and identifies the currently traversed pixels as noise, thus confirming that no laser line has been identified from the laser image.
[0082] Step C8: Determine whether the number of columns where laser line recognition failed is greater than or equal to a preset number. If yes, proceed to step C9; otherwise, proceed to step C10. The preset number is preferably 3, so that 3 consecutive columns are used as a reference number to determine the continuity of the traversed laser lines. If the number of columns where laser line recognition failed is less than the preset number, step C10 needs to be executed to continue traversing the next column, in order to determine whether no upper or lower boundary pixels of the laser line are found in any consecutive preset number of columns within the laser image.
[0083] Step C9: If no upper or lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image, then a laser line is determined to be segmented in the current column. Specifically, after finding the upper and lower boundary pixels of the laser line in the previous column of the laser image (i.e., after identifying the laser line once), if no upper or lower boundary pixels of the laser line are found in three consecutive columns, then the laser line identified in the previous column is determined to be segmented. This indicates that the laser line previously traversed hit obstacles at two different locations, resulting in a segmented and discontinuous laser line. At this point, the robot will continue traversing the next column to search for other laser lines. The number of columns where laser line identification failed is then reset to zero, and step C10 is executed.
[0084] Step C10: The number of columns traversed within the laser image is reset to zero, and the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found is also reset to zero. Simultaneously, the first row of pixels in the next column is updated as the search starting point, and the next column is updated to the current column. Then, step C2 is executed. Since step C4 has already determined that the upper and lower boundary pixels of the laser line have been found in the current column of the laser image and jumps to step C7, instead of setting the search starting point in the next column within the neighborhood of the upper and lower boundary pixels as in step C1, the first row of pixels in the next column is directly updated as the search starting point, and the next column is updated to the current column. Then, step C2 is executed. This demonstrates that the laser line is segmented by the failure to identify the laser line in a consecutive preset number of columns, reflecting obstacle distribution information.
[0085] In summary, whenever it is determined that no laser line exists in the current column and the currently traversed pixel is identified as noise, it is determined that not all laser line upper and lower boundary pixels are found in a consecutive preset number of columns in the laser image, and it is also determined that no laser line upper or lower boundary pixels are found in the current column of the laser image. Therefore, to prove that the laser line is segmented by failing to identify the laser line through a consecutive preset number of columns, the first row of pixels in the next column is configured as the search starting point in the next column, and the next column is updated to the current column. Then, the traversal of each column of the laser image continues until a preset number of steps C4 are executed consecutively and it is determined that no laser line is found in the current column of the laser image. Only by identifying the upper and lower boundary pixels of the laser line can a laser line segmentation be confirmed. After each execution of steps C7 and C9, which determine that laser line recognition in the current column has failed and that laser line segmentation has been confirmed, the number of columns traversed in the laser image is reset to zero, as are the number of columns in the laser image where the upper and lower boundary pixels of the laser line have been found. Then, step C2 is executed to start from the search starting point of the next column. A preset number of consecutive columns and the upper and lower boundary pixels of the laser line in each column are counted again to identify the laser line from the laser image. This effectively addresses interference caused by multipath or reflection and improves the accuracy of laser line recognition.
[0086] Based on the foregoing embodiments, this application also discloses a chip electrically connected to a line laser sensor, or the chip disposed inside the line laser sensor. Both the chip and the line laser sensor are mounted in a robot. The line laser sensor emits line laser light, which is reflected by obstacles and captured by the robot to form a laser image. The chip is configured to execute the laser line center extraction method disclosed in the foregoing embodiments. The chip is used to perform steps A to D of the laser line center extraction method on the pixels in each column of the laser image to identify laser lines from the laser image and calculate the center point of each column of laser lines. The chip disclosed in this application traverses each column of pixels within a preset pixel area by executing steps A to D to calculate the current grayscale change in the laser line and searches for the upper and lower boundary pixels of the laser line based on the relationship between the current grayscale change in the laser line and a preset boundary judgment threshold. This is achieved by amplifying the change in grayscale values to search for the upper and lower boundary pixels of the laser line. Compared with the prior art, the chip disclosed in this application does not rely solely on grayscale values to determine boundaries.
[0087] The chip disclosed in this application determines that a laser line has been identified in the laser image when it searches for both the upper and lower boundary pixels of the laser line within a consecutive preset number of columns. It then calculates the center point of the laser line between the upper and lower boundary pixels using the gray-scale centroid method, improving the accuracy of laser line center point extraction and filtering out laser lines generated by multiple paths. Therefore, the chip disclosed in this application does not need to traverse all pixels in the laser image. Instead, it searches for the upper and lower boundary pixels of the laser line within a preset pixel area based on the relationship between the current gray-scale change in the laser line and a preset boundary judgment threshold. When the upper and lower boundary pixels of the laser line are found within a consecutive preset number of columns in the laser image, the laser line can be identified. This reduces the time spent processing pixels and enables the chip to accelerate the extraction of accurate laser line center points within local pixel areas of the laser image, while also eliminating interfering laser lines generated by multiple paths or reflections.
[0088] The above embodiments are only for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent transformations or modifications made in accordance with the spirit and essence of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for laser line center extraction based on a line laser sensor, characterized in that, Laser line center extraction methods include: Step A: Within the current column of the laser image, starting from the search starting point, traverse each pixel according to the preset pixel area and calculate the current laser line grayscale change amount. Based on the relationship between the current laser line grayscale change amount and the preset boundary judgment threshold, search for the upper boundary pixel of the laser line and the lower boundary pixel of the laser line, and then execute Step B; wherein, the laser image is a laser line distribution image obtained in real time by a line laser sensor. Step B: Determine whether the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in a consecutive preset number of columns in the laser image. If yes, proceed to step C; otherwise, proceed to step D. Step C: Determine the laser line currently identified from the laser image; and for each column, calculate the center point of the laser line using the gray-scale centroid method between the upper boundary pixel of the laser line and the lower boundary pixel of the laser line. Step D: Based on the upper boundary pixel of the laser line and the lower boundary pixel of the laser line, set the search starting point in the next column, update the next column to the current column, and then execute step A; In this case, the neighborhood of the upper boundary pixel of the laser line and the neighborhood of the lower boundary pixel of the laser line both extend to the next column.
2. The laser line center extraction method according to claim 1, characterized in that, In step A, the method for searching for the upper and lower boundary pixels of the laser line based on the relationship between the current grayscale change amount of the laser line and the preset boundary determination threshold includes: For each pixel traversed, the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are selected in the current column of the laser image to form a preset pixel area, and the grayscale change amount of the current laser line is calculated once based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. If the grayscale change amount of the current laser line calculated in both consecutive calculations is greater than the preset boundary judgment threshold, then the pixel point currently traversed that is required to calculate the grayscale change amount of the current laser line first will be set as the upper boundary pixel point of the laser line, and the pixel point currently traversed that is required to calculate the grayscale change amount of the current laser line second will be set as the lower boundary pixel point of the laser line.
3. The laser line center extraction method according to claim 2, characterized in that, The pixels currently traversed that are required to calculate the grayscale change of the current laser line first and the pixels currently traversed that are required to calculate the grayscale change of the current laser line later are located at different positions. Each currently traversed pixel corresponds to a first calculated pixel, a second calculated pixel, and a third calculated pixel, forming two different preset pixel regions, so that the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are located in two different preset pixel regions. Within the current column, the area between the upper boundary pixel of the laser line and the lower boundary pixel of the laser line is used to distribute the laser line.
4. The laser line center extraction method according to claim 1, characterized in that, In step D, the method for setting the search starting point in the next column based on the upper boundary pixel of the laser line and the lower boundary pixel of the laser line includes: If the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in the current column, then set a pixel in the neighborhood of the upper boundary pixel of the laser line and a pixel in the neighborhood of the lower boundary pixel of the laser line in the next column as the search starting point in the next column. If no upper or lower boundary pixel of the search laser line is found in the current column, the first row of pixels in the next column will be configured as the search starting point in the next column.
5. The laser line center extraction method according to claim 4, characterized in that, In step A, the method for searching for the upper and lower boundary pixels of the laser line based on the relationship between the current laser line grayscale change amount and the preset boundary determination threshold further includes: When a pixel in the neighborhood of the laser line's boundary pixel is configured as the first search starting point, in the next column, starting from the first search starting point, for each pixel traversed, a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel are selected in the next column of the laser image to form a preset pixel region. The grayscale change amount of the current laser line is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. When the grayscale change amount of the current laser line is greater than a preset boundary determination threshold, the currently traversed pixel is set as the boundary pixel of the laser line. When a pixel in the neighborhood of the lower boundary pixel of the laser line is configured as the second search starting point, in the next column, starting from the second search starting point, for each pixel traversed, a first calculated pixel, a second calculated pixel, the currently traversed pixel, and a third calculated pixel are selected in the next column of the laser image to form a preset pixel region. The grayscale change amount of the current laser line is calculated based on the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel. When the grayscale change amount of the current laser line is greater than the preset boundary determination threshold, the currently traversed pixel is set as the lower boundary pixel of the laser line. The search starting points in the next column include the first search starting point and the second search starting point.
6. The laser line center extraction method according to claim 3 or 5, characterized in that, The method for constructing the preset pixel region includes: Within a column of the laser image, a pixel whose distance from the currently traversed pixel in the preset column direction is equal to a preset pixel distance is set as a first calculated pixel. A pixel whose distance from the currently traversed pixel in the preset column direction is equal to a preset pixel distance is set as a first calculated pixel. A pixel whose distance from the currently traversed pixel in the preset column direction is equal to half of the preset pixel distance is set as a second calculated pixel. A pixel whose distance from the currently traversed pixel in the opposite direction of the preset column direction is equal to half of the preset pixel distance is set as a third calculated pixel. Then, the first and third calculated pixels form two boundary points of the preset pixel region, such that the second calculated pixel and the currently traversed pixel divide the preset pixel region into four equal parts within a column.
7. The laser line center extraction method according to claim 6, characterized in that, In step A, the method for calculating the current grayscale change of the laser line includes: The pixels are traversed row by row in a column of the laser image. According to the preset pixel distance, the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are set from top to bottom in a column of the laser image. The gray values of the first calculated pixel, the second calculated pixel, the currently traversed pixel, and the third calculated pixel are extracted respectively. The grayscale value of the first calculated pixel is subtracted from the grayscale value of the currently traversed pixel to obtain the first preset grayscale difference; The grayscale value of the second calculated pixel is subtracted from the grayscale value of the third calculated pixel to obtain the second preset grayscale difference; The grayscale change amount of the current laser line is obtained by adding the first preset grayscale difference and the second preset grayscale difference.
8. The laser line center extraction method according to claim 1, characterized in that, In step B, the method for determining whether the upper boundary pixels of the laser line and the lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image includes: Step B1: Starting from the search starting point, continuously traverse each column of pixels in the laser image and count the number of columns traversed in the laser image. Also count the number of columns in the laser image where the upper boundary pixels of the laser line and the lower boundary pixels of the laser line have been searched, and then execute step B2. Step B2: Determine whether the number of columns traversed in the laser image is less than the preset number. If yes, proceed to step B3; otherwise, proceed to step B4. Step B3: Determine whether the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in the current column of the laser image. If yes, proceed to step D; otherwise, proceed to step B6. Step B4: Determine whether the number of columns in the laser image that have been searched for the upper boundary pixels of the laser line and the lower boundary pixels of the laser line is less than the preset number. If yes, proceed to step B3; otherwise, proceed to step B5. Step B5: Determine that the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in a consecutive preset number of columns in the laser image, and clear the number of columns traversed in the laser image to zero, and clear the number of columns in the laser image in which the upper boundary pixel of the laser line and the lower boundary pixel of the laser line have been found to zero, and then execute step C. Step B6: Configure the first row of pixels in the next column as the search starting point in the next column, update the next column to the current column, clear the number of columns traversed in the laser image to zero, clear the number of columns in the laser image that have been searched for the upper boundary pixels of the laser line and the lower boundary pixels of the laser line, and then execute step A.
9. The laser line center extraction method according to claim 1, characterized in that, After performing step C once to determine that a laser line has been identified from the laser image, the following exists: Step C1: Determine the upper boundary pixel of the laser line and the lower boundary pixel of the laser line in the current column of the laser image respectively. Then, in the neighborhood of the upper boundary pixel of the laser line and the neighborhood of the lower boundary pixel of the laser line, set the search starting point in the next column and update the next column to the current column. Then execute step C2. Step C2: In the current column of the laser image, starting from the search starting point, continuously traverse each column of pixels in the laser image and count the number of columns traversed in the laser image. Also count the number of columns in the laser image where the upper boundary pixels of the laser line and the lower boundary pixels of the laser line have been searched, and then execute step C3. Step C3: Determine whether the number of columns traversed in the laser image is less than the preset number. If yes, proceed to step C4; otherwise, proceed to step C5. Step C4: Determine whether the upper boundary pixel of the laser line and the lower boundary pixel of the laser line are found in the current column of the laser image. If yes, proceed to step C1; otherwise, proceed to step C7. Step C5: Determine whether the number of columns in the laser image that have been searched for the upper boundary pixels of the laser line and the lower boundary pixels of the laser line is less than the preset number. If yes, proceed to step C4; otherwise, proceed to step C6. Step C6: Determine that a laser line has been identified in the laser image. Clear the number of columns that have been traversed in the laser image to zero. Clear the number of columns in the laser image that have been searched for the upper boundary pixels of the laser line and the lower boundary pixels of the laser line. Then execute step C1. Step C7: Determine if laser line recognition fails in the current column, count the number of columns that fail laser line recognition, and then proceed to step C8. Step C8: Determine whether the number of columns that failed to identify the laser line is greater than or equal to a preset number. If yes, proceed to step C9; otherwise, proceed to step C10. Step C9: Determine that no upper or lower boundary pixels of the laser line are found in a consecutive preset number of columns in the laser image, and then determine that a laser line is segmented in the current column. At the same time, clear the number of columns where laser line recognition failed to be performed, and then execute step C10. Step C10: Clear the number of columns traversed in the laser image to zero, clear the number of columns in the laser image where the upper boundary pixels of the laser line and the lower boundary pixels of the laser line have been searched to zero, update the first row of pixels in the next column as the search starting point, update the next column as the current column, and then execute step C2.
10. A chip, wherein the chip is electrically connected to a line laser sensor, or the chip is disposed inside a line laser sensor; characterized in that, The chip is configured to perform the laser line center extraction method according to any one of claims 1 to 9 to identify laser lines from a laser image and calculate the center point of each column of laser lines.