A method, apparatus and robotic device for region segmentation
By determining the preset rectangular area and intersection points of the region to be segmented, a target segmentation line is generated, which solves the problem that smart home robots cannot accurately segment the target area of the map and achieves accurate segmentation in various scenarios.
Patent Information
- Application Number
- CN202211164291.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2042-09-23
AI Technical Summary
In existing technologies, smart home robots cannot accurately determine the dividing lines when dividing a target area on a map, resulting in their inability to respond to the user's dividing commands.
By determining a preset rectangular region to be segmented, determining the first and second intersection points based on preset positional relationships, generating a preset array, and traversing color value points to determine the target segmentation line.
This technology enables smart home robots to accurately segment areas in various scenarios, ensuring that the dividing lines intersect with the areas and improving the accuracy of segmentation.
Smart Images

Figure CN115641436B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers and home Internet of Things, and particularly relates to a region segmentation method and device and a robot device. BACKGROUND
[0002] With the development of computers and home Internet of Things technology, the computers and home Internet of Things technology are also applied to smart home robots. The smart home robots need to divide a target region on a map when working.
[0003] At present, a smart home robot divides a target region on a map by using a map editing method of a smart home robot. The method comprises the following steps: selecting a target region to be segmented by the smart home robot in a room map, detecting a sliding track on the room map, generating a segmentation line on the target region according to the sliding track, and segmenting the target region into a first sub-region and a second sub-region according to the segmentation line.
[0004] Based on the above method, in the process of generating the segmentation line on the target region according to the sliding track, a rectangular coordinate system needs to be established in the room map region. The rectangular coordinate system can be a view coordinate system of the map. Then, a linear equation corresponding to the gesture segmentation line of the user terminal in the rectangular coordinate system is determined. Then, points between the horizontal coordinate of 0 and the horizontal coordinate of x1 on the linear equation are traversed, and points from the horizontal coordinate of xt to the horizontal coordinate of x1 are traversed. When all the traversed points are consistent with the color value points of the target region, the traversal is stopped. When the number of the traversed points consistent with the color value points of the target region is 2, the segmentation line of the target region is determined. The process of determining the segmentation line is as follows:
[0005] Specifically, the position relationship between the linear equation and the target region is shown in Figure 1 . Figure 1 The points corresponding to the linear equation when the horizontal coordinates are x1 and xt, and four position relationships between the linear equation and the target region are recorded in Figure 1 . The target region is a real region of a room. Here, a rectangular region is taken as an example. The coordinate point (minX, minY) and the coordinate point (maxX, maxY) are the vertices of the rectangular region. Based on Figure 1 , only the first intersection point on the target region can be determined, but the segmentation line cannot be determined based on the first intersection point. Therefore, the smart home robot cannot respond to the segmentation instruction input by the user terminal, so that the smart home robot cannot determine the accurate segmentation line for the target region. SUMMARY
[0006] The present application provides a region segmentation method, device and electronic equipment for determining the segmentation line of a target region to be segmented.
[0007] In a first aspect, the present application provides a region segmentation method, the method comprising:
[0008] obtaining a preset rectangular region corresponding to a region to be segmented;
[0009] determining a first intersection point and a second intersection point on an edge of the preset rectangular region based on a preset positional relationship, and obtaining a preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point, wherein the preset positional relationship is a positional relationship between the preset rectangular region and each preset coordinate point;
[0010] determining a target segmentation line corresponding to the region to be segmented based on the preset array, and segmenting the region to be segmented based on the target segmentation line.
[0011] Through the above method, the preset rectangular region of the region to be segmented is determined, the first intersection point and the second intersection point are determined based on the preset positional relationship between the preset rule region and the preset coordinate point, so that the preset straight line can have two intersection points with the preset rectangular region, and then the target segmentation line corresponding to the region to be segmented is determined based on the color value point, so that the region to be segmented can be segmented, and the intelligent home robot can segment the region to be segmented in multiple scenarios.
[0012] In a possible design, obtaining a preset rectangular region corresponding to a region to be segmented comprises:
[0013] determining a color value identifier of the region to be segmented and calculating a first extreme point and a second extreme point corresponding to the region to be segmented;
[0014] determining a preset rectangular region corresponding to the region to be segmented based on the color value identifier and the first extreme point and the second extreme point.
[0015] Through the above method, the preset rectangular region corresponding to the region to be segmented is determined, and the irregular region is simulated into the preset rectangular region, so that it can be applied to more scenarios, and the determination of the target segmentation line corresponding to the region to be segmented is facilitated.
[0016] In a possible design, determining a first intersection point and a second intersection point on an edge of the preset rectangular region based on a preset positional relationship comprises:
[0017] determining a preset first coordinate point and a preset second coordinate point corresponding to the region to be segmented;
[0018] determining a linear equation based on the preset first coordinate point and the preset second coordinate point;
[0019] a first coordinate point and a second coordinate point of an edge line corresponding to the linear equation and the preset rectangular region are calculated based on the linear equation and the preset rectangular region;
[0020] a first intersection point and a second intersection point on the edge line of the preset rectangular region are determined based on the first coordinate point and the second coordinate point.
[0021] Through the above method, whether the linear equation intersects with the preset rectangular region is determined based on the first coordinate point and the second coordinate point of the linear equation and the preset rectangular region, and the first intersection point and the second intersection point are determined. The preset rectangular region can be segmented based on the first intersection point and the second intersection point, which is beneficial to the segmentation of the to-be-segmented region.
[0022] In a possible design, the preset array corresponding to the to-be-segmented region is obtained based on the first intersection point and the second intersection point, including:
[0023] Each color value point on the preset straight line is traversed based on the first intersection point and the second intersection point.
[0024] A color value point consistent with the color value identifier of the to-be-segmented region is determined, and the color value point consistent with the color value identifier is added to the preset array.
[0025] Through the above method, by comparing whether the color value identifier of the color value point is consistent with the color value identifier of the to-be-segmented region, it is ensured that the target segmentation line determined is within the to-be-segmented region, and the target segmentation line can accurately segment the to-be-segmented region.
[0026] In a possible design, the target segmentation line corresponding to the to-be-segmented region is determined based on the preset array, including:
[0027] In response to the array element in the preset array exceeding a preset threshold, the first element in the preset array is taken as a starting point of the to-be-segmented region, and the last element in the preset array is taken as an end point corresponding to the to-be-segmented region.
[0028] The target segmentation line corresponding to the to-be-segmented region is determined based on the starting point and the end point.
[0029] Through the above method, the starting point and the end point are determined based on the array elements recorded in the preset array. Since the linear equation corresponding to the preset array has two intersection points with the to-be-segmented region, the target segmentation line corresponding to the to-be-segmented region can be determined based on the starting point and the end point in the preset array, thereby realizing the segmentation of the to-be-segmented region.
[0030] In a second aspect, the present application provides a region segmentation device, which comprises:
[0031] obtain a preset rectangular region corresponding to the region to be segmented;
[0032] determine a first intersection point and a second intersection point on an edge of the preset rectangular region based on the preset positional relationship, and obtain a preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point;
[0033] determine a target segmentation line corresponding to the region to be segmented based on the preset array, and segment the region to be segmented based on the target segmentation line.
[0034] In a possible design, the obtaining module is specifically configured to determine a color value identifier of the region to be segmented, and calculate a first extreme point and a second extreme point corresponding to the region to be segmented, and determine a preset rectangular region corresponding to the region to be segmented based on the color value identifier and the first extreme point and the second extreme point.
[0035] In a possible design, the determining module is specifically configured to determine a preset first coordinate point and a preset second coordinate point corresponding to the region to be segmented, determine a linear equation based on the preset first coordinate point and the preset second coordinate point, calculate a first coordinate point and a second coordinate point of an edge line corresponding to the linear equation and the preset rectangular region based on the linear equation and the preset rectangular region, and determine a first intersection point and a second intersection point on the edge line of the preset rectangular region based on the first coordinate point and the second coordinate point.
[0036] In a possible design, the determining module is further configured to traverse each color value point on a preset straight line based on the first intersection point and the second intersection point, determine a color value point consistent with the color value identifier of the region to be segmented, and add the color value point consistent with the color value identifier to a preset array.
[0037] In a possible design, the determining module is further configured to, in response to an array element in the preset array exceeding a preset threshold, take a first element in the preset array as a starting point of the region to be segmented, take a last element in the preset array as an end point corresponding to the region to be segmented, and determine a target segmentation line corresponding to the region to be segmented based on the starting point and the end point.
[0038] In a third aspect, a robot device is provided, including:
[0039] a memory configured to store a computer program;
[0040] A processor is configured to implement the method steps of the region segmentation method when executing a computer program stored in the memory.
[0041] In a fourth aspect, a computer readable storage medium stores a computer program, and the computer program is configured to implement the method steps of the region segmentation method when executed by a processor.
[0042] The technical effects of the first aspect to the fourth aspect and each possible solution of the first aspect can be referred to the technical effect description of the first aspect or the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 A schematic diagram of the position relationship between the linear equation and the target region provided in the present application;
[0044] Figure 2 A flowchart of the method steps of the region segmentation provided in the present application;
[0045] Figure 3 A schematic diagram of the linear segment on the linear equation and the region to be segmented having only one intersection point provided in the present application;
[0046] Figure 4 A schematic diagram of the position relationship between the linear equation and the preset rectangular region provided in the present application;
[0047] Figure 5 A schematic diagram of determining the target segmentation line corresponding to the region to be segmented provided in the present application;
[0048] Figure 6 A structural schematic diagram of the region segmentation device provided in the present application;
[0049] Figure 7 A structural schematic diagram of the robot device provided in the present application. DETAILED DESCRIPTION
[0050] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings. The specific operation methods in the method embodiments can also be applied to the device embodiments or system embodiments. It should be noted that, in the description of the present application, "multiple" is understood as "at least two". The association relationship of the associated objects is described, which means that there can be three relationships, for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone. A and B are connected, which means that A and B are directly connected and A and B are connected through C. In addition, in the description of the present application, "first", "second", etc. are used only for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can it be understood as indicating or implying order.
[0051] In order to determine the segmentation line of the room area on the map, the intelligent home robot can adopt the following manner: in the rectangular coordinate system corresponding to the target area, the point with horizontal coordinate 0 and the point with horizontal coordinate x1 on the linear equation of the gesture segmentation line of the user terminal are determined, and then the points between the horizontal coordinate 0 and the horizontal coordinate x1 on the linear equation are traversed to determine the first intersection point with the target area, and the point with horizontal coordinate xt is traversed to the point with horizontal coordinate x1, and when the traversed point is consistent with the color value point of the target area, the traversal is stopped, and the second intersection point with the target area is determined, and then the first intersection point and the second intersection point are used to determine the segmentation line of the target area. However, based on 1, 2 and 3 in Figure 1 , only the first intersection point on the target area can be determined, and the segmentation line cannot be determined based on the first intersection point, so that the intelligent home robot cannot respond to the segmentation instruction input by the user terminal, resulting in that the intelligent home robot cannot accurately determine the segmentation line.
[0052] The embodiment provides a region segmentation method, which is used for the intelligent home robot to accurately determine the segmentation line and accurately segment the target area based on the segmentation line. The method and the device in the embodiment of the present application are based on the same technical concept. Since the principles of the problems solved by the method and the device are similar, the embodiments of the device and the method can be mutually referred to, and the repeated parts will not be described again.
[0053] The embodiment will be described in detail below with reference to the drawings.
[0054] Referring to Figure 2 , the embodiment provides a region segmentation method, which can determine the segmentation line of the target area and segment the target area based on the segmentation line. The implementation process of the method is as follows:
[0055] Step S21: obtaining a preset rectangular area corresponding to a region to be segmented.
[0056] In order to determine the segmentation line of the to-be-segmented region, the to-be-segmented region needs to be determined first. The to-be-segmented region can be an irregular polygon. In order to accurately cover all cases and scenarios of the to-be-segmented region and avoid being able to determine only one intersection point in the to-be-segmented region, a preset rectangular region corresponding to the to-be-segmented region needs to be obtained.
[0057] Optionally, the determination process of the preset rectangular region is as follows:
[0058] Since the to-be-segmented region is a certain room region on an actual map, different room regions are marked with different color values, and therefore the color value mark of the to-be-segmented region can be determined. The to-be-segmented region is an irregular polygon. In order to determine the preset rectangular region corresponding to the to-be-segmented region, a two-dimensional array corresponding to the to-be-segmented region needs to be determined. The to-be-segmented region can be represented by a two-dimensional array. The method of converting the to-be-segmented region into a two-dimensional array is not described in detail here. In actual application, the smart home robot can convert a one-dimensional array corresponding to the scanned to-be-segmented region into a two-dimensional array.
[0059] After the to-be-segmented region is converted into a two-dimensional array, the first extreme point and the second extreme point corresponding to the to-be-segmented region are calculated based on the two-dimensional array. The preset rectangular region corresponding to the to-be-segmented region can be simulated through the first extreme point and the second extreme point. The first extreme point is represented by (minX, minY), and the first extreme point represents the minimum extreme point corresponding to the to-be-segmented region. The second extreme point is represented by (maxX, maxY), and the second extreme point represents the maximum extreme point corresponding to the to-be-segmented region.
[0060] The above describes an optional method of obtaining a preset rectangular region. When the to-be-segmented region is an irregular region, the preset rectangular region corresponding to the to-be-segmented region can be obtained through the above method. However, the method of obtaining the preset rectangular region is not limited to this.
[0061] Step S22: Determine the first intersection point and the second intersection point on the edge of the preset rectangular region based on the preset position relationship, and obtain the preset array corresponding to the to-be-segmented region based on the first intersection point and the second intersection point.
[0062] After the preset rectangular region corresponding to the to-be-segmented region is determined, the position relationship between the two non-overlapping coordinate points and the preset rectangular region is used to simulate the segmentation line determined by the user end in the actual situation.
[0063] Optionally, the position relationship between the two non-overlapping coordinate points and the preset rectangular region is as follows:
[0064] The corresponding linear equation can be calculated by the preset first coordinate point and the preset second coordinate point. For example, the preset first coordinate point is (2, 3), the preset second coordinate point is (4, 2), the linear equation calculated based on (2, 3) and (4, 2) is y = -0.5x + 4, the preset first coordinate point can be x1, and the preset second coordinate point can be xt. After the linear equation of the two non-overlapping coordinate points is determined, the position relationship between the linear equation and the preset rectangular region can be determined. All position relationships between the linear equation and the preset rectangular region need to be explained as follows. The specific explanation process is as follows: case one: when the linear equation and the preset rectangular region do not exist intersection point, since there is a line segment with x1 and xt as endpoints on the linear equation, x1 and xt are on the linear equation, when the horizontal coordinate of x1 in the rectangular coordinate system is determined, the corresponding vertical coordinate of the horizontal coordinate x1 on the linear equation can be calculated. The first extreme point and the second extreme point corresponding to the preset rectangular region are known, and the position relationship between the above line segment and the preset rectangular region can be determined based on the coordinates of the first extreme point, the second extreme point and the two endpoints. The specific position relationship is as follows:
[0065] When the horizontal coordinate of the endpoint x1 is ≥maxX and the horizontal coordinate of the endpoint xt is ≥maxX, the above line segment is on the right side of the preset rectangular region.
[0066] When the horizontal coordinate of the endpoint x1 is ≤minX and the horizontal coordinate of the endpoint xt is ≤minX, the above line segment is on the left side of the preset rectangular region.
[0067] When the vertical coordinate of the endpoint x1 is ≥maxY and the vertical coordinate of the endpoint xt is ≥maxY, the above line segment is on the lower side of the preset rectangular region.
[0068] When the vertical coordinate of the endpoint x1 is ≤minY and the vertical coordinate of the endpoint xt is ≤minY, the above line segment is on the upper side of the preset rectangular region.
[0069] Among the four position relationships between the line segment and the preset rectangular region described above, the linear equation and the preset rectangular region have no intersection point.
[0070] Case two: when the linear equation and the preset rectangular region have intersection points, there are two coincident intersection points and two non-coincident intersection points. The specific explanation is as follows:
[0071] When the linear equation and the preset rectangular region have a first intersection point, the linear equation only coincides with one of the four vertex coordinates of the preset rectangular region.
[0072] When the linear equation has a first intersection point and a second intersection point with the preset rectangular region, the linear equation has two intersection points with the region to be segmented, or the linear equation has one intersection point with the region to be segmented, or the linear equation has no intersection point with the region to be segmented.
[0073] It should be noted that, in order to determine the intersection between the line segment on the linear equation and the preset rectangular region, the following method can be used to determine:
[0074] In the above description, the first extreme point and the second extreme point of the preset rectangular region have been obtained, and the linear equation, in actual application, in order to determine the positional relationship between the line segment on the linear equation and the preset rectangular region, it is necessary to calculate the y1 corresponding to the ordinate when the abscissa is minX in the linear equation; and calculate the y2 corresponding to the ordinate when the abscissa is maxX in the linear equation; and calculate the a1 corresponding to the abscissa when the ordinate is minY in the linear equation; and calculate the a2 corresponding to the abscissa when the ordinate is maxY in the linear equation.
[0075] After determining the above y1, y2, a1, a2, if y1≥minY and y1≤maxY, it represents that the linear equation intersects on the left side of the preset rectangular region;
[0076] If a1≥minX and a1≤maxX, it represents that the linear equation intersects on the top side of the preset rectangular region;
[0077] If y2≥minY and y1≤maxY, it represents that the linear equation intersects on the right side of the preset rectangular region;
[0078] If a2≥minX and a2≤maxX, it represents that the linear equation intersects on the bottom side of the preset rectangular region.
[0079] Based on the above method, the intersection between the line segment and the preset rectangular region can be determined, when the linear equation has one intersection point with the region to be segmented, the specific description is as follows:
[0080] The schematic diagram of the line segment on the linear equation and the region to be segmented having only one intersection point is shown in Figure 3 In Figure Three , for the schematic diagram in Figure 3 , Figure 1 When x1>x2 and start x<end x, there are two intersection points, if end x>x1, it represents that xt is in the preset rectangular region, or if start x<x2, it represents that x1 is in the preset rectangular region;
[0081] For the schematic diagram in Figure 3 , Figure 2When x1>x2, and start x>end x, there are two intersection points, if start x>x1, it represents that xt is in the preset rectangular region, or if end x<x2, it represents that x1 is in the preset rectangular region;
[0082] For the schematic diagram in Figure 3 Figure 3 When x1<x2, and start x>end x, there are two intersection points, if end x<x1, it represents that xt is in the preset rectangular region, or if start x>x2, it represents that x1 is in the preset rectangular region.
[0083] For the schematic diagram in Figure 3 Figure 4 When x1<x2, and start x>end x, there are two intersection points, if end x<x1, it represents that xt is in the preset rectangular region, or if start x>x2, it represents that x1 is in the preset rectangular region.
[0084] When the line segment with x1 and xt as end points meets any one of the above four conditions, it represents that a certain end point of the target split line is in the room, and the determination result is that the target split line has only one intersection point with the region to be split.
[0085] The above has determined that the target split line has only one intersection point with the region to be split, which can be a coincident intersection point. After determining that the linear equation has a first intersection point and a second intersection point with the preset rectangular region, in order to ensure that the two intersection points of the linear equation and the region to be split are on the edge of the region to be split, all points between the first intersection point and the second intersection point on the linear equation can be traversed. When a point consistent with the color value identifier of the region to be split is not traversed, it represents that the linear equation does not intersect the region to be split; when a point consistent with the color value identifier of the region to be split is traversed, it is necessary to determine whether it is a coincident two intersection points, if not, the two intersection points of the linear equation and the region to be split are determined.
[0086] Based on the above description, when the linear equation has two intersection points with the region to be split, the region to be split can be successfully split, therefore, the preset position relationship in the embodiment of the application represents the case that the linear equation has two intersection points with the region to be split, in some embodiments, the preset position relationship schematic diagram corresponding to the linear equation and the preset rectangular region is as shown in Figure 4 , in Figure 4 , the region to be split is a rhombus in the preset rectangular region, the line segment on the linear equation is a dashed line in Figure 4 , x1 and xt are end points of the line segment, x1 is also a preset first coordinate point, xt is also a preset second coordinate point, x1 and xt are used to simulate the end points of the split line determined by the user end, in Figure 4 The line segment and the preset rectangular region are different positions, and the intersection points of the line segment and the preset rectangular region are respectively the first intersection point and the second intersection point.
[0087] Based on the above description, based on the preset first coordinate point and the preset second coordinate point, the linear equation is calculated, and the first coordinate point and the second coordinate point can be calculated based on the first extreme point and the second extreme point of the preset rectangular region and the linear equation. The first coordinate point and the second coordinate point are outside the preset rectangular region. When it is determined that there are two intersection points outside the preset rectangular region, the first intersection point and the second intersection point on the edge line of the preset rectangular region can also be determined. For Figure 4 Any one of the above cases, the first intersection point and the second intersection point of the line segment intersecting the preset rectangular region on the linear equation can be determined according to the method described above.
[0088] Based on the above method, the case that the linear equation does not have two intersection points with the region to be divided is excluded, and all cases that the linear equation has two intersection points with the preset rectangular region and the region to be divided are determined. Avoiding the segmentation of the region to be divided based on the determined segmentation line, thereby ensuring that the region to be divided can be successfully segmented. After determining the first intersection point and the second intersection point of the linear equation and the preset rectangular region, since the first intersection point and the second intersection point are on the preset straight line, which is the linear equation, all pixel points between the first intersection point and the second intersection point on the linear equation can be traversed. The pixel points with the same color value as the color value of the region to be divided are added to the preset array.
[0089] Based on the above method, the first intersection point and the second intersection point corresponding to the preset rectangular region are determined, which are on the linear equation, and the pixel points outside the region to be divided and the pixel points inside the region to be divided are determined by traversing the pixel points with the same color value as the color value of the region to be divided.
[0090] Step S23: determining a target segmentation line corresponding to the region to be divided based on the preset array, and segmenting the region to be divided based on the target segmentation line.
[0091] Since the pixel points between the first intersection point and the second intersection point in the linear equation with the same color value as the color value of the region to be divided are recorded in the preset array, the segmentation line of the region to be divided can be determined by reading the pixel points recorded in the preset array. First, it can be detected whether the array element in the preset array exceeds the preset threshold. When the array element in the preset array exceeds the preset threshold, the first element in the array element is taken as the starting point of the region to be divided, and the last element in the array element is taken as the termination point corresponding to the region to be divided.
[0092] After the starting point and the ending point are determined, the segmentation line corresponding to the region to be segmented can be determined based on the starting point and the ending point, and the segmentation line is taken as a target segmentation line. After the target segmentation line is determined, the smart home sweeping robot can segment the region to be segmented based on the target segmentation line, thereby realizing successful segmentation of the region to be segmented based on the target segmentation line.
[0093] It should be noted that the schematic diagram of the target segmentation line corresponding to the region to be segmented provided in the embodiments of the present application is as shown in Figure 5 After the first intersection point and the second intersection point in the preset rectangular region are determined, the target segmentation line corresponding to the region to be segmented can be determined based on the method described above, Figure 5 The case 7 in Figure 4 is only taken as an example. The process of determining the target segmentation line corresponding to the region to be segmented based on other preset segmentation lines refers to the examples in Figure 5 Since the process of determining the target segmentation line is consistent, it is not described in detail here.
[0094] Based on the above method, the preset rectangular region is determined through the color value identification of the region to be segmented, the first intersection point and the second intersection point of the preset rectangular region are determined, and the target segmentation line corresponding to the region to be segmented is determined by traversing the color value points between the first intersection point and the second intersection point. It is ensured that the target segmentation line has two intersection points with the region to be segmented, and can cover multiple scenarios, so that the smart home robot can accurately determine the target segmentation line of the region to be segmented.
[0095] Based on the same inventive concept, the embodiments of the present application also provide a region segmentation device for realizing the functions of the region segmentation method. Referring to Figure 6 , the device comprises:
[0096] The obtaining module 601 is configured to obtain a preset rectangular region corresponding to a region to be segmented.
[0097] The determining module 602 is configured to determine a first intersection point and a second intersection point on the edge of the preset rectangular region based on a preset position relationship, and obtain a preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point.
[0098] The target module 603 is configured to determine a target segmentation line corresponding to the region to be segmented based on the preset array, and segment the region to be segmented based on the target segmentation line.
[0099] In a possible design, the obtaining module 601, in particular, is configured to determine a color value identifier of the region to be segmented, and calculate a first extreme point and a second extreme point corresponding to the region to be segmented, and determine a preset rectangular region corresponding to the region to be segmented based on the color value identifier and the first extreme point and the second extreme point.
[0100] In a possible design, the determining module 602, in particular, is configured to determine a preset first coordinate point and a preset second coordinate point corresponding to the region to be segmented, determine a linear equation based on the preset first coordinate point and the preset second coordinate point, calculate a first coordinate point and a second coordinate point of an edge line corresponding to the preset rectangular region based on the linear equation and the preset rectangular region, and determine a first intersection point and a second intersection point on the edge line of the preset rectangular region based on the first coordinate point and the second coordinate point.
[0101] In a possible design, the determining module 602 is further configured to traverse each color value point on a preset straight line based on the first intersection point and the second intersection point, determine a color value point consistent with the color value identifier of the region to be segmented, and add the color value point consistent with the color value identifier to a preset array.
[0102] In a possible design, the determining module 602 is further configured to, in response to an array element in the preset array exceeding a preset threshold, take a first element in the preset array as a starting point of the region to be segmented, take a last element in the preset array as an end point corresponding to the region to be segmented, and determine a target segmentation line corresponding to the region to be segmented based on the starting point and the end point.
[0103] Based on the same inventive concept, the embodiment of the present application further provides a robot device, which can implement the function of the foregoing region segmentation device, refer to Figure 7 , the robot device comprises:
[0104] at least one processor 701 and a memory 702 connected with the at least one processor 701, and the specific connection medium between the processor 701 and the memory 702 is not limited in the embodiment of the present application, Figure 7 in the embodiment of the present application, the connection between the processor 701 and the memory 702 is taken as an example connected through a bus 700. The bus 700 is represented by a thick line in Figure 7 , the connection mode between other components is only schematically illustrated, and is not limited. The bus 700 can be divided into an address bus, a data bus, a control bus, etc., for the convenience of representation, Figure 7Only one bus is shown for simplicity, but there can be more buses or more types of buses. The processor 701 can also be referred to as a controller, without limiting the name.
[0105] In the embodiment of the present application, the memory 702 stores instructions executable by the at least one processor 701, and the at least one processor 701 can execute the foregoing method for region segmentation by executing the instructions stored in the memory 702. The processor 701 can implement Figure 6 the functions of the various modules of the apparatus shown.
[0106] The processor 701 is the control center of the apparatus, and can connect all parts of the apparatus through various interfaces and lines, and monitor the whole apparatus by running or executing instructions stored in the memory 702 and calling data stored in the memory 702, thereby processing data and performing various functions of the apparatus.
[0107] In a possible design, the processor 701 can include one or more processing units, and the processor 701 can integrate an application processor and a modem processor, where the application processor mainly processes operating systems, user interfaces, and application programs, and the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor can also not be integrated into the processor 701. In some embodiments, the processor 701 and the memory 702 can be implemented on the same chip, and in some embodiments, they can also be implemented on separate chips respectively.
[0108] The processor 701 can be a general-purpose processor, for example, a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, and can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method for region segmentation disclosed in conjunction with the embodiments of the present application can be directly embodied as execution completed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0109] The memory 702, as a non-volatile computer readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 702 can include at least one type of storage medium, for example, can include flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. The memory 702 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited to this. The memory 702 in the embodiments of the present application can also be a circuit or any other device capable of realizing a storage function, used to store program instructions and / or data.
[0110] By designing and programming the processor 701, the code corresponding to the method of region segmentation introduced in the foregoing embodiments can be fixed in the chip, so that the chip can execute the steps of the method of region segmentation of the embodiments shown in the running time. Figure 1 How to design and program the processor 701 is a technology known to those skilled in the art, and will not be described here.
[0111] Based on the same inventive concept, the embodiments of the present application also provide a storage medium storing computer instructions, when the computer instructions run on a computer, the computer executes the method of region segmentation discussed above.
[0112] In some possible implementation, the various aspects of the method for region segmentation provided by the present application can also be implemented as a program product in the form of a computer program code, which, when run on an apparatus, is used to cause the control device to perform the steps of the method for region segmentation according to various exemplary embodiments of the present application described above in the specification. Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can be in the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can be in the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.
[0113] The present application is described with reference to the flowcharts and / or block diagrams of the method, device (system), and computer program product according to the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as a combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus generate a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure One The flow or multiple flows and / or blocks Figure One The apparatus that performs the functions specified in the flow or multiple flows and / or blocks.
[0114] These computer program instructions can also be stored in a computer-readable memory that can direct the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including instruction apparatus, which implements the functions specified in the flowcharts and / or block diagrams. Figure One The flow or multiple flows and / or blocks Figure One The apparatus that performs the functions specified in the flow or multiple flows and / or blocks.
[0115] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable data processing apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable data processing apparatus provide a means for implementing the functions specified in the flowcharts and / or block diagrams. Figure One The flow or multiple flows and / or blocks Figure One Figure One The apparatus that performs the functions specified in the flow or multiple flows and / or blocks.
[0116] Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.
Claims
1. A method of region segmentation, characterized by, The method comprises the following steps: obtaining a preset rectangular region corresponding to a region to be segmented; determining a first intersection point and a second intersection point on the edge of the preset rectangular region based on a preset position relationship, and obtaining a preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point, wherein the preset position relationship is the position relationship between the preset rectangular region and each preset coordinate point; determining a target segmentation line corresponding to the region to be segmented based on the preset array, and segmenting the region to be segmented based on the target segmentation line; wherein obtaining the preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point comprises: traversing each color value point on a preset straight line based on the first intersection point and the second intersection point; determining a color value point consistent with the color value identifier of the region to be segmented, and adding the color value point consistent with the color value identifier to the preset array; wherein determining the target segmentation line corresponding to the region to be segmented based on the preset array comprises: in response to the number of array elements in the preset array representing the color value point consistent with the color value identifier of the region to be segmented between the first intersection point and the second intersection point exceeding a preset threshold, taking the first element in the preset array as the starting point of the region to be segmented, and taking the last element in the preset array as the terminal point corresponding to the region to be segmented; determining the target segmentation line corresponding to the region to be segmented based on the starting point and the terminal point.
2. The method of claim 1, wherein, obtaining a preset rectangular region corresponding to a region to be segmented comprises: determining the color value identifier of the region to be segmented and calculating the first extreme point and the second extreme point corresponding to the region to be segmented; determining the preset rectangular region corresponding to the region to be segmented based on the color value identifier and the first extreme point and the second extreme point.
3. The method of claim 1, wherein, determining the first intersection point and the second intersection point on the edge of the preset rectangular region based on a preset position relationship comprises: determining a preset first coordinate point and a preset second coordinate point corresponding to the region to be segmented; determining a linear equation based on the preset first coordinate point and the preset second coordinate point; calculating the first coordinate point and the second coordinate point of the edge line corresponding to the linear equation and the preset rectangular region based on the linear equation and the preset rectangular region; determining the first intersection point and the second intersection point on the edge line of the preset rectangular region based on the first coordinate point and the second coordinate point.
4. An apparatus for region segmentation, the apparatus comprising: The method comprises the following steps: an obtaining module is configured to obtain a preset rectangular region corresponding to a region to be segmented; a determining module is configured to determine a first intersection point and a second intersection point on the edge of the preset rectangular region based on a preset position relationship, and obtain a preset array corresponding to the region to be segmented based on the first intersection point and the second intersection point; a target module is configured to determine a target segmentation line corresponding to the region to be segmented based on the preset array, and segment the region to be segmented based on the target segmentation line. The determining module is further configured to traverse each color value point on a preset straight line based on the first intersection point and the second intersection point, determine a color value point consistent with the color value identifier of the region to be segmented, and add the color value point consistent with the color value identifier to a preset array. The determining module is further configured to, in response to an array element in the preset array exceeding a preset threshold, take a first element in the preset array as a starting point of the region to be segmented, take a last element in the preset array as a corresponding terminal point of the region to be segmented, and determine a target segmentation line corresponding to the region to be segmented based on the starting point and the terminal point.
5. The apparatus of claim 4, wherein, The obtaining module is specifically configured to determine a color value identifier of the region to be segmented and calculate a first extreme point and a second extreme point corresponding to the region to be segmented, and determine a preset rectangular region corresponding to the region to be segmented based on the color value identifier and the first extreme point and the second extreme point.
6. The apparatus of claim 4, wherein, The determining module is specifically configured to determine a preset first coordinate point and a preset second coordinate point corresponding to the region to be segmented, determine a linear equation based on the preset first coordinate point and the preset second coordinate point, calculate a first coordinate point and a second coordinate point of an edge line corresponding to the linear equation and the preset rectangular region based on the linear equation and the preset rectangular region, and determine a first intersection point and a second intersection point on the edge line of the preset rectangular region based on the first coordinate point and the second coordinate point.
7. A robotic device, characterized by The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps of any one of claims 1-3. The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps of any one of claims 1-3. 8. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
Land parcel segmentation method and device, electronic device and storage medium
CN110675414A
Map editing method and device of sweeping robot, storage medium and electronic equipment
CN113720337A