A robot region processing method based on changing thresholds
By dynamically adjusting the threshold to control the number of iterations and the expansion of the watershed algorithm, the problems of computational overhead and real-time navigation in robot map segmentation are solved, and efficient room area division of indoor environment is achieved.
Patent Information
- Application Number
- CN202210290285.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-23
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2042-03-23
AI Technical Summary
Existing watershed algorithms lead to increased computational overhead and decreased navigation real-time performance when segmenting robot maps, and cannot efficiently divide room areas in indoor environments.
A region processing method based on changing thresholds is adopted. By dynamically adjusting the initial expansion threshold and the expansion threshold, the number of iterations of the watershed algorithm is controlled. The robot's working area is marked according to the repeatability of the region expansion, thereby reducing repeated scanning calculations.
It improves the efficiency of robot map region division, reduces computational overhead, enhances the real-time performance of navigation, and enables the simultaneous detection and segmentation of local areas in different indoor locations.
Smart Images

Figure CN116843699B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of watershed algorithm for map segmentation, and more particularly to a method for robot region processing based on changing thresholds. Background Technology
[0002] In the field of robotics, maps are one of the main tools that help robots describe their environment and achieve precise localization. Currently, when using the watershed algorithm for map image segmentation, it starts with selected seed elements in each region and iteratively performs morphological opening operations on the grid map according to the corresponding gradient hierarchy. This involves multiple scans and calculations for each pixel on average, gradually segmenting each potential room region. This not only increases the computational overhead for the robot on the timely constructed map regions but also affects the real-time performance of the robot's navigation and movement. Summary of the Invention
[0003] To address the aforementioned technical problems, this invention discloses a robot region processing method based on a changing threshold under the conditions of the watershed algorithm. This method is applicable to dividing the robot's current working environment into various working zones, corresponding to the room areas in the robot's indoor environment. The specific technical solution is as follows:
[0004] A robot region processing method based on a changing threshold is disclosed. The method includes: the robot expanding a region using a watershed algorithm until the grayscale value of the pixels on the contour of the latest expanded region equals an initial expansion threshold, and marking the robot's working partitions; then controlling the initial expansion threshold to change once, and updating the changed initial expansion threshold to the current expansion threshold; when the robot's current expansion threshold equals a preset termination threshold, stopping the watershed algorithm for region expansion and confirming that all robot working partitions have been marked; when the robot's current expansion threshold does not equal the preset termination threshold, continuing to expand the region using the watershed algorithm, and marking the robot's working partitions based on the repetitiveness of the region expansion, until the grayscale value of the pixels on the contour of the latest expanded region equals the robot's current expansion threshold, then controlling the robot's current expansion threshold to change once, and updating the changed expansion threshold to the current expansion threshold.
[0005] Furthermore, before starting the region expansion using the watershed algorithm, an expansion starting point is set. This starting point is a seed element in the watershed algorithm, ensuring that each region expansion update uses pixels from areas not marked as robot working zones. The initial expansion threshold and the expansion threshold are both thresholds describing the distance between the pixel to be processed and the contour of the robot's environment, represented by grayscale values. The pixels to be processed include pixels from areas not marked as robot working zones. As the pixel to be processed gets closer to the contour of the robot's environment, changing the initial expansion threshold once reduces it, and changing the robot's currently obtained expansion threshold once reduces it. The preset termination threshold is less than the initial expansion threshold.
[0006] Furthermore, the method for marking robot work zones based on the repetitiveness of region expansion includes determining that if a marked traversable connected region exists within the newly expanded effective region, the marked traversable connected region is considered part of the already marked robot work zone, but the marked traversable connected region is not marked as a new robot work zone; wherein, the region formed between the outline of the newly expanded region and the outline of the previously expanded region is the newly expanded effective region.
[0007] Furthermore, if it is determined that there is a marked extension starting point within the newly expanded effective region, then it is determined that there is a marked traversable connected component within the newly expanded effective region.
[0008] Furthermore, the method for marking robot work partitions based on the repetitiveness of region expansion also includes, if it is determined that there is a traversable connected region within the newly expanded effective region that does not overlap with the marked traversable connected region, then the traversable connected region that does not overlap with the marked traversable connected region is marked as a new robot work partition and stored in the work region list storage space; wherein, when a traversable connected region is marked as a robot work partition, each pixel point within the traversable connected region is marked as belonging to the robot work partition.
[0009] Furthermore, the method of using the watershed algorithm for region expansion includes expanding the region outward according to the gray values sorted from high to low when the expansion threshold obtained by the control robot changes once, which means that the expansion threshold obtained by the control robot decreases once; wherein, in each expanded region, the contour formed by pixels with the same gray value is expanded by the contour formed by pixels with higher gray values, and the contour formed by pixels with the same gray value is surrounded by the contour formed by pixels with lower gray values.
[0010] Furthermore, the grayscale value of each pixel within the traversable connected region is equal; or, the grayscale value of each pixel on the outline of each expanded region is equal; wherein, each expanded region includes a portion of the marked robot working partition, a region connected to the marked robot working partition, and / or the newly generated connected region.
[0011] Furthermore, the newly generated connected component is a traversable connected component that does not overlap with the already marked traversable connected components. The newly generated connected component is not connected to the already marked robot work area, so that the newly marked robot work area is not connected to the already marked robot work area.
[0012] Furthermore, the method of controlling the expansion threshold to change once includes: controlling the expansion threshold to change once in the same direction according to a preset gradient value; wherein, the preset gradient value is allowed to be configured to be different, so that the magnitude of the expansion threshold change is different each time; or, the preset gradient value is allowed to be configured to be the same, so that the expansion threshold changes according to a fixed gradient value.
[0013] Furthermore, the preset gradient value is used to limit the number of iterations of the watershed algorithm, thereby constraining the range of the area expanded by the robot and the range of the robot's working partition; wherein, when the expansion threshold currently obtained by the robot changes once, which means the expansion threshold currently obtained by the robot decreases once, the preset termination threshold is 0.
[0014] Compared with existing technologies, this invention limits the number of segmentations of the watershed algorithm during the region segmentation process by continuously changing the threshold to ensure the robot's working efficiency. Under each threshold condition, it determines whether to mark the new region as a new robot working partition based on whether the newly generated region contains the already marked old region. This enables one-time detection and segmentation of local regions at different locations within the same map image, reducing the number of repeated scanning calculations, and also determining the approximate distribution of all marked robot working partitions. Attached Figure Description
[0015] Figure 1 This is a flowchart of a region processing method based on a changing threshold disclosed in one embodiment of the present invention.
[0016] Figure 2(a) is a schematic diagram of the room area expanded by the watershed algorithm under the condition of an initial expansion threshold, according to an embodiment of the present invention.
[0017] Figure 2(b) is a schematic diagram of the various room areas obtained by expanding based on Figure 2(a) under the condition that the initial expansion threshold is reduced for the first time.
[0018] Figure 2(c) is a schematic diagram of each room area obtained by expanding based on Figure 2(b) under the condition that the initial expansion threshold is reduced for the second time.
[0019] Figure 3 This is a schematic diagram of each room area obtained when the latest expansion threshold equals the preset termination threshold. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be described in detail below with reference to the accompanying drawings. To further illustrate the embodiments, the present invention provides accompanying drawings. These drawings are part of the disclosure of the present invention, 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 the present invention. The components in the figures are not drawn to scale, and similar component symbols are generally used to represent similar components.
[0021] This invention discloses a robot-based region processing method using varying thresholds. This method is suitable for robots to divide and identify various room areas in their current working environment. Specifically, it involves setting dynamically changing thresholds to perform grayscale processing on a pre-scanned map image constructed by the robot. At each threshold, the map image is grayscaled into a corresponding grayscale image, allowing the robot to use a watershed algorithm to identify new, non-repeating working partitions at each threshold. This includes non-repeating scanning and expanding the marking of robot working partitions, adapting to the simultaneous division of multiple, continuously expanding room areas within an indoor environment. Optionally, the robot is equipped with a LiDAR, which can be a 360-degree rotating LiDAR or a fixed LiDAR. The robot also includes a controller, an electronic computing core built into the robot body. The controller is connected to the LiDAR sensor and is used to execute the logical operation steps corresponding to the region processing method to achieve intelligent processing of the indoor area.
[0022] See Figure 1It can be seen that the region processing method specifically includes: step S101, the robot uses the watershed algorithm to expand the region until the gray value of the pixel on the contour of the newly expanded region is equal to the initial expansion threshold, then a watershed line (belonging to the watershed in the watershed algorithm) is found below the initial expansion threshold, then the robot can divide the corresponding robot working area along the corresponding watershed line and mark the robot working area; then control the initial expansion threshold to change once, and update the changed initial expansion threshold to the expansion threshold; then proceed to step S102. In this embodiment, the robot first sets an initial expansion threshold and several expansion starting points, which can be determined as the initial expansion starting points. Each initial expansion starting point is located at the center of a specific map area. Then, starting from each initial expansion starting point, the robot uses the watershed algorithm to expand the region. When the grayscale value of the pixels at the edge of the region meets the initial expansion threshold, it is equivalent to dividing the same map area into different partitions along the watershed at the initial expansion threshold. The partitions are equivalent to newly expanded areas starting from the corresponding expansion starting points, and these newly expanded areas can be marked as the robot's working partitions. Then, to continue expanding the region and according to the watershed algorithm under the new expansion threshold conditions (equivalent to new grayscale levels), the robot needs to apply a change to the initial expansion threshold. The robot controls the initial expansion threshold to change once and updates the changed initial expansion threshold to the expansion threshold to start iteratively expanding the region. It should be noted that the expansion starting point is equivalent to the seed element of the region currently being processed by the watershed algorithm. An initial expansion starting point corresponds to the center point of a room area that the robot wants to divide, that is, the center point of a robot working partition (the area may continue to expand later).
[0023] Step S102: Determine whether the currently obtained expansion threshold of the robot is equal to the preset termination threshold. If yes, proceed to step S104; otherwise, proceed to step S103. It should be noted that before each new region expansion using the watershed algorithm, the robot controls the expansion threshold to change once in the same direction according to a preset gradient value. The preset gradient value can be configured to be different, so that the magnitude of the change in the expansion threshold varies each time. The specific magnitude is related to the distance between the pixel to be processed and the edge of the region to be processed, or it can be determined by the connectivity between the contour of the currently expanded region and the contour of the region to be processed; the better the connectivity, the greater the magnitude of the change. Alternatively, the preset gradient value can be configured to be the same, so that the expansion threshold changes according to a fixed gradient value, then the number of region expansions performed by the watershed algorithm is controllable.
[0024] It should be noted that the preset gradient value is used to limit the number of iterations of the watershed algorithm, thus constraining the range of the region expanded by the robot and the range of the robot's working partition. In some embodiments, when the currently obtained expansion threshold of the robot changes once, it means that the currently obtained expansion threshold of the robot decreases once, and the preset termination threshold is a value of 0, which can correspond to all pixels on the outline being black pixels, or to the presence of black pixels on the outline. In other embodiments, when the currently obtained expansion threshold of the robot changes once, it means that the currently obtained expansion threshold of the robot increases once, and the preset termination threshold is a value of 255, which can correspond to all pixels on the outline being white pixels, or to the presence of white pixels among the pixels on the outline.
[0025] Step S103: Use the watershed algorithm to expand the region. At this time, the robot uses the expansion threshold currently obtained by the robot (the expansion threshold obtained from the latest change, including the expansion threshold obtained from the change of the initial expansion threshold in step S101), and marks the robot's working partition according to the repeatability of the region expansion, until the gray value of the pixel on the contour of the latest expanded region is equal to the expansion threshold currently obtained by the robot, and then proceeds to step S104. In step S103, during the execution of the watershed algorithm, whenever the robot detects a change in the expansion threshold, it continues to expand the region based on the changed expansion threshold, according to the basic segmentation concept of the watershed algorithm. It can also expand the neighborhood of unmarked pixels to mark the robot's working partitions. However, for repeatedly scanned pixels or connected regions, the region expansion operation is not continued. The marking of the robot's working partitions is based on the repetitiveness of the region expansion, until there are pixels on the contour of the latest expanded region whose grayscale value equals the robot's currently obtained expansion threshold, or the grayscale value of all pixels on the contour (edge line) of the latest expanded region equals the robot's currently obtained expansion threshold. At this point, a watershed at the robot's currently obtained expansion threshold is determined. The change in the expansion threshold can be controlled by the robot and is mainly determined by the progress of the watershed algorithm's region expansion within the same map image. It can be related to the current value of the expansion threshold. Moreover, the more expansion thresholds there are, the more new robot working partitions are expanded, allowing the robot to divide room areas of more shapes in an indoor environment.
[0026] It should be noted that whenever the robot expands an area that includes both new connected components (unmarked connected components) and old connected components (connected components already marked as robot working zones), the expanded area is marked. In some embodiments, the connected components described in this example can be divided from spatially adjacent regions with similar grayscale values. Pixels within a connected component have the same grayscale value, and different regions are separated by connected components, serving as a watershed for image segmentation. The robot assigns a region to each pixel within the expanded area, distinguishing between marked and unmarked regions. Each marked connected component within a robot working zone can be assigned a unique identifier to differentiate it from other connected components. However, this is not simply a matter of marking pixels as being occupied by obstacles, but rather assigning them to a specific robot working zone or a corresponding type of room area within the indoor environment. Therefore, in this embodiment, the robot can abandon the use of the watershed algorithm to expand the already marked areas, and instead choose the pixels in the unmarked areas as the starting point for region growth, and start scanning and expanding the unmarked areas. That is, it can discover new water basins in the remaining unmarked areas, avoid repeatedly scanning and expanding the already marked areas, thereby reducing the number of repeated scans and computational overhead of the robot.
[0027] It should be noted that the initial expansion threshold and the expansion threshold are thresholds used to describe the distance (radial distance) between the pixel to be processed and the contour (edge line) of the region to be processed. In this embodiment, grayscale values are used to represent their values. The pixel to be processed includes pixels in the region not marked as the robot's working partition, which can become a new expansion starting point in the watershed algorithm. Before the robot starts to expand the region using the watershed algorithm, the expansion starting point is set. The expansion starting point is a seed element in the watershed algorithm, so that the expansion starting point is updated with pixels in the region not marked as the robot's working partition each time the region is expanded.
[0028] Preferably, the closer the pixel to be processed is to the edge of the map image region to be processed (such as the outline of a wall in a room), that is, the closer the pixel to be processed is to the outline of the environment region where the robot is located, which can also be understood as the farther the pixel to be processed is from the initial expansion starting point, the smaller the expansion threshold is configured by the robot; conversely, the farther the pixel to be processed is from the edge of the map image region to be processed (such as the outline of a wall in a room), that is, the farther the pixel to be processed is from the outline of the environment region where the robot is located, which can also be understood as the closer the pixel to be processed is to the initial expansion starting point, the larger the expansion threshold is configured by the robot. Therefore, each change in the initial expansion threshold by the robot is equivalent to decreasing the initial expansion threshold once, and each change in the expansion threshold by the robot is equivalent to decreasing the expansion threshold once. In this embodiment, after the map image is processed by the watershed algorithm, the grayscale value of pixels farther away from the center point of the image area to be processed (an initial expansion starting point) is smaller, and the grayscale value of pixels closer to the center point of the image area to be processed is larger. Therefore, the method for determining the expansion starting point in this embodiment includes: starting from the outline of the map image, including the wall outline and the outer edge of the obstacle in the map image, calculating the distance between each white pixel (the position point that supports the robot's free passage) on the map image and the black pixel marked by the nearest wall outline or the outer edge of the obstacle in the map image, and then marking the area to be expanded (which can be understood as the initial form of the robot's working area) from the outer outline to the inner area in different position areas according to the gradient change of the above distance, obtaining multiple areas to be expanded. At this time, the center point of each area to be expanded belongs to the corresponding expansion starting point, so there can be multiple expansion starting points in the same map image area to be processed; wherein, each expansion starting point can be understood as the center point of the map area within the corresponding range and the pixel with the highest grayscale value in the corresponding map area.
[0029] In some implementations, if the closer the pixel to be processed is to the center of the robot's current working area, the higher its grayscale value, then the operation configuration for applying a change to the expansion threshold is to decrease the expansion threshold by a gradient change value to meet the threshold requirements for judging the grayscale values of pixels on the contour of the newly expanded area. This allows the watershed algorithm to be used to divide the optimal room area within the corresponding pixel grayscale value distribution environment. The preset termination threshold is less than the initial expansion threshold.
[0030] Preferably, the expansion threshold is configured to be larger by the robot when the pixel to be processed is closer to the edge of the map image region to be processed (such as the outline of a wall in a room), that is, when the pixel to be processed is closer to the outline of the environment region where the robot is located, which can also be understood as the pixel to be processed being further away from the initial expansion starting point; conversely, the expansion threshold is configured to be smaller by the robot when the pixel to be processed is further away from the edge of the map image region to be processed (such as the outline of a wall in a room), that is, when the pixel to be processed is further away from the outline of the environment region where the robot is located, which can also be understood as the pixel to be processed being closer to the initial expansion starting point. Therefore, each change in the initial expansion threshold controlled by the robot is equivalent to increasing the initial expansion threshold once, and each change in the expansion threshold controlled by the robot is equivalent to increasing the expansion threshold once. In this embodiment, after the map image is processed by the watershed algorithm, the grayscale value of pixels farther away from the center point (an expansion starting point) of the image area to be processed is larger, and the grayscale value of pixels closer to the center point of the image area to be processed is smaller. Based on this, the method for determining the expansion starting point includes: starting from the outline of the map image, including the wall outline and the outer edge of the obstacle in the map image, calculating the distance between each white pixel (the position point that supports the robot's free passage) on the map image and the black pixel marked by the nearest wall outline or the outer edge of the obstacle in the map image. Then, based on the watershed algorithm, in different position areas, the area to be expanded (which can be understood as the initial form of the robot's working area) is marked from the inside out according to the gradient of the above distance, obtaining multiple areas to be expanded. At this time, the center point of each area to be expanded belongs to the corresponding expansion starting point. Here, each expansion starting point can be understood as the center point of the map area within the corresponding range.
[0031] In other implementations, if the grayscale value of a pixel is higher the farther it is from the center of the robot's current working area, the operation of changing the expansion threshold is configured to increase the expansion threshold by a gradient change value to meet the threshold requirements for judging the grayscale value of pixels on the contour of the newly expanded area. This allows the watershed algorithm to be used to divide the optimal room area within the corresponding pixel grayscale value distribution environment. The preset termination threshold is greater than the initial expansion threshold.
[0032] Step S105: Control the robot to change the currently obtained expansion threshold once, and update the changed expansion threshold to the currently obtained expansion threshold of the robot. Then return to step S102 until the changed expansion threshold equals the preset termination threshold. When the robot executes to step S105, the watershed algorithm expands the region to the boundary line corresponding to the currently obtained expansion threshold of the robot described in step S102 or step S103. Even if it does not encounter the highest or lowest gray level, it still needs to construct a watershed in the map image to distinguish different regions and mark the currently expanded robot working partition. At this time, the robot does not continue to expand the region under the currently obtained expansion threshold of the robot described in step S102 or step S103, forming a watershed. Until the robot controls the currently obtained expansion threshold of the robot in step S103 to change once in step S105, it returns to execute step S102 and starts to continue expanding the region under the new expansion threshold. This can be understood as continuing to expand on the basis of the currently expanded robot working partition (which may not be connected and are separated by boundary lines), which is equivalent to realizing the expansion of the water basin in the watershed algorithm.
[0033] Step S104: Determine and mark all robot working partitions. That is, when the robot's current expansion threshold equals the preset termination threshold, the robot marks all possible robot working partitions within the image area to be processed. This is equivalent to expanding the corresponding robot working partitions from each expansion starting point using a watershed algorithm, thereby determining the center point and coverage area of each robot working partition. One expansion starting point can correspond to one or more robot working partitions. The number of robot working partitions and the size of their occupied area are related to the robot's current expansion threshold. It should be noted that within the binarized map image, in step S104, the robot can form a marked robot working partition from each individual connected region composed of non-black pixels. The marked connected regions within each robot working partition can be understood as regions surrounded by pixels with lower grayscale values or regions surrounded by pixels with higher grayscale values.
[0034] Therefore, when the robot detects in step S102 that the currently obtained expansion threshold is equal to the preset termination threshold, the robot executes step S104. Specifically, the robot stops using the watershed algorithm to expand the region, stops marking the robot's working partitions, and confirms that all robot working partitions have been marked. When the robot detects in step S102 that the currently obtained expansion threshold is not equal to the preset termination threshold, the robot executes step S103. Specifically, the robot continues to use the watershed algorithm to expand the region and marks the robot's working partitions according to the repetition of the region expansion until the gray value of the pixel on the contour of the latest expanded region is equal to the latest changed expansion threshold. Then, the robot controls the currently obtained expansion threshold to change once, updates the changed expansion threshold to the currently obtained expansion threshold, and returns to step S102 to determine whether to continue using the watershed algorithm for region expansion. Compared with the prior art, this embodiment controls the threshold to change continuously during the process of dividing the map region by executing the watershed algorithm, limiting the number of divisions of the watershed algorithm to ensure the working efficiency of the robot. Under each threshold condition, it decides whether to mark the new region as a newly added robot working partition based on whether the newly generated region contains the old region that has already been marked, thereby reducing the computational overhead of the robot on the map region that is built in a timely manner and enhancing the real-time performance of the robot's navigation movement.
[0035] Based on the embodiments described in steps S101 to S105 above, and based on the same watershed algorithm, the region processing method includes: the robot can simultaneously start from each initial expansion point, use the watershed algorithm to expand the region within a preset map image, and mark the robot's working partitions according to the repetition of the region expansion, until the gray value of the pixels on the contour of the expanded region corresponding to each expansion point is equal to the expansion threshold currently obtained by the robot, and mark multiple new robot working partitions at once within the same map image. Then, the robot controls the expansion threshold to change once and updates the changed expansion threshold to the expansion threshold currently obtained by the robot. Based on the area expanded from each expansion starting point, the watershed algorithm is used to continue expanding the area within the preset map image. According to the repetition of the area expansion, multiple robot working partitions are marked within the preset map image until the gray value of the pixels on the contour of the area expanded from each expansion starting point is equal to the expansion threshold currently obtained by the robot. This is understood as reaching the boundary line (watershed line) where at least two robot working partitions (areas expanded from two different expansion starting points under the same expansion threshold) intersect. Thus, robot working partitions are expanded at different locations simultaneously to achieve multiple robot working partitions expanded at once. This process is repeated until the latest changed expansion threshold is equal to the preset termination threshold, at which point the watershed algorithm is stopped for area expansion, and all robot working partitions are marked within the preset map image.
[0036] When the robot performs step S104, refer to Figures 2(a), 2(b), 2(c) and Figure 3 It can be seen that the region processing method described in the foregoing embodiments is used to obtain... Figure 3 The map area mentioned above also marks all robot work zones, corresponding to... Figure 3All the white connected regions within the figure are the segmentation results marked by the watershed algorithm after the expansion threshold has undergone one round of expansion loops from the initial value to the preset termination threshold. They are also expanded sequentially from the white connected regions (white connected areas in the figures) in Figures 2(a), 2(b), and 2(c). Each white connected region can represent a robot working area, a room area, or at least determine its distribution area and even its center point. Specifically, the expansion threshold of the white connected regions in Figure 2(b) changes once compared to the white connected regions in Figure 2(a), and the number of white connected regions in Figure 2(b) is greater than the number of white connected regions in Figure 2(a). Each white connected region is not connected to each other, and each white connected region has a corresponding expansion starting point. The area of some white connected regions in Figure 2(b) is larger than the area of the white connected regions in Figure 2(a) with the same expansion starting point. Similarly, the white connected regions in Figure 2(c) undergo a new change in expansion threshold compared to the white connected regions in Figure 2(b), exposing new white connected regions. The number of white connected regions in Figure 2(c) is greater than that in Figure 2(b). Some of these white connected regions are interconnected. The area of a portion of the white connected regions in Figure 2(c) is larger than the area of the white connected regions in Figure 2(b) at the same expansion starting point. For Figure 3 The white connected regions are expanded by a threshold change to a preset termination threshold. White connected regions are then exposed within the new location area. Based on these white connected regions, the positions and outlines of all robot work zones are determined. That is, the robot work zones are expanded according to the expansion threshold of all collected values, transforming them into room areas within the actual environment where the robot is located. At least the center point of each room area can be distinguished. Figure 3 The number of white connected regions in Figure 2(c) is greater than the number of white connected regions in Figure 2(c), and most of the white connected regions are interconnected. Figure 3 The area of all white connected regions in Figure 2(c) is larger than the area of the white connected regions with the same expansion start point. In summary, this embodiment achieves one-time detection and segmentation of different local regions within the same map image, reducing the number of repeated scanning calculations. At the same time, by continuously adjusting the expansion threshold (changing from the initial value to the preset termination threshold), the area not mined by the watershed algorithm under a single threshold condition is reduced. Thus, all marked robot working areas can be combined into the robot's overall working area, which can reflect the approximate location of each room area in the indoor environment where the robot is located.
[0037] It should be noted that the watershed algorithm is an image region segmentation method. During the segmentation process, it uses the similarity between neighboring pixels as an important reference, thereby connecting pixels that are spatially close and have similar gray values to form a closed contour. Closure is an important feature of the watershed algorithm.
[0038] It should be noted that Figure 2 and Figure 3 The map can be a binarized laser map, where marked black pixels can represent isolated obstacles as well as continuous obstacles (such as walls); white pixels in the binarized laser map represent map areas not occupied by other objects or landmarks. When the binarized laser map is a raster map, the raster corresponding to a black pixel represents a raster area marked with obstacle information, and the raster corresponding to a white pixel represents an empty raster area without any information.
[0039] As one embodiment, the method for marking robot work zones based on the repetitiveness of region expansion includes: specifically, during the robot's execution of the aforementioned step S103, if it is determined that there is a marked traversable connected region within the newly expanded effective region, then the marked traversable connected region is determined to be a part of the already marked robot work zone. This can be a region connected to the already marked robot work zone. In the actual environment, the newly expanded effective region includes a part of the previously expanded room region and the newly expanded unmarked room region. The newly expanded region includes at least the corresponding new room region and the expansion starting point of the old room region (which can be understood as the center position point of the robot work zone). However, the robot cannot mark the marked traversable connected region as a new robot work zone, and the pixels inside it cannot be used for the next region expansion. Specifically, it cannot be called by the watershed algorithm, so it is impossible to expand the new basin in the watershed algorithm in the neighborhood of the pixel, forming a non-growing pixel. Specifically, the region formed between the contour of the newly expanded region and the contour of the previously expanded region is the newly expanded effective region, making the contour of the newly expanded region the outer contour of the newly expanded effective region relative to the initial expansion point. This ensures region expansion coverage while avoiding repeated scanning and expansion of already marked areas, thereby reducing the number of robot scans and computational overhead.
[0040] Based on the above embodiments, if the robot determines that there is a marked expansion starting point within the newly expanded effective region, it determines that there is a marked passable connected region within the newly expanded effective region, which can cover the effective region expanded before the latest expansion threshold change. The marked expansion starting point can be an expansion starting point determined by the robot during the execution of step S101 or a pixel in the neighborhood of that expansion starting point. It should be noted that during the region expansion using the watershed algorithm, the neighborhood points of the initial expansion starting point determined in step S101 can be updated to new expansion starting points to maintain a new region expansion, regardless of whether the initial expansion threshold has changed. It should be noted that in this embodiment, the region number corresponding to the region expanded by the watershed algorithm is identified, especially the region number that can be marked as the robot's working partition and the gray value of the corresponding pixel in the region, which is the set of pixels corresponding to a specific gray value in a specific region. Preferably, a correspondence is established between the region number and the expansion starting point, so that each expansion starting point is matched with a region number. Therefore, each of the aforementioned passable connected components is assigned a unique identifier to facilitate the sequential detection of each pixel within each passable connected component under a certain extended threshold.
[0041] It should be noted that a connected region is a set of pixels consisting of adjacent pixels with the same pixel value. Therefore, a traversable connected region is a set of pixels consisting of adjacent pixels that are not black (grayscale value greater than 0). In the accompanying drawings, this is schematically represented by white connected regions. The grayscale value of each pixel within the traversable connected region is equal; or, the grayscale value of each pixel on the outline of each expanded region is equal; wherein each expanded region includes a portion of the marked robot working area, a region connected to the marked robot working area, and / or a newly generated connected region. Preferably, the previously expanded region and the latest expanded effective region are connected.
[0042] Based on the aforementioned embodiments, the method for marking robot work partitions according to the repetitiveness of region expansion further includes: if the robot determines that there is a traversable connected region in the newly expanded effective region that does not overlap with the marked traversable connected region, then the traversable connected region that does not overlap with the marked traversable connected region is marked as a robot work partition and stored in the work area list storage space, so that each expansion threshold corresponds to a robot work partition; wherein, the traversable connected region that does not overlap with the marked traversable connected region is, relative to the marked traversable connected region, a newly added room area of the robot in the map image to be processed, which needs to be saved and given a unique identifier, and can be used as a new expansion starting point in the current region expansion, that is, the seed element required by the watershed algorithm in the region expansion, so as to realize the expansion using the watershed algorithm until the gray value is the expansion threshold after the latest change. In this process, the corresponding unmarked pixels and their corresponding connected regions need to be added to the work area list storage space so as to determine whether the pixels belong to the marked ones later. Connected regions include, but are not limited to, four-connected neighborhoods and nine-connected neighborhoods that support robot passage. When a passable connected region is marked as a robot working partition, each pixel in the passable connected region is marked as belonging to the robot working partition. If there are pixels belonging to the marked region in the newly expanded effective area, it means that there is a marked passable connected region in the newly expanded effective area.
[0043] It should be noted that the working area list storage space can be a temporary queue or other data structure used to store seed elements. It can identify the region number, grayscale value, corresponding expansion threshold (equivalent to representing a specific grayscale level in a specific region), or initial expansion threshold of a pixel. Preferably, the working area list storage space may contain pixels with different grayscale values between 0 and 255. Image points from the same region constitute the working area list storage space, and the working area list storage space stores labeled pixels (carrying region numbers). Thus, the corresponding expansion threshold and the robot working partition it points to can be obtained from the working area list storage space.
[0044] It should be noted that a work area list storage space can store the pixels that make up a room area in the actual environment, all of which come from a catch basin (connected component) in the watershed algorithm. Preferably, for the several expansion starting points initially set by the robot in step S101, each expansion starting point corresponds to a catch basin, then the number of work area list storage spaces created is equal to the number of expansion starting points set in step S101.
[0045] As one embodiment, the method of using the watershed algorithm for region expansion includes: when the robot configures the currently obtained expansion threshold to decrease by one time, specifically when the expansion threshold decreases by one time according to the preset gradient value, starting from the expansion starting point, the region is expanded outward in descending order of grayscale values, such that the farther the distance of a pixel on the contour of the region expanded with the expansion starting point as the center point is from the expansion starting point, the smaller the grayscale value of that pixel; when the grayscale value of a pixel on the contour of the latest expanded region is equal to the currently decreased expansion threshold, it is determined that the region is expanded from the starting point... The point has been expanded to the watershed position; then the robot controls the currently decreasing expansion threshold to continue decreasing once according to the preset gradient value, and then expands the region from the new expansion starting point until the gray value of the pixel on the outline of the latest expanded region is equal to the latest decreased expansion threshold (updated by subtracting the preset gradient value from the current decreased expansion threshold). It is determined that the expansion has expanded to the position of the new watershed from the expansion starting point. The new expansion starting point is a pixel that was not assigned to the robot's working partition in the previous expansion, which serves as the seed element for the new region expansion. It is worth noting that during the expansion process corresponding to each expansion threshold, the labeled connected components are detected in the corresponding connected components to reduce the number of repeated scanning expansions. Unlabeled pixels are selected as new expansion starting points for the current region expansion, promoting the growth of the region, including the expansion of labeled robot working areas. This process is repeated until the latest reduced expansion threshold decreases to the preset termination threshold, preferably a value of 0, at which point the expansion of the region stops. The robot then marks all possible robot working areas within the image region to be processed, adapting to the characteristic that pixels farther from the center point of the image region to be processed have smaller gray values, and pixels closer to the center point of the image region to be processed have larger gray values. Thus, in an indoor environment, all possible robot working areas are marked according to the contour distribution characteristics of the room area, since the contour of the room area is a continuous obstacle composed of walls, and its image is represented by pixels with low gray values (generally values of 0).
[0046] It should be noted that in this embodiment, the watershed algorithm is a method based on mathematical morphology. Any image can be viewed as a map, and the gray value of each pixel represents the distance between that pixel and the outline of the room area to be divided in the indoor environment (belonging to the wall outline or the nearest wall-adjacent obstacle). The main purpose of the watershed algorithm is to find the dividing line between different areas in the indoor environment, which corresponds to the boundary line between different areas. The basic principle of the watershed algorithm is: to measure each pixel with a gray value that decreases with a certain gradient value. When pixels in different areas are measured, the gray level of the pixels that make up the same robot working area is sorted from high to low according to the gradient change law of the distance between each white pixel in the map image and the pixel corresponding to the edge of the nearest obstacle. Therefore, the distance between the white pixel and the pixel corresponding to the edge of the nearest obstacle shows a decreasing trend, and the gray level contour line of the white pixel shows a decreasing trend. In each expanded region, the contour formed by pixels with the same gray value is expanded by the contour formed by pixels with a higher gray value, specifically by the neighborhood expansion of the pixels on the contour; and the contour formed by pixels with the same gray value is surrounded by the contour formed by pixels with a lower gray value.
[0047] As one embodiment, when the robot configures the currently obtained expansion threshold to increase once, specifically, when the expansion threshold increases once according to the preset gradient value, starting from the expansion starting point, the region expands outward in order of grayscale values from low to high. This ensures that the farther the distance of a pixel on the outline of the region expanded from the expansion starting point is relative to the expansion starting point, the larger the grayscale value of that pixel. When the grayscale value of a pixel on the outline of the latest expanded region is equal to the robot's currently increased expansion threshold, it is determined that the region has expanded to the watershed position from the expansion starting point. Then, the robot's currently increased expansion threshold continues to increase once according to the preset gradient value, and pixels not assigned to the corresponding robot working partition are used to update the expansion starting point. The region is then expanded from the new expansion starting point until the grayscale value of a pixel on the outline of the latest expanded region is equal to the latest increased expansion threshold (obtained by subtracting the preset gradient value from the robot's currently increased expansion threshold), and it is determined that the region has expanded to the new watershed position from the expansion starting point. It is worth noting that during the expansion process corresponding to each expansion threshold, the marked connected components are detected in the corresponding connected components to reduce the number of repeated scans for expansion. Unmarked pixels are selected as new expansion starting points for the current region expansion, promoting the growth of the region, including the expansion of marked robot working areas. This process is repeated until the latest decreasing expansion threshold increases to the preset termination threshold, preferably a value of 255, at which point the expansion of the region stops, and the robot marks all possible robot working areas within the image region to be processed. It should be noted that in this embodiment, the watershed algorithm is a method based on mathematical morphology. Any image can be regarded as a map, and the gray value of each pixel represents the distance between the pixel and the outline of the room area to be divided (belonging to the wall outline or the nearest wall-adjacent obstacle). The main purpose of the watershed algorithm is to find the watershed line between each region, which corresponds to the boundary line between each region. The basic principle of the watershed algorithm is as follows: Each pixel is measured using a grayscale value that increases with a certain gradient. When pixels in different regions are measured, the grayscale levels of pixels forming the same robot working area are sorted from low to high according to the negative correlation between the gradient change of the distance between each white pixel in the map image and the pixel corresponding to the nearest obstacle edge. Therefore, the distance between a white pixel and the pixel corresponding to its nearest obstacle edge decreases, and the contour lines of the grayscale level of the white pixel increase. Specifically, within each expanded region, the contour formed by pixels with the same grayscale value is expanded from the contour formed by pixels with lower grayscale values, and the contour formed by pixels with the same grayscale value is surrounded by the contour formed by pixels with higher grayscale values.
[0048] Preferably, the newly generated connected component is a traversable connected component that does not overlap with the already marked traversable connected components. The newly generated connected component is not connected to the already marked robot work areas, ensuring that the newly marked robot work areas are not connected to the already marked robot work areas. In this preferred embodiment, starting from an expansion starting point, the influence area is expanded outwards within the map region according to the grayscale values of the set pixels in the same direction of change. When the expansion threshold after the latest change equals the preset termination threshold, at least two corresponding areas expanded from the expansion starting points intersect to form a watershed boundary. This results in two robot work areas being marked as disconnected, thus constructing a reasonable watershed to accurately distinguish different room areas within the map image, enhancing the watershed algorithm's edge detection capability for room areas (robot work areas).
[0049] 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 robot region processing based on a changing threshold, characterized in that, The region processing method includes: The robot uses the watershed algorithm to expand the region until the gray value of the pixels on the contour of the newly expanded region equals the initial expansion threshold. The robot then marks the working area and controls the initial expansion threshold to change once. The changed initial expansion threshold is then updated to the expansion threshold. When the current expansion threshold obtained by the robot is equal to the preset termination threshold, stop using the watershed algorithm to expand the region and determine that all robot working areas have been marked. When the current expansion threshold obtained by the robot is not equal to the preset termination threshold, the watershed algorithm is used to continue to expand the region, and the robot's working partition is marked according to the repetition of the region expansion, until the gray value of the pixel on the outline of the latest expanded region is equal to the current expansion threshold. Then, the current expansion threshold obtained by the robot is controlled to change once, and the changed expansion threshold is updated to the current expansion threshold obtained by the robot. Before starting the region expansion using the watershed algorithm, an expansion starting point is set. The expansion starting point is a seed element in the watershed algorithm, so that each time the region is expanded, the expansion starting point is updated using the pixels in the region not marked as the robot's working partition. Both the initial expansion threshold and the expansion threshold are thresholds used to describe the distance between the pixel to be processed and the contour of the environment area where the robot is located, and are represented by grayscale values; where the pixel to be processed includes pixels in the area not marked as the robot's working area; When the pixel to be processed is closer to the outline of the environment area where the robot is located, controlling the initial expansion threshold to change once is controlling the initial expansion threshold to decrease once, and controlling the expansion threshold currently obtained by the robot to change once is controlling the expansion threshold currently obtained by the robot to decrease once. The preset termination threshold is less than the initial expansion threshold.
2. The region processing method according to claim 1, characterized in that, The method for marking robot work zones based on the repeatability of region expansion includes: If it is determined that there is a marked traversable connected region within the newly expanded effective area, then the marked traversable connected region is determined to be part of the already marked robot working partition, but the marked traversable connected region is not marked as a new robot working partition. The region formed between the outline of the newly expanded region and the outline of the previously expanded region is the newly expanded effective region.
3. The region processing method according to claim 2, characterized in that, If it is determined that there is a marked starting point in the newly expanded effective region, then it is determined that there is a marked traversable connected component in the newly expanded effective region.
4. The region processing method according to claim 3, characterized in that, The method for marking robot work zones based on the repeatability of region expansion further includes: If it is determined that there is a traversable connected region in the newly expanded effective area that does not overlap with the marked traversable connected regions, then the traversable connected region that does not overlap with the marked traversable connected regions is marked as a new robot working partition and stored in the working area list storage space. Specifically, when a passable connected region is marked as a robot working partition, each pixel within that passable connected region is marked as belonging to that robot working partition.
5. The region processing method according to claim 4, characterized in that, Methods for expanding a region using the watershed algorithm include: When the expansion threshold obtained by the control robot changes once, it means that the expansion threshold obtained by the control robot decreases once. The expansion area is sorted outward according to the gray value from high to low. In each expansion area, the contour formed by pixels with the same gray value is expanded by the contour formed by pixels with a higher gray value, and the contour formed by pixels with the same gray value is surrounded by the contour formed by pixels with a lower gray value.
6. The region processing method according to claim 5, characterized in that, The grayscale value of each pixel within the passable connected region is equal; or, the grayscale value of each pixel on the outline of each expanded region is equal. Each expanded area includes a portion of the already marked robot work zone, the area connected to the already marked robot work zone, and / or the newly generated connected domain.
7. The region processing method according to claim 6, characterized in that, The newly generated connected component is a traversable connected component that does not overlap with the already marked traversable connected components. The newly generated connected component is not connected to the already marked robot work areas, so that the newly marked robot work areas are not connected to the already marked robot work areas.
8. The region processing method according to claim 1, characterized in that, One method to control the expansion threshold to change once is to control the expansion threshold to change once in the same direction according to a preset gradient value; The preset gradient value can be configured to be different, so that the magnitude of the change in the extended threshold is different each time; or, the preset gradient value can be configured to be the same, so that the extended threshold changes according to a fixed gradient value.
9. The region processing method according to claim 8, characterized in that, The preset gradient value is used to limit the number of iterations of the watershed algorithm, thereby constraining the range of the area extended by the robot and the range of the robot's working area. Specifically, when the expansion threshold currently obtained by the control robot changes once, which is equivalent to the expansion threshold currently obtained by the control robot decreasing once, the preset termination threshold is 0.
Citation Information
Patent Citations
Working area expansion method based on laser map, chip and robot
CN111631642A
Laser map region segmentation method
CN111681246A