Image Processing Method, Apparatus, Storage Medium, Processor, and Electronic Device
By acquiring the junction in the target image and segmenting processing to generate a polygon set, the problem of low pathfinding efficiency is solved, and the target object's direct pathfinding on the slash path is achieved.
Patent Information
- Application Number
- CN202210366179.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-04-08
AI Technical Summary
In the prior art, the pathfinding efficiency of game maps or real maps is low, especially when the paths appear slashes, they cannot be directly point-to-point pathfinding in one step.
By obtaining the junction between the walkable area and the unwalking area in the target image, segmentation processing is performed, a target polygon collection is generated, and a target map is generated based on this to realize the wayfinding function of the target object.
The efficiency of pathfinding is improved, so that the target object can directly search for pathfinding in one step when the path appears slash.
Smart Images

Figure CN114820653B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular, to an image processing method, apparatus, storage medium, processor, and electronic device. Background Art
[0002] Currently, automatic pathfinding refers to searching for the best passable path between two points in a blocked game map. The path found by traditional pathfinding algorithms will be a relatively mechanical path. Due to the limitation that obstacles exist in a grid form, when there is a diagonal line in the path, it is impossible to directly find the path point-to-point in one step, resulting in low pathfinding efficiency.
[0003] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention
[0004] At least some embodiments of the present invention provide an image processing method, apparatus, storage medium, processor, and electronic device to at least solve the technical problem of low pathfinding efficiency in the related art for maps.
[0005] According to an embodiment of the present invention, an image processing method is provided, including: obtaining a target image, where the target image includes a first region and a second region, the first region is used to represent the region where the target object can walk, and the second region is used to represent other regions except the first region; determining the boundary between the first region and the second region in the target image; performing segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple polygons in the set of target polygons do not intersect each other; generating a target map based on the set of target polygons, where the target map is used to implement the pathfinding function of the target object.
[0006] Optionally, performing segmentation processing on the first region of the target image based on the boundary to obtain a set of target polygons includes: obtaining a first set of points corresponding to the boundary; performing segmentation processing on the first region based on the first set of points to obtain a set of target polygons.
[0007] Optionally, performing segmentation processing on the first region based on the first set of points to obtain a set of target polygons includes: performing segmentation processing on the first region based on the first set of points to obtain an initial set of polygons; obtaining the vertices and midpoints of each polygon in the initial set of polygons to generate a second set of points; screening the second set of points based on the second region to obtain a set of target polygons.
[0008] Optionally, filter the second set of points based on the second region to obtain a set of target polygons, including: determining whether there is a target point in the second set of points that is located in the second region; in response to there being a target point in the second set of points that is located in the second region, obtaining the target polygon corresponding to the target point; deleting the target polygon from the initial set of polygons to obtain the set of target polygons.
[0009] Optionally, determining the boundary between the first region and the second region in the target image includes: performing grid processing on the target image to obtain a grid image, where the grid image includes at least one grid for distinguishing the first region and the second region; determining the boundary between the first region and the second region by traversing at least one grid in the grid image.
[0010] Optionally, determining the boundary between the first region and the second region by traversing at least one grid in the grid image includes: traversing at least one grid in the grid image to obtain a target grid, where the target grid corresponds to the first region in the target image, and at least one grid adjacent to the target grid corresponds to the second region in the target image; determining the region where the target grid is located as the boundary.
[0011] According to one embodiment of the present invention, there is provided an image processing apparatus, the apparatus including: an acquisition module for acquiring a target image, where the target image includes a first region and a second region, the first region is used to represent the region where the target object can walk, and the second region is used to represent other regions except the first region; a determination module for determining the boundary between the first region and the second region in the target image; a processing module for performing segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple target polygons in the set of target polygons do not intersect each other; a generation module for generating a target map based on the set of target polygons, where the target map is used to implement the pathfinding function of the target object.
[0012] According to one embodiment of the present invention, there is provided a non-volatile storage medium, in which a computer program is stored, where the computer program is configured to execute the image processing method in any one of the above when running.
[0013] According to one embodiment of the present invention, there is provided a processor, characterized in that the processor is used to run a program, where the program is configured to execute the image processing method in any one of the above when running.
[0014] According to one embodiment of the present invention, there is provided an electronic device, including a memory and a processor, characterized in that a computer program is stored in the memory, and the processor is configured to run the computer program to execute the image processing method in any one of the above.
[0015] First, obtain a target image, where the target image includes a first region and a second region. The first region is used to represent the area where the target object can walk, and the second region is used to represent other areas except the first region. Determine the boundary between the first region and the second region in the target image, and perform segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple polygons in the set of target polygons do not intersect with each other. Thus, the first region representing the walkable area in the image can be re-planned. By dividing the first region into multiple polygons, when it is applied to the target map later, the target object can determine the pathfinding route based on the polygons it needs to pass from the starting point to the ending point. When there is a diagonal line in the path, it can directly perform point-to-point pathfinding in one step, thereby improving the pathfinding efficiency, and further solving the technical problem of low pathfinding efficiency in the related art of maps. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a mobile terminal for an image processing method according to an embodiment of the present invention;
[0018] Figure 2 is a flowchart of an image processing method according to one embodiment of the present invention;
[0019] Figure 3 is a schematic diagram of a target map according to one embodiment of the present invention;
[0020] Figure 4 is a schematic diagram of a mask image of a map according to one embodiment of the present invention;
[0021] Figure 5 is a block diagram of a structure of an image processing apparatus according to one embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0023] It should be noted that the terms "first", "second", etc. in the description, claims and above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that such data used can be interchanged under appropriate circumstances, so that the embodiments of the present invention described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0024] According to one embodiment of the present invention, an embodiment of an image processing method is provided. It should be noted that the steps shown in the flowchart of the drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here.
[0025] This method embodiment can be executed on a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a handheld computer, and a mobile Internet device (abbreviated as MID), a PAD, a game console and other terminal devices. Figure 1 It is a hardware structure block diagram of a mobile terminal of an image processing method according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processor 102 may include, but is not limited to, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a programmable logic device (FPGA), a neural network processor (NPU), a tensor processor (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. Optionally, the above-mentioned mobile terminal may further include a transmission device 106, an input / output device 108 and a display device 110 for communication functions. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may further include more or fewer components than those Figure 1 shown in the figure, or have a different configuration from that Figure 1 shown in the figure.
[0026] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the image processing method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, implements the above-mentioned image processing method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the mobile terminal through a network. Examples of the above network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.
[0027] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include the wireless network provided by the communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.
[0028] The input in the input / output device 108 can come from multiple human interface devices (Human Interface Device, abbreviated as HID). For example: keyboards and mice, game pads, other dedicated game controllers (such as: steering wheels, fishing rods, dance mats, remote controls, etc.). Some human interface devices can provide output functions in addition to input functions, such as: force feedback and vibration of game pads, audio output of controllers, etc.
[0029] The display device 110 can be, for example, a head-up display (HUD), a touch-screen liquid crystal display (LCD), and a touch display (also referred to as a "touch screen" or "touch display screen"). The liquid crystal display enables the user to interact with the user interface of the mobile terminal. In some embodiments, the above mobile terminal has a graphical user interface (GUI), and the user can perform human-computer interaction with the GUI through finger contacts and / or gestures on the touch-sensitive surface. The human-computer interaction function here may optionally include the following interactions: creating web pages, drawing, word processing, creating electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. The executable instructions for performing the above human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0030] The image processing method in one of the embodiments of the present disclosure can run on a local terminal device or a server. When the image processing method runs on the server, the method can be implemented and executed based on a cloud interaction system, where the cloud interaction system includes a server and a client device.
[0031] In a possible implementation manner, an embodiment of the present invention provides an image processing method. Figure 2 It is a flowchart of an image processing method according to an embodiment of the present invention, as Figure 2 shown, the method includes the following steps:
[0032] Step S202, obtain a target image.
[0033] Among them, the target image includes a first area and a second area. The first area is used to represent the area where the target object can walk, and the second area is used to represent other areas except the first area.
[0034] The above-mentioned target image can be a grid image of a map in a game or a grid image of a map in reality.
[0035] The above-mentioned first area can be the area where the target object can walk in the image. In a game scene, it can be an area where the target object can walk, such as a road in the game. In a real scene, it can be an area where pedestrians can walk. The above-mentioned second area can be obstacles in the game, such as stone walls, rockeries, etc., and can be furniture, walls, etc. in a real scene that are difficult for pedestrians to pass through.
[0036] The above-mentioned target object can be a virtual game character in a game scene, and the above-mentioned target object can be a person, an animal, etc. in a real scene.
[0037] In an optional embodiment, a target image corresponding to the map can be obtained so as to process the target image and generate a map that can quickly find a path.
[0038] Step S204, determine the boundary between the first area and the second area in the target image.
[0039] In an optional embodiment, the target image can be pixelated into a grid. The grids at the boundary in the first area can be marked as the boundary between the first area and the second area, and the grids at the boundary in the second area can also be marked as the boundary between the first area and the second area.
[0040] In an alternative embodiment, after meshing the pixels of the target image, the white grids represent the areas where walking is possible, that is, the above-mentioned first area, and the black grids represent the areas where walking is not possible, that is, the above-mentioned second area. All grids can be traversed to determine whether the grid is a walkable area and whether any one of the grids above (0, 1), below (0, -1), left (-1, 0), and right (1, 0) is an unwalkable area. If so, the grid is on the boundary of the walkable area, and the grid can be marked as the boundary between the first area and the second area.
[0041] Step S206: Based on the boundary, perform a segmentation process on the first area to obtain a set of target polygons.
[0042] Among them, the multiple target polygons in the set of target polygons do not intersect with each other.
[0043] The above-mentioned target polygons can be triangles, rhombuses, squares, etc. In this application, the polygon is taken as an example of a triangle for illustration.
[0044] In an alternative embodiment, the first area can be segmented according to the boundary, and the first area is segmented into multiple polygons, that is, the above-mentioned set of target polygons. Specifically, multiple line segments can be determined according to the grids in the boundary, and the vertices of the multiple line segments can be obtained to obtain a first point set. The Bowyer-Watson (point-by-point insertion algorithm) algorithm can be used to process the first point set to obtain multiple Delaunay triangles (Delaunay triangles), and then a set of Delaunay triangles can be obtained.
[0045] The specific process of using the Bowyer-Watson algorithm to process the first point set is as follows: All points in the first point set can be sorted first, the maximum and minimum values of the abscissa and ordinate of all points can be determined, and a super triangle can be determined through the maximum and minimum values of all points. It can be judged whether the points in the first point set are on the inscribed circle of the triangle. If so, the three sides of this triangle can be added to the line segment set. All line segments in the line segment set can be traversed to remove the same line segments. After removing the same line segments, all line segments can be traversed to obtain multiple triangles, thereby obtaining a set of Delaunay triangles.
[0046] Step S208: Generate a target map based on the set of target polygons.
[0047] Among them, the target map is used to implement the pathfinding function of the target object.
[0048] In an alternative embodiment, after obtaining the target polygon set, the target polygon set can be exported and applied to the walkable area in the map, so that during the pathfinding process of the target object, the hypotenuses of multiple polygons in the target polygon set can be used to find a route for fast walking, thereby improving the pathfinding efficiency of the target object.
[0049] It should be noted that the multiple polygons in the target polygon set are adjacent but non-overlapping. As Figure 3 shown in the schematic diagram of the target map, where the first area can be represented by the target polygon set, and during the pathfinding process of the target object, pathfinding can be performed based on the target polygon set in the first area.
[0050] Through the above steps, first obtain the target image, where the target image includes a first area and a second area. The first area is used to represent the walkable area of the target object, and the second area is used to represent other areas except the first area. Determine the boundary between the first area and the second area in the target image, and perform segmentation processing on the first area based on the boundary to obtain the target polygon set, where the multiple polygons in the target polygon set do not intersect each other. Thus, the first area representing the walkable area in the image can be re-planned. By dividing the first area into multiple polygons, when applied to the target map later, the target object can determine the pathfinding route based on the polygons to be walked from the starting point to the ending point. When there is a diagonal line in the path, it can directly perform point-to-point pathfinding in one step, thereby improving the pathfinding efficiency and solving the technical problem of low pathfinding efficiency in the related art.
[0051] Optionally, performing segmentation processing on the first area of the target image based on the boundary to obtain the target polygon set includes: obtaining a first point set corresponding to the boundary; and performing segmentation processing on the first area based on the first point set to obtain the target polygon set.
[0052] The above-mentioned first point set can be a set of endpoints of multiple line segments in the boundary.
[0053] In an alternative embodiment, multiple line segments in the boundary can be obtained first. It should be noted that a line segment can be composed of multiple adjacent grids in the front, back, left, or right. There can be multiple line segments in the boundary. When a grid in the boundary does not have adjacent grids in the front, back, left, or right that are also located at the boundary, it means that this grid cannot form a line segment with other grids. At this time, the center point of this grid can be obtained and used as an endpoint. When there are one or more adjacent grids in the front, back, left, or right that are also located at the boundary in the boundary grid, it means that this grid can form a line segment with other grids. Specifically, the center points of the adjacent multiple grids can be connected to obtain a line segment, and then the endpoints at both ends of the line segment can be obtained.
[0054] Further, all the end points on the boundary can be obtained to get the above-mentioned first point set.
[0055] In another alternative embodiment, after obtaining the first point set, the Bowyer-Watson algorithm can be used to divide the first region to obtain a plurality of Delaunay triangles. After obtaining the Delaunay triangles, it is also necessary to further screen the plurality of Delaunay triangles to remove the Delaunay triangles that exceed the first region to avoid the appearance of walkable parts in the second region.
[0056] Optionally, the first region is divided based on the first point set to obtain a target polygon set, including: dividing the first region based on the first point set to obtain an initial polygon set; obtaining the vertices and midpoints of each polygon in the initial polygon set to generate a second point set; screening the second point set based on the second region to obtain the target polygon set.
[0057] In an alternative embodiment, the first region can be divided according to the first point set to first obtain an initial polygon set. It should be noted that there may be polygons in the initial polygon set that exceed the first region. Therefore, it is necessary to remove the polygons that exceed the first region in the initial polygon set. Specifically, the vertices and midpoints of each polygon in the initial polygon set can be obtained to generate a second point set, and it is determined whether there is a point in the second point set that is located in the second region. If there is a point located in the second region, it means that the polygon corresponding to this point will exceed the walkable first region. At this time, this triangle can be removed from the initial polygon set to obtain the target polygon set.
[0058] In another alternative embodiment, the S.W.SLOAN algorithm (double-line interpolation algorithm) can be used to propose a fast algorithm for generating a set of constrained initial polygons, such that the polygons in the polygon set do not exceed the first region. The specific steps can be as follows. First, taking the polygon as a triangle as an example, the variable at the intersection can be defined as P, and the triangle can be defined as T. Determine whether the side of triangle T intersects with P. If it intersects, the intersecting line segment can be recorded. Determine whether the two triangles where the intersecting line segment is located can form a convex polygon. If a convex polygon can be formed, the opposite sides of the two triangles can be swapped, and then determine whether it intersects with P. If it does not intersect with P, the two triangles after swapping the opposite sides can form new triangles and be added to the triangle set. Further, traverse the triangle set and determine whether the circumcircle of the two triangles containing the new side contains the vertex of another triangle. If it contains, swap the opposite sides of the two triangles and determine whether a convex polygon can be formed. If a convex polygon can be formed, a convex polygon can be generated based on the two triangles with the opposite sides swapped, and two new triangles can be generated and added to the triangle set. The above-mentioned triangle set can be output, and the corresponding NavMesh map can be generated.
[0059] Optionally, based on the second region, filter the second point set to obtain a target polygon set, including: determining whether there is a target point in the second region in the second point set; in response to there being a target point in the second region in the second point set, obtaining the target polygon corresponding to the target point; deleting the target polygon in the initial polygon set to obtain the target polygon set.
[0060] In one alternative embodiment, it can be determined whether there is a target point in the non-walkable second region in the second point set. If there is a target point in the non-walkable second region in the second point set, it means that the polygon corresponding to the target point exceeds the first region. At this time, it is necessary to obtain the target polygon corresponding to the target point and delete the target polygon in the initial polygon set to obtain the target polygon set, so as to ensure that the polygons in the target polygon set are all located in the first region.
[0061] Optionally, determining the boundary between the first region and the second region in the target image includes: performing grid processing on the target image to obtain a grid image, where the grid image contains at least one grid for distinguishing the first region and the second region; determining the boundary between the first region and the second region by traversing at least one grid in the grid image.
[0062] In one alternative embodiment, the mask image of the map can be obtained first, such as Figure 4As shown, then perform grid processing on the mask image to obtain at least one grid that can divide the first area and the second area. Specifically, the light-colored area in the mask image, that is, the first area where walking is possible, can be represented by light-colored grids, and the dark-colored area in the mask image, that is, the second area where walking is not possible, can be represented by dark-colored grids, so as to obtain the grids corresponding to multiple grids that can distinguish the first area and the second area, that is, the above-mentioned boundary.
[0063] Optionally, by traversing at least one grid in the grid image, determining the boundary between the first area and the second area includes: traversing at least one grid in the grid image to obtain a target grid, where the target grid corresponds to the first area in the target image, and at least one grid adjacent to the target grid corresponds to the second area in the target image; determining that the area where the target grid is located is the boundary.
[0064] In an alternative embodiment, after obtaining the grid image, all grids in the grid image can be traversed. If the grid is in the first area and any one of the grids above (0, 1), below (0, -1), left (-1, 0), and right (1, 0) is in the second area, and if the grid is on the boundary, these grids can be marked as the grids at the boundary.
[0065] Further, after obtaining the grids at the boundary, the grids at the boundary can be traversed. The method of breadth-first search can be used to search the eight directions of the grid: above (0, 1), below (0, -1), left (-1, 0), right (1, 0), above-left (-1, 1), below-left (-1, -1), above-right (1, 1), and below-right (1, -1) to obtain a set of line segments at the boundary. According to the set of line segments, a set of first points corresponding to the boundary can be determined, and the first area can be segmented according to the set of first points to obtain a set of target polygons.
[0066] From the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.
[0067] In this embodiment, an image processing apparatus is further provided. This apparatus is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used hereinafter, the terms "unit" and "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0068] Figure 5 is a structural block diagram of an image processing apparatus according to an embodiment of the present invention. As Figure 5 shown, the apparatus includes:
[0069] An acquisition module 502, configured to acquire a target image, where the target image includes a first region and a second region. The first region is used to represent the region where the target object can walk, and the second region is used to represent other regions except the first region;
[0070] A determination module 504, configured to determine the boundary between the first region and the second region in the target image;
[0071] A processing module 506, configured to perform segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple target polygons in the set of target polygons do not intersect each other;
[0072] A generation module 508, configured to generate a target map based on the set of target polygons, where the target map is used to implement the pathfinding function of the target object.
[0073] Optionally, the processing module includes: an acquisition unit, configured to acquire a first point set corresponding to the boundary; a segmentation unit, configured to perform segmentation processing on the first region based on the first point set to obtain a set of target polygons.
[0074] Optionally, the segmentation unit is configured to perform segmentation processing on the first region based on the first point set to obtain an initial set of polygons; acquire the vertices and midpoints of each polygon in the initial set of polygons to generate a second point set; and screen the second point set based on the second region to obtain a set of target polygons.
[0075] Optionally, the segmentation unit is further configured to determine whether there is a target point in the second region in the second point set; in response to there being a target point in the second region in the second point set, acquire the target polygon corresponding to the target point; and delete the target polygon in the initial set of polygons to obtain a set of target polygons.
[0076] Optionally, the determination module includes: a processing unit configured to perform grid processing on a target image to obtain a grid image, where the grid image includes at least one grid for distinguishing a first region and a second region; a traversal unit configured to determine the boundary between the first region and the second region by traversing at least one grid in the grid image.
[0077] Optionally, the traversal unit is further configured to traverse at least one grid in the grid image to obtain a target grid, where the target grid corresponds to the first region in the target image, and at least one grid adjacent to the target grid corresponds to the second region in the target image; and determine the region where the target grid is located as the boundary.
[0078] It should be noted that the above-mentioned units and modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited thereto: the above-mentioned units and modules are all located in the same processor; or, the above-mentioned units and modules are respectively located in different processors in any combination.
[0079] An embodiment of the present invention further provides a non-volatile storage medium, in which a computer program is stored, where the computer program is configured to execute the steps in any one of the above method embodiments when running.
[0080] Optionally, in this embodiment, the above non-volatile storage medium can be configured to store a computer program for executing the following steps:
[0081] S1. Obtain a target image, where the target image includes a first region and a second region, the first region is used to represent the region where the target object can walk, and the second region is used to represent other regions except the first region;
[0082] S2. Determine the boundary between the first region and the second region in the target image;
[0083] S3. Perform segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple polygons in the set of target polygons do not intersect each other;
[0084] S4. Generate a target map based on the set of target polygons, where the target map is used to implement the pathfinding function of the target object.
[0085] Optionally, in this embodiment, the above non-volatile storage medium may include but is not limited to: various media such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.
[0086] An embodiment of the present invention further provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0087] Optionally, the above electronic device may further include a transmission device and an input / output device. Among them, the transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0088] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:
[0089] S1. Obtain a target image, where the target image includes a first area and a second area. The first area is used to represent the area where the target object can walk, and the second area is used to represent other areas except the first area;
[0090] S2. Determine the boundary between the first area and the second area in the target image;
[0091] S3. Based on the boundary, perform segmentation processing on the first area to obtain a set of target polygons, where the polygons in the set of target polygons do not intersect each other;
[0092] S4. Based on the set of target polygons, generate a target map, where the target map is used to implement the pathfinding function of the target object.
[0093] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated here.
[0094] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0095] In the above embodiments of the present invention, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
[0096] In several embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of units or modules can be in an electrical or other form.
[0097] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0098] In addition, each functional unit in various embodiments of the present invention can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.
[0100] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. An image processing method, characterized in that, The method includes: Obtain a target image, where the target image includes a first region and a second region, the first region is used to represent the area where the target object can walk, and the second region is used to represent other regions except the first region; Determine the boundary between the first region and the second region in the target image; Based on the boundary, perform segmentation processing on the first region to obtain a set of target polygons, where the multiple polygons in the set of target polygons do not intersect each other; Based on the set of target polygons, generate a target map, where the target map is used to implement the pathfinding function of the target object; Among them, performing segmentation processing on the first region based on the boundary to obtain a set of target polygons includes: Obtain a first point set corresponding to the boundary; Based on the first point set, perform segmentation processing on the first region to obtain an initial polygon set; Obtain the vertices and midpoints of each polygon in the initial polygon set to generate a second point set; Based on the second region, filter the second point set to obtain the set of target polygons, where the set of target polygons does not include the target polygon corresponding to the target point in the second region.
2. The method according to claim 1, wherein Based on the second region, filtering the second point set to obtain the set of target polygons includes: Determine whether there is a target point in the second region in the second point set; In response to the existence of a target point in the second region in the second point set, obtain the target polygon corresponding to the target point; Delete the target polygon in the initial polygon set to obtain the set of target polygons.
3. The method according to claim 1, characterized in that Determining the boundary between the first region and the second region in the target image includes: Perform grid processing on the target image to obtain a grid image, where the grid image includes at least one grid for distinguishing the first region and the second region; By traversing the at least one grid in the grid image, determine the boundary between the first region and the second region.
4. The method according to claim 3, characterized in that By traversing the at least one grid in the grid image, determining the boundary between the first region and the second region includes: Traverse the at least one grid in the grid image to obtain a target grid, where the target grid corresponds to the first region in the target image, and at least one grid adjacent to the target grid corresponds to the second region in the target image; Determine the region where the target grid is located as the boundary.
5. An image processing apparatus, characterized in that, The device includes: An acquisition module, configured to acquire a target image, where the target image includes a first region and a second region, the first region is used to represent the area where the target object can walk, and the second region is used to represent other regions except the first region; A determination module, configured to determine the boundary between the first region and the second region in the target image; A processing module, configured to perform segmentation processing on the first region based on the boundary to obtain a set of target polygons, where the multiple target polygons in the set of target polygons do not intersect each other; A generation module, configured to generate a target map based on the target polygon set, wherein the target map is used to implement the pathfinding function of the target object; Wherein, the processing module is configured to obtain a first point set corresponding to the junction; perform segmentation processing on the first region based on the first point set to obtain an initial polygon set; obtain the vertices and midpoints of each polygon in the initial polygon set to generate a second point set; screen the second point set based on the second region to obtain the target polygon set, wherein the target polygon set does not include the target polygon corresponding to the target point in the second region.
6. A non-volatile storage medium, characterized in that, A computer program is stored in the non-volatile storage medium, wherein the computer program is configured to execute the image processing method described in any one of claims 1 to 4 when run by a processor.
7. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to run the computer program to execute the image processing method described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and device for automatically generating map area link, equipment and storage medium
CN113521741A
Method and device for controlling way-finding of simulation object, and server
WO2018130135A1