Path planning method, device, computer-readable medium, and electronic device
By using a sliding window to match path templates in robot image processing to determine anchor points and generate paths, the problem of traditional robot path planning relying on hardware is solved, achieving more stable and flexible path planning and improving robot working efficiency.
Patent Information
- Application Number
- CN202210498489.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-09
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-05-09
AI Technical Summary
Traditional robot path planning methods rely on hardware devices, resulting in poor stability and flexibility in path planning.
By acquiring the image to be processed in the work area, a sliding window is used to traverse the image and match it with a preset path template to determine the starting anchor point and multiple anchor points, thereby generating the work path.
It eliminates the need for sensors, improving the stability and flexibility of path planning, enhancing anti-interference capabilities, and increasing robot work efficiency.
Smart Images

Figure CN114777792B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image processing and artificial intelligence technology, and specifically relates to a path planning method, apparatus, computer-readable medium and electronic device. Background Technology
[0002] In recent years, products developed based on artificial intelligence technology have gradually entered people's work and lives, not only bringing convenience but also improving work efficiency to some extent. For example, robots are used for lawn maintenance, environmental cleaning, and goods handling. Traditional robot path planning methods involve setting markers along the work path and then attaching sensors to the robot to detect these markers and determine its movement path. This method relies heavily on hardware; if either the sensor or the path markers malfunctions, the robot's path planning will become abnormal, resulting in poor stability and flexibility.
[0003] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0004] The purpose of this application is to provide a path planning method, apparatus, computer-readable medium, and electronic device to solve the problem of poor stability and flexibility in path planning in related technologies.
[0005] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0006] According to one aspect of the embodiments of this application, a path planning method is provided, comprising:
[0007] Acquire the image to be processed in the working area, the image to be processed comprising multiple pixels;
[0008] Based on the pixel values of the plurality of pixels, a starting anchor point is determined from the plurality of pixels;
[0009] The image to be processed is traversed by a sliding window, and the images of each window corresponding to the sliding window during the traversal are matched with a preset path template to obtain the matching anchor points.
[0010] The working path in the working area is generated based on the starting anchor point and the matching anchor point.
[0011] According to one aspect of the embodiments of this application, a path planning apparatus is provided, comprising:
[0012] The image acquisition module is used to acquire the image to be processed in the working area, the image to be processed including multiple pixels;
[0013] The starting anchor point determination module is used to determine the starting anchor point of the sliding window from the plurality of pixels based on the pixel values of the plurality of pixels.
[0014] The window sliding module is used to traverse the image to be processed through a sliding window, and match each window image corresponding to the sliding window during the traversal with a preset path template to obtain the matching anchor point;
[0015] The path generation module is used to generate a working path in the working area based on the starting anchor point and the matching anchor point.
[0016] In one embodiment of this application, the window sliding module includes:
[0017] The sliding window building unit is used to construct a sliding window centered on the starting anchor point.
[0018] The matching unit is used to match the window image corresponding to the sliding window with a preset path template to determine the traversal direction of the sliding window and the next anchor point connected to the center point.
[0019] The judgment unit is used to determine the next anchor point as the next center point of the sliding window when the next anchor point does not coincide with the specified anchor point, and to perform the step of matching the window image corresponding to the sliding window with the preset path template according to the traversal direction; and to stop the sliding of the sliding window when the next anchor point coincides with the specified anchor point.
[0020] Wherein, the designated anchor point includes already determined anchor points; or
[0021] The designated anchor point is a pixel on the edge of the image to be processed.
[0022] In one embodiment of this application, the matching unit is specifically used for:
[0023] The traversal direction of the sliding window is determined based on the center point;
[0024] Obtain multiple preset path templates indicated by the traversal direction;
[0025] The window image corresponding to the sliding window is matched with the multiple preset path templates to obtain the next anchor point connected to the center point.
[0026] In one embodiment of this application, the starting anchor point determination module includes:
[0027] The target pixel acquisition unit is used to acquire target pixels that satisfy a preset pixel threshold from the plurality of pixels;
[0028] The adjacent pixel acquisition unit is used to acquire adjacent pixels of the target pixel from the plurality of pixels;
[0029] The starting anchor point determination unit is used to determine the target pixel as the starting anchor point when the pixel value of the adjacent pixel is not the same as the pixel value of the target pixel.
[0030] In one embodiment of this application, the apparatus further includes:
[0031] A marking unit is used to mark the target pixel.
[0032] The adjacent pixel points acquired by the adjacent pixel point acquisition unit are unmarked pixels.
[0033] In one embodiment of this application, the marking unit is specifically used for:
[0034] Set the pixel value of each target pixel to a preset pixel value;
[0035] Alternatively, each of the target pixels can be marked with an index number.
[0036] In one embodiment of this application, the image acquisition module includes:
[0037] The original image acquisition unit is used to acquire the original image of the working area, wherein the pixel value of each pixel in the original image includes the pixel value of multiple color channels;
[0038] A grayscale image generation unit is used to obtain the average pixel value of the multiple color channels, use the average pixel value as the grayscale value of each pixel, and generate a grayscale image corresponding to the original image based on the grayscale value of each pixel.
[0039] The image generation unit is configured to update the pixel value of any pixel in the grayscale image to a first pixel value when the grayscale value of any pixel in the grayscale image is greater than a preset grayscale pixel threshold; and update the pixel value of any pixel in the grayscale image to a second pixel value when the grayscale value of any pixel in the grayscale image is less than the preset grayscale pixel threshold; and obtain the image to be processed based on each pixel after updating the pixel value.
[0040] According to one aspect of the embodiments of this application, a computer-readable medium is provided, on which a computer program is stored, which, when executed by a processor, implements the path planning method as described in the above technical solutions.
[0041] According to one aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor executes the executable instructions to cause the electronic device to perform the path planning method as described in the above technical solutions.
[0042] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the path planning method as described in the above technical solutions.
[0043] In the technical solution provided in this application embodiment, the starting anchor point of the sliding window is determined from the adjacent pixels of the image to be processed in the working area by acquiring the image to be processed. Then, the sliding window traverses the image to be processed with the anchor point as the center point. Multiple anchor points are obtained by matching each window image with a preset path template during the traversal. This method of determining anchor points by template matching is simple to operate, easy to deploy, and can quickly determine each anchor point during the window traversal, with high efficiency and accuracy. Finally, the working path is generated based on the starting anchor point and the matched anchor points, making the generation of the working path convenient and fast. In addition, this path planning method does not rely on hardware devices such as sensors, which improves the stability and flexibility of path planning and enhances the anti-interference ability of path planning. Furthermore, the image to be processed used to generate the path can be an offline working map, that is, the path can be pre-configured for the robot, eliminating the need for the robot to calculate the path in real time during the working process, thus improving the robot's working efficiency.
[0044] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0046] Figure 1 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0047] Figure 2 A flowchart illustrating a path planning method provided in one embodiment of this application is shown schematically.
[0048] Figures 3A-3B A schematic diagram of the preset path template provided in the embodiments of this application is shown.
[0049] Figure 4 A schematic diagram of an image to be processed provided in one embodiment of this application is shown.
[0050] Figure 5 A schematic diagram of an image to be processed provided in another embodiment of this application is shown.
[0051] Figure 6 A schematic diagram illustrating a working path generation process provided in one embodiment of this application is shown.
[0052] Figure 7 A schematic diagram of an image to be processed provided in yet another embodiment of this application is shown.
[0053] Figure 8 A schematic diagram of the path planning device provided in an embodiment of this application is shown.
[0054] Figure 9 A schematic diagram of a computer system architecture suitable for implementing the embodiments of this application is shown. Detailed Implementation
[0055] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.
[0056] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0057] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0058] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0059] Figure 1 An exemplary system architecture block diagram illustrating the application of the technical solution of this application is shown schematically.
[0060] like Figure 1 As shown, the system architecture 100 may include terminal devices 110, a network 120, and a server 130. Terminal devices 110 may include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, in-vehicle terminals, robots, etc. Server 130 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Network 120 may be a communication medium of various connection types capable of providing a communication link between terminal devices 110 and server 130, such as a wired communication link or a wireless communication link.
[0061] Depending on the implementation requirements, the system architecture in this application embodiment can have any number of terminal devices, networks, and servers. For example, server 130 can be a server group composed of multiple server devices. In addition, the technical solutions provided in this application embodiment can be applied to terminal device 110, or to server 130, or can be implemented jointly by terminal device 110 and server 130. This application does not impose any special limitations on this.
[0062] For example, the path planning method provided in this application embodiment is implemented by server 130. Server 130 acquires an image to be processed in the working area, the image including multiple pixels; the image to be processed can be captured by terminal device 110 and then transmitted to server 130 via network 120. Then, server 130 determines a starting anchor point from the multiple pixels based on the pixel values of adjacent pixels. Next, server 130 traverses the image to be processed through a sliding window, and matches each window image corresponding to the sliding window during the traversal with a preset path template to obtain a matched anchor point as the next center point of the sliding window, and the initial center point of the sliding window as the starting anchor point. Finally, server 130 generates a working path in the working area based on the starting anchor point and the matched anchor points.
[0063] After the server 130 generates the working path, it can send the working path to the terminal device 110, and then the terminal device 110 can move according to the working path. Of course, the path planning method provided in this embodiment can also be implemented by the terminal device 110, that is, the terminal device 110 obtains the image to be processed, performs the above processing to obtain the working path, and then moves according to the working path.
[0064] The path planning method provided in this application will be described in detail below with reference to specific implementation methods.
[0065] Figure 2 A flowchart illustrating a path planning method provided in one embodiment of this application is shown schematically. This method can be implemented by a terminal device, such as... Figure 1 The terminal device 110 shown; this method can also be implemented by a server, such as Figure 1 Server 130 is shown. (As shown) Figure 2 As shown, the path planning method provided in this application embodiment includes steps 210 to 240, as detailed below:
[0066] Step 210: Obtain the image to be processed in the working area. The image to be processed includes multiple pixels.
[0067] Specifically, the image to be processed can be a working map, which is a map of the working area of the terminal device. The following explanation will use a robot as an example of the terminal device. Areas outside the robot's working area on the working map are called non-working areas. The working area can be a lawn mowing robot's work area, a floor cleaning robot's work area, or a mopping robot's cleaning area, etc. Non-working areas can be flower beds, trees, sofas, tables, etc., without limitation.
[0068] In one embodiment of this application, the process of obtaining the image to be processed in the working area includes: obtaining the original image of the working area, wherein the pixel value of each pixel in the original image includes the pixel value of multiple color channels; obtaining the average pixel value of the multiple color channels, and using the average pixel value as the gray value of each pixel; generating a grayscale image corresponding to the original image based on the grayscale value corresponding to each pixel; updating the pixel value of the pixel in the grayscale image to a first pixel value when the grayscale value of any pixel in the grayscale image is greater than a preset grayscale pixel threshold; updating the pixel value of the pixel in the grayscale image to a second pixel value when the grayscale value of any pixel in the grayscale image is less than the preset grayscale pixel threshold; and obtaining the image to be processed based on each pixel after updating the pixel value.
[0069] Specifically, the raw image of the working area refers to the unprocessed image of the working area acquired by the camera device. This acquisition can be done via any method, such as from the user's device, Bluetooth, WiFi, or a local database. Generally, the raw image is a color image. Each pixel in the raw image consists of pixel values from multiple color channels. Each color channel corresponds to a color, and the pixel value of a color channel represents the brightness of that color. For example, if the raw image is an RGB image, then each pixel in the raw image consists of pixel values from three color channels: R (Red), G (Green), and B (Blue). As another example, if the raw image is a CMYK image, then each pixel in the raw image consists of pixel values from four color channels: C (Cyan), M (Magenta), Y (Yellow), and B (Black).
[0070] After obtaining the original image, it is preprocessed to obtain a grayscale image. The pixel value of each pixel in the grayscale image is also called the grayscale value. Therefore, to convert the original image into a grayscale image, it is only necessary to convert the pixel values of each pixel in the original image into grayscale values. In the embodiments of this application, the preprocessing process includes taking the average pixel value of each color channel of a pixel as the grayscale value of that pixel. For example, the original image is an RGB image, and the pixel value of a pixel in the original image includes: R value = 100, G value = 150, B value = 200. Then the grayscale value of that pixel = (100 + 150 + 200) / 3 = 150.
[0071] In one embodiment of this application, the pixel values of each color channel of a pixel can be used as the grayscale value of that pixel. Then, based on the pixel values of the same color channel corresponding to each pixel in the original image, a grayscale image can be obtained. This allows for the generation of multiple grayscale images from the original image, with the number of grayscale images matching the number of color channels of the pixel. Finally, one of these multiple grayscale images can be selected as the desired target grayscale image.
[0072] In one embodiment of this application, one of the pixel values of each color channel of a pixel can be used as the grayscale value of that pixel. For example, the maximum pixel value of each color channel of the pixel can be used as the grayscale value of that pixel. Alternatively, the weighted average pixel value of each color channel of a pixel can be used as the grayscale value of that pixel. That is, a weight is set for each color channel, and then the pixel values of the pixel are summed in a weighted manner based on the weights of each color channel to obtain the grayscale value of the pixel.
[0073] After obtaining the grayscale image, the pixel value of each pixel in the grayscale image is updated according to a preset grayscale pixel threshold. The pixels in the grayscale image are divided into two categories: pixels with a first pixel value and pixels with a second pixel value. In this embodiment, when the grayscale value of a pixel in the grayscale image is greater than the preset grayscale pixel threshold, the pixel value of that pixel is set to the first pixel value; when the grayscale value of a pixel in the grayscale image is less than the preset grayscale pixel threshold, the pixel value of that pixel is set to the second pixel value. The case where the grayscale value of a pixel is equal to the preset grayscale pixel threshold can be categorized as either a grayscale value greater than or less than the preset grayscale pixel threshold based on actual circumstances.
[0074] The grayscale image after pixel value updates is transformed into the image to be processed. In this image, multiple pixels with a first pixel value constitute a first image region, and multiple pixels with a second pixel value constitute a second image region. These two different image regions actually correspond to the robot's working area and non-working area on the work map, respectively, indicating that the image to be processed achieves the division of the working and non-working areas on the work map. For example, if the first pixel value is 0 and the second pixel value is 255, the image to be processed is represented as a black and white image; if white represents the working area, then black represents the non-working area.
[0075] Step 220: Determine the starting anchor point from the multiple pixels based on the pixel values of adjacent pixels.
[0076] Specifically, by identifying the pixel values of adjacent pixels of any pixel in the image to be processed, it can be determined whether the pixel is a pixel in the working area, a pixel in the non-working area, or a pixel on the boundary between the working and non-working areas. When a pixel is identified as a pixel on the boundary between the working and non-working areas, this pixel is used as the starting anchor point of a sliding window. This sliding window is used to slide across the image to determine multiple anchor points after the starting anchor point. The anchor point of the sliding window refers to the center point of the sliding window; therefore, the starting anchor point is the center point of the first sliding window, which can also be considered the starting point of the sliding window.
[0077] In one embodiment of this application, pixels in the working area of the image to be processed have a first pixel value, and pixels in the non-working area have a second pixel value. When a pixel is within the working area, its adjacent pixels should also be within the working area. Therefore, the pixel value of the pixel should be the same as the pixel value of its adjacent pixels, i.e., both should have the first pixel value. Similarly, when a pixel is outside the working area, its adjacent pixels should also be outside the working area. Therefore, the pixel value of the pixel should be the same as the pixel value of its adjacent pixels, i.e., both should have the second pixel value. When a pixel is on the boundary between the working area and the non-working area, its adjacent pixels may be either within the working area or outside the working area, indicating that there are different pixel values among the adjacent pixels of the pixel. Based on the above characteristics, the pixel values of each adjacent pixel in the image to be processed can be identified. When there are different pixel values among the adjacent pixels of a pixel, it can be determined that the pixel is on the boundary, and thus it can be used as the first center point of the sliding window, i.e., the starting anchor point.
[0078] In one embodiment of this application, the process of determining the starting anchor point includes: obtaining a target pixel that meets a preset pixel threshold from a plurality of pixels; obtaining adjacent pixels of the target pixel from a plurality of pixels; and determining the target pixel as the starting anchor point when the pixel value of the adjacent pixel is different from the pixel value of the target pixel.
[0079] First, target pixels that meet a preset pixel threshold are obtained from multiple pixels in the image to be processed. Meeting the preset pixel threshold means that if a pixel's value is equal to the preset threshold, then that pixel is a target pixel. For example, if the preset pixel threshold is 254, then a pixel with a value of 254 is considered a target pixel. Next, the neighboring pixels of the target pixel are obtained. Neighboring pixels are pixels within a specific neighborhood of the target pixel. This specific neighborhood can be a four-neighbor, eight-neighbor, or D-neighbor, etc. Within a 3x3 pixel matrix (in a nine-grid format), the pixels in the four directions (up, down, left, and right) of the center pixel are its four-neighbor pixels. The pixels on the diagonal of the nine-grid are the center pixel's D-neighbor pixels. The sum of the four-neighbor and D-neighbor pixels is the center pixel's eight-neighbor pixels (i.e., all pixels within the nine-grid except the center pixel are the center pixel's eight-neighbor pixels).
[0080] Taking the four-neighborhood as an example, if one of the neighboring pixels in the four-neighborhood of a target pixel has a different pixel value than the target pixel, then the target pixel is considered a boundary pixel and can be used as a starting anchor point. Specifically, the pixels in the image to be processed are first marked, for example, by assigning a specific label to each pixel. The marked pixels are those waiting for subsequent processing. Then, pixels that meet the preset pixel threshold among the marked pixels are taken as target pixels. This process is as follows: traverse the marked pixels in the image to be processed. For each marked pixel, determine whether the pixel value of the marked pixel is the preset pixel threshold. If it is, then the marked pixel is taken as the target pixel. If the pixel value of the marked pixel is not the preset pixel threshold, then the marked pixel is not the target pixel. Continue traversing the next marked pixel. At the same time, it is necessary to exclude the marked pixel that is not the target pixel from the range of marked pixels to be traversed in the future. For example, the mark of the marked pixel is cleared. This can avoid repeated traversal of the marked pixel in the future.
[0081] After identifying the target pixel, it is added to the pixel queue to be processed. Pixels in the queue are the target pixels from which neighboring pixels need to be obtained. Pixels not in the queue do not require neighboring pixels. Next, target pixels are sequentially retrieved from the queue, and their neighboring pixels are obtained by traversing their specific neighborhoods.
[0082] In order to distinguish the target pixel from other non-target pixels, the embodiments of this application further include: a step of marking the target pixel; in the step of obtaining the neighboring pixels of the target pixel from multiple pixels, the neighboring pixels are unmarked pixels.
[0083] Specifically, in this embodiment, the step of marking target pixels includes: setting the pixel value of each target pixel to a preset pixel value; or, marking each target pixel with an index number. The preset pixel value can be set according to the actual situation, and the index number can be set according to the position arrangement of the target pixels in the image to be processed.
[0084] This allows the corresponding target pixel to be quickly located in the image to be processed based on the set pixel value or index number.
[0085] Step 230: Traverse the image to be processed through a sliding window, and match the corresponding window images of the sliding window with the preset path template during the traversal process to obtain the matching anchor points.
[0086] Specifically, after determining the starting anchor point, this starting anchor point is used as the first center point of the sliding window, i.e., the initial center point. The corresponding window image in the image to be processed is matched with a preset path template to determine the center point of the next sliding window connecting to the starting anchor point. The sliding window then slides along the determined center point of this next sliding window. The image area covered by the sliding window in the image to be processed is called the window image. During the sliding process, the window image is matched with the preset path template. Based on the matching result, the traversal direction of the sliding window and the corresponding anchor point are determined. The matched anchor point is the center point of the sliding window.
[0087] In this embodiment, the size of the preset path template is the same as the size of the sliding window. By matching the window image with the preset path template, the location of the next anchor point corresponding to the anchor point (denoted as the current anchor point) in the currently matched window image can be determined. Then, the traversal direction of the sliding window can be determined by the current anchor point and the next anchor point. After determining the next anchor point, the sliding window moves its center point to the position of the next anchor point, thereby obtaining the window image corresponding to the next anchor point. After the window image is matched with the preset path template, the next anchor point is obtained. The sliding window traverses the image to be processed in this way to obtain multiple anchor points.
[0088] In one embodiment of this application, the sliding process of the sliding window includes: constructing a sliding window centered on a starting anchor point; matching the window image corresponding to the sliding window with a preset path template to determine the traversal direction of the sliding window and the next anchor point connected to the center point; when the next anchor point does not coincide with the specified anchor point, using the next anchor point as the next center point of the sliding window, and performing the step of matching the window image corresponding to the sliding window with the preset path template according to the traversal direction; stopping the sliding of the sliding window when the next anchor point coincides with the specified anchor point; wherein, the specified anchor point includes already determined anchor points; or the specified anchor point is a pixel point on the edge of the image to be processed.
[0089] Specifically, first, a sliding window is constructed with the starting anchor point as the center point. Generally, the sliding window is 3*3 pixels in size, that is, 3 pixels in both the length and width directions, forming a nine-grid pattern. The starting anchor point is located at the center point of this nine-grid. Then, the window image corresponding to the sliding window is matched with a preset path template to obtain the next anchor point, which is the anchor point connected to the anchor point in the current window image.
[0090] In this embodiment, there are multiple preset path templates, each indicating the orientation of the next anchor point connected to the current anchor point. For example, as shown... Figures 3A-3BAs shown, the embodiments of this application provide 16 preset path templates, numbered 1-16. Each preset path template is different from the others. The direction of the arrow in each preset path template is the location of the next anchor point. One square in the preset path template represents one pixel. The color marked in the square represents the color of the corresponding pixel. "Black" represents a black pixel and "white" represents a white pixel. Squares without color markings indicate that the color of the corresponding pixel does not need to be considered when matching.
[0091] The following uses preset path template number 1 (hereinafter referred to as template 1) as an example to illustrate the matching process between the window image and the preset path template. The image to be processed uses two pixel values to represent pixels in the working area and pixels in the non-working area. Assume that the pixel value of pixels in the working area is 255, representing white; and the pixel value of pixels in the non-working area is 0, representing black. Therefore, within the window image corresponding to the sliding window, all pixels except the center point contain both black and white pixels. For example... Figure 3A Template 1, as shown, has its center point as the current anchor point (i.e., the center point of the current window image). In the window image, if the pixel directly above the current anchor point is black, and the pixels to its upper left and left are white, then the preset path template matching this window image is Template 1. The arrow in Template 1 points to the upper left pixel, thus determining the upper left pixel of the current anchor point as the next anchor point connected to it. Next, the sliding window slides according to the matched anchor point, moving the center point to that upper left pixel, obtaining the window image centered at that upper left pixel, and then comparing this window image with... Figures 3A-3B The system matches the various preset path templates shown and determines the next anchor point based on the matched preset path template.
[0092] In one embodiment of this application, one way to match a window image with a preset path template is as follows: determine the traversal direction of the sliding window based on the center point; obtain multiple preset path templates indicated by the traversal direction; and match the window image corresponding to the sliding window with the multiple preset path templates to obtain the next anchor point connected to the center point.
[0093] Specifically, the preset path template in this embodiment has two different matching directions: counter-clockwise matching and clockwise matching. Pixels in the window image other than the center pixel (i.e., the current anchor point) are called neighboring pixels. Counter-clockwise matching means that, starting from a black pixel, the neighboring pixels of the window image are traversed counter-clockwise until the first white pixel is found. This first white pixel is the next anchor point connected to the current anchor point. The preset path template corresponding to the counter-clockwise matching method is as follows: Figure 3AAs shown, there are 8 in total. Clockwise matching refers to traversing the neighboring pixels of the window image, starting from a black pixel, and sequentially going clockwise until the first white pixel is found. This first white pixel is the next anchor point connected to the current anchor point. The preset path template corresponding to the clockwise matching method is as follows: Figure 3B As shown, there are a total of 8.
[0094] Once the matching direction is determined, it will not change in subsequent matching processes. Therefore, the next anchor point connected to the current anchor point is unique, and the traversal direction of the sliding window is also determined. Thus, the matching direction can be determined first, indicating the traversal direction. In subsequent matching processes, the window image only needs to be matched with multiple preset paths corresponding to that matching direction, instead of matching with all preset path templates. This reduces the number of preset path templates that the window image needs to compare during the matching process, improving matching efficiency and consequently increasing the efficiency of generating the working path.
[0095] The matching direction can be determined based on the matching result of the window image corresponding to the starting anchor point. The matching direction of the starting anchor point can be randomly selected or preset using parameters. For example, Figure 4 The diagram illustrates an image to be processed. Assuming the starting anchor point is anchor point A, the window image corresponding to anchor point A has two matching directions to choose from during matching. If clockwise matching is chosen at anchor point A, the subsequent matching process should follow route 1; if counter-clockwise matching is chosen at anchor point A, the subsequent matching process should follow route 2. It should be noted that... Figure 4 The routes 1 and 2 shown are only for illustrative purposes and do not represent the final working path curves.
[0096] In this embodiment, the matching ends when the next anchor point matched by the current anchor point coincides with the specified anchor point. Specifically: if the next anchor point does not coincide with the specified anchor point, the next anchor point is used as the center point of the sliding window, and the matching operation continues; if the next anchor point coincides with the specified anchor point, the sliding window stops sliding, and multiple anchor points are obtained based on the matching results of each window image. The specified anchor point includes already determined anchor points, or the specified anchor point is a pixel on the edge of the image to be processed.
[0097] Specifically, the matched anchor points are the pixels on the boundary line between the working area and the non-working area. When the next anchor point is a previously matched anchor point, it means that the matched anchor points have formed a closed boundary, and all pixels on this boundary are determined, so no further matching is needed. Generally, the next anchor point in this case is the starting anchor point. For example, as shown... Figure 4The image to be processed is shown. Assuming anchor point A is the starting anchor point, and matching is performed according to route 2, when matching continues according to anchor point Z, the next anchor point is anchor point A. Since anchor point A is a determined anchor point, the matching stops. A closed boundary can be obtained by following the matching direction of route 2.
[0098] When the next anchor point is a pixel at the top edge of the image to be processed, it indicates that the matched boundary has extended to the edge of the image to be processed. Continuing to match will exceed the range of the image to be processed. If the matching is not stopped, it may lead to data errors. At the same time, this situation also indicates that the matched boundary is a non-closed boundary. For example, as shown... Figure 5 The image to be processed is shown. Assuming anchor point A is the starting anchor point, the matching direction is clockwise. When the image continues to slide from anchor point A to anchor point Y, and anchor point Y is matched, the next anchor point matched by anchor point Y is anchor point Z. Anchor point Z is a pixel on the edge of the image to be processed. At this point, the matching stops, and a non-closed boundary can be obtained.
[0099] Therefore, when the next anchor point is a determined anchor point or a pixel on the edge of the image to be processed, it means that a complete boundary has been determined, that is, a closed boundary or a non-closed boundary, and the matching operation ends at this time.
[0100] Step 240: Generate the working path in the working area based on the starting anchor point and the matched anchor points.
[0101] Specifically, the starting anchor point and the matched anchor points are connected sequentially to form the working path. Since the connection of each anchor point also forms the boundary line between the working area and the non-working area, the generated working path is also called an edge path.
[0102] For example, Figure 6 A schematic diagram of a working path generation process provided in one embodiment of this application is shown. Figure 6 As shown in image ①, the current anchor point in the window image is anchor point A. Directly below anchor point A are black pixels, while the lower right and right sides are white pixels. Through matching, it is determined that the window image matches the inverted... Figure 3A Template 5, as shown, indicates that the bottom right pixel is the next anchor point. Let's denote the next anchor point as anchor point B. Then, anchor point B is determined to be the next anchor point connected to anchor point A, as shown below. Figure 6 As shown in image ②, connecting anchor point A and anchor point B yields the working path, as follows. Figure 6 As shown in image ③.
[0103] Steps 210-240 above illustrate the technical principle of this application using the example of a single boundary in the image to be processed. In some cases, multiple boundaries may exist in the image to be processed. In this case, the working paths corresponding to each boundary are generated as follows: First, the first edge path corresponding to the first boundary is generated according to steps 210-240 above. During the generation of the first edge path, pixels that have already been traversed in the image to be processed are marked. When generating other edge paths subsequently, the marked pixels will not be traversed again. This avoids repeated traversal of pixels and improves path generation efficiency. After generating the first edge path, the image region composed of currently untraversed pixels is taken as the image to be processed, and steps 220-240 are executed again to generate the second edge path corresponding to the second boundary. The image to be processed in the working region is traversed in the above loop. When all pixels of the image to be processed in the working region have been traversed, the processing of the image to be processed in the working region is completed, resulting in multiple working paths.
[0104] For example, Figure 7 The diagram illustrates a schematic representation of an image to be processed according to another embodiment of this application. Assuming processing begins from the top-left pixel of the image, the starting anchor point is identified as anchor point A. Matching begins from anchor point A to obtain working path 11. After obtaining working path 11, the starting anchor point is identified as anchor point B among unmarked pixels. Matching begins from anchor point B to obtain working path 12. After obtaining working path 12, the starting anchor point is identified as anchor point C among unmarked pixels. Matching begins from anchor point C to obtain working path 13. After obtaining working path 13, the starting anchor point is identified as anchor point D among unmarked pixels. Matching begins from anchor point D to obtain working path 14.
[0105] In the technical solution provided in this application embodiment, the image to be processed in the working area is acquired, and then the starting anchor point is determined. A sliding window centered on the anchor point traverses the image to be processed. Multiple anchor points are obtained by matching the images in each window with a preset path template during the traversal. Finally, a working path is generated based on the starting anchor point and the matched anchor points. This method of determining anchor points through template matching is simple to operate, easy to deploy, and can quickly determine each anchor point during window traversal, resulting in high efficiency and accuracy, and making the generation of the working path convenient and fast. Furthermore, this path planning method does not rely on hardware devices such as sensors, improving the stability and flexibility of path planning, as well as its anti-interference capability. Moreover, the image to be processed used to generate the path can be an offline working map, meaning the path can be pre-configured for the robot, eliminating the need for the robot to calculate the path in real time during operation, thus improving the robot's working efficiency.
[0106] It should be noted that although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0107] The following describes an embodiment of the apparatus of this application, which can be used to execute the path planning method in the above embodiments of this application. Figure 8 A schematic block diagram of the path planning device provided in an embodiment of this application is shown. Figure 8 As shown, the path planning device includes:
[0108] Image acquisition module 810 is used to acquire an image to be processed in the working area, the image to be processed including multiple pixels;
[0109] The starting anchor point determination module 820 is used to determine a starting anchor point from the plurality of pixels based on the pixel values of the plurality of pixels;
[0110] The window sliding module 830 is used to traverse the image to be processed through the sliding window, and match each window image corresponding to the sliding window during the traversal with a preset path template to obtain the matching anchor point;
[0111] The path generation module 840 is used to generate a working path in the working area based on the starting anchor point and the matching anchor point.
[0112] In one embodiment of this application, the window sliding module 830 includes:
[0113] The sliding window building unit is used to construct a sliding window centered on the starting anchor point.
[0114] The matching unit is used to match the window image corresponding to the sliding window with a preset path template to determine the traversal direction of the sliding window and the next anchor point connected to the center point.
[0115] The judgment unit is used to, when the next anchor point does not coincide with the specified anchor point, take the next anchor point as the next center point of the sliding window, and perform the step of matching the window image corresponding to the sliding window with the preset path template according to the traversal direction; when the next anchor point coincides with the specified anchor point, stop the sliding of the sliding window; wherein, the specified anchor point includes the already determined anchor point;
[0116] Alternatively, the specified anchor point may be a pixel on the edge of the image to be processed.
[0117] In one embodiment of this application, the matching unit is specifically used for:
[0118] The traversal direction of the sliding window is determined based on the center point;
[0119] Obtain multiple preset path templates indicated by the traversal direction;
[0120] The window image corresponding to the sliding window is matched with the multiple preset path templates to obtain the next anchor point connected to the center point.
[0121] In one embodiment of this application, the starting anchor point determination module 820 includes:
[0122] The target pixel acquisition unit is used to acquire target pixels that satisfy a preset pixel threshold from the plurality of pixels;
[0123] The adjacent pixel acquisition unit is used to acquire adjacent pixels of the target pixel from the plurality of pixels;
[0124] The starting anchor point determination unit is used to determine the target pixel as the starting anchor point when the pixel value of the adjacent pixel is not the same as the pixel value of the target pixel.
[0125] In one embodiment of this application, the apparatus further includes:
[0126] A marking unit is used to mark the target pixel.
[0127] The adjacent pixel points acquired by the adjacent pixel point acquisition unit are unmarked pixels.
[0128] In one embodiment of this application, the marking unit is specifically used for:
[0129] Set the pixel value of each target pixel to a preset pixel value;
[0130] Alternatively, each of the target pixels can be marked with an index number.
[0131] In one embodiment of this application, the image acquisition module 810 includes:
[0132] The original image acquisition unit is used to acquire the original image of the working area, wherein the pixel value of each pixel in the original image includes the pixel value of multiple color channels;
[0133] A grayscale image generation unit is used to obtain the average pixel value of the multiple color channels, use the average pixel value as the grayscale value of each pixel, and generate a grayscale image corresponding to the original image based on the grayscale value of each pixel.
[0134] The image generation unit is configured to update the pixel value of any pixel in the grayscale image to a first pixel value when the grayscale value of any pixel in the grayscale image is greater than a preset grayscale pixel threshold; and update the pixel value of any pixel in the grayscale image to a second pixel value when the grayscale value of any pixel in the grayscale image is less than the preset grayscale pixel threshold; and obtain the image to be processed based on each pixel after updating the pixel value.
[0135] The specific details of the path planning apparatus provided in the various embodiments of this application have been described in detail in the corresponding method embodiments, and will not be repeated here.
[0136] Figure 9 A schematic block diagram of a computer system architecture for implementing an electronic device according to embodiments of the present application is shown.
[0137] It should be noted that, Figure 9 The computer system 900 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0138] like Figure 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 902 or programs loaded from storage section 908 into random access memory (RAM) 903. The RAM 903 also stores various programs and data required for system operation. The CPU 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output interface 905 (I / O interface) is also connected to the bus 904.
[0139] The following components are connected to the input / output interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a local area network card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0140] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by central processing unit 901, it performs various functions defined in the system of this application.
[0141] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0143] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0144] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.
[0145] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0146] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A path planning method, characterized in that, include: Acquire the image to be processed in the working area, the image to be processed comprising multiple pixels; Based on the pixel values of the plurality of pixels, a starting anchor point is determined from the plurality of pixels; wherein, when there are different pixel values among the adjacent pixels of the pixel, the pixel is determined as the starting anchor point; The image to be processed is traversed by a sliding window, and each window image corresponding to the sliding window during the traversal is matched with a preset path template to obtain a matching anchor point; wherein, the anchor point is the center point of the sliding window, and the starting anchor point is the first center point of the sliding window; The starting anchor point and the matching anchor point are connected sequentially to generate the working path in the working area; wherein, the working path is an edge path.
2. The path planning method according to claim 1, characterized in that, The step of traversing the image to be processed through a sliding window and matching each window image corresponding to the sliding window during the traversal with a preset path template to obtain the matching anchor points includes: Construct a sliding window centered at the starting anchor point; Match the window image corresponding to the sliding window with the preset path template to determine the traversal direction of the sliding window and the next anchor point connected to the center point; When the next anchor point does not coincide with the specified anchor point, the next anchor point is taken as the next center point of the sliding window, and the step of matching the window image corresponding to the sliding window with the preset path template is executed according to the traversal direction. When the next anchor point coincides with the specified anchor point, the sliding window stops sliding; Wherein, the designated anchor point includes already determined anchor points; or The designated anchor point is a pixel on the edge of the image to be processed.
3. The path planning method according to claim 2, characterized in that, The step of matching the window image corresponding to the sliding window with a preset path template to determine the traversal direction of the sliding window and the next anchor point connected to the center point includes: The traversal direction of the sliding window is determined based on the center point; Obtain multiple preset path templates indicated by the traversal direction; The window image corresponding to the sliding window is matched with the multiple preset path templates to obtain the next anchor point connected to the center point.
4. The path planning method according to claim 1, characterized in that, The step of determining the starting anchor point from the plurality of pixels based on the pixel values of the plurality of pixels includes: Obtain target pixels that satisfy a preset pixel threshold from the plurality of pixels; Obtain the adjacent pixels of the target pixel from the plurality of pixels; When the pixel value of the adjacent pixel is different from the pixel value of the target pixel, the target pixel is determined as the starting anchor point.
5. The path planning method according to claim 4, characterized in that, The method further includes: The step of marking the target pixels; In the step of obtaining the neighboring pixels of the target pixel from the plurality of pixels, the neighboring pixels are unmarked pixels.
6. The path planning method according to claim 5, characterized in that, The step of marking the target pixel includes: Set the pixel value of each target pixel to a preset pixel value; Alternatively, each of the target pixels can be marked with an index number.
7. The path planning method according to any one of claims 1-6, characterized in that, The acquisition of the image to be processed in the working area includes: Obtain the original image of the working area, wherein the pixel value of each pixel in the original image includes the pixel value of multiple color channels; Obtain the average pixel value of the multiple color channels, and use the average pixel value as the grayscale value of each pixel. Generate a grayscale image corresponding to the original image based on the grayscale value corresponding to each pixel. When the gray value of any pixel in the grayscale image is greater than a preset grayscale pixel threshold, the pixel value of the pixel in the grayscale image is updated to the first pixel value; When the gray value of any pixel in the grayscale image is less than a preset grayscale pixel threshold, the pixel value of the pixel in the grayscale image is updated to a second pixel value; The image to be processed is obtained based on each pixel after the pixel value is updated.
8. A path planning device, characterized in that, include: The image acquisition module is used to acquire the image to be processed in the working area, the image to be processed including multiple pixels; The starting anchor point determination module is used to determine a starting anchor point from the plurality of pixels based on the pixel values of the plurality of pixels; wherein, when there are different pixel values among the adjacent pixels of the pixel, the pixel is determined as the starting anchor point; A window sliding module is used to traverse the image to be processed through a sliding window, and match each window image corresponding to the sliding window during the traversal with a preset path template to obtain a matching anchor point; wherein, the anchor point is the center point of the sliding window, and the starting anchor point is the first center point of the sliding window; The path generation module is used to connect the starting anchor point and the matching anchor point in sequence to generate a working path in the working area; wherein, the working path is an edge path.
9. A computer-readable medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the path planning method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor executes the executable instructions to cause the electronic device to perform the path planning method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Path planning method and device thereof, computer equipment and storage medium
CN113848947A