Image recognition method and device

CN120641952APending Publication Date: 2025-09-12DJANGO ROBOTICS SHENZHEN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202480001183.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-12
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

When processing large maps, scaling causes the loss of boundary pixels, and unscaling causes slow calculations or excessive memory resources to be taken up, resulting in system performance degradation.

Method used

The image to be identified is divided into first and second type grids, and the first type grid is divided into multiple rectangles based on preset rules. The proximal edges of adjacent rectangles are determined as gateways, and a graph theory model is generated and the target path is determined.

Benefits of technology

The generated vector data is smaller, easy to transmit and save, and the calculation speed is similar to the scaled image, but it is more accurate, avoiding the problems of pixel loss and excessive memory usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120641952A_ABST
    Figure CN120641952A_ABST
Patent Text Reader

Abstract

The invention discloses an image recognition method and device and belongs to the technical field of computers. The image recognition method comprises the steps that a to-be-recognized image is recognized as a first type of grid and a second type of grid, pixels of the first type of grid are larger than a pixel threshold value, and pixels of the second type of grid are larger than the pixel threshold value; based on a preset rule, dividing an area formed by the first type of grids into a plurality of rectangles, and determining adjacent edges of any two adjacent rectangles as gateways, the gateways being used for determining whether a target object can enter a second rectangle from the first rectangle through the gateway between the first rectangle and the second rectangle; according to the gateway, a graph theory model is generated, and the vertex of the graph theory model is the gateway; and determining a target path in the to-be-recognized image based on the graph theory model, the starting point and the ending point.
Need to check novelty before this filing date? Find Prior Art

Description

Image recognition method and device Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to an image recognition method and device. Background Art

[0002] Grayscale images are widely used to record maps. Regions with larger grayscale values ​​are unreachable (black dots), while regions with smaller grayscale values ​​are reachable (white dots). The data interface can be abstracted as a two-dimensional array, and the A-star algorithm can be used for path calculation.

[0003] However, when a map is large and contains too many pixels, and limited computer memory and processor resources prevent it from being processed quickly, it may be necessary to scale it down before use. Some implementations of scaling techniques are lossy, resulting in the loss of boundary pixels. Without scaling, computations can be slow due to the large number of pixels, or excessive memory and processor resources can be used, leading to reduced system performance.

[0004] Summary of the Invention

[0005] The purpose of the embodiments of the present application is to provide an image recognition method and device that can solve the problems in related technologies such as scaling causing loss of boundary pixels, slow calculation without scaling, or occupying too much memory and processor resources, resulting in reduced system performance.

[0006] In a first aspect, the present application discloses an image recognition method, comprising:

[0007] Identify the image to be identified as a first type of grid and a second type of grid, wherein pixels of the first type of grid are greater than a pixel threshold, and pixels of the second type of grid are greater than the pixel threshold;

[0008] Based on a preset rule, the area formed by the first type of grid is divided into a plurality of rectangles, and adjacent edges of any two adjacent rectangles are determined as gateways, where the gateways are used to determine whether a target object can enter the second rectangle from the first rectangle via the gateway between the first and second rectangles;

[0009] generating a graph model according to the gateway, wherein the vertices of the graph model are the gateways;

[0010] Based on the graph theory model, the starting point and the terminal, a target path in the image to be identified is determined.

[0011] In a second aspect, an embodiment of the present application discloses an image recognition device, comprising:

[0012] An identification module, configured to identify the image to be identified as a first type of grid and a second type of grid, wherein pixels of the first type of grid are greater than a pixel threshold, and pixels of the second type of grid are greater than the pixel threshold;

[0013] a partitioning module, configured to divide the area formed by the first type of grid into a plurality of rectangles based on a preset rule, and to determine the adjacent edges of any two adjacent rectangles as gateways, wherein the gateways are used to determine whether a target object can enter the second rectangle from the first rectangle via the gateway between the first and second rectangles;

[0014] A generating module, configured to generate a graph model according to the gateway, wherein the vertices of the graph model are the gateways;

[0015] A determination module is used to determine a target path in the image to be identified based on the graph theory model, the starting point and the terminal.

[0016] In a third aspect, an embodiment of the present application discloses an electronic device comprising a processor, a memory, and a program or instruction stored on the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.

[0017] In an embodiment of the present application, the image to be identified is first identified as a first type of grid and a second type of grid, the pixels of the first type of grid being greater than a pixel threshold, and the pixels of the second type of grid being greater than a pixel threshold. Then, based on a preset rule, the area composed of the first type of grid is divided into multiple rectangles, and the adjacent edges of any two adjacent rectangles are determined as gateways. The gateway is used to determine whether the target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle. Then, based on the gateway, a graph model is generated, and the vertices of the image model are gateways. Finally, based on the graph model, the starting point and the terminal, the target path in the image to be identified is determined. The embodiment of the present application can be applied to various types of images. The generated grid is vector data, the data volume is smaller than that of a bitmap, and it is easy to transmit and save. Compared with the adjacency matrix of the scaled image, it is about the same speed, but more accurate. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] FIG1 is a flow chart of an image recognition method provided in an embodiment of the present application;

[0019] FIG2 is a schematic diagram of a detailed flow chart of an image recognition method provided in an embodiment of the present application;

[0020] FIG3 is a schematic diagram of a rectangular division method provided in an embodiment of the present application;

[0021] FIG4 is a schematic diagram showing coordinate representation of a rectangle vertex provided in an embodiment of the present application;

[0022] FIG5 is a schematic diagram of the first vertex of a rectangle provided in an embodiment of the present application;

[0023] FIG6 is a schematic diagram of a temporary mark of a block after generation provided by an embodiment of the present application;

[0024] FIG7 is a schematic diagram of black dot shielding provided in an embodiment of the present application;

[0025] FIG8 is a schematic diagram of point L provided in an embodiment of the present application;

[0026] FIG9 is a schematic diagram of a KL position without internal black spots provided by an embodiment of the present application;

[0027] FIG10 is a schematic diagram of point L provided in an embodiment of the present application;

[0028] FIG11 is a schematic diagram of selecting the maximum L value provided in an embodiment of the present application;

[0029] FIG12 is a schematic diagram of white table acceleration provided in an embodiment of the present application;

[0030] FIG13 is a schematic diagram of backfilling provided in an embodiment of the present application;

[0031] FIG14 is a schematic diagram of a partial correction provided in an embodiment of the present application;

[0032] Figures 15-16 are schematic diagrams of the number of generated blocks provided in an embodiment of the present application;

[0033] FIG17 is a schematic diagram of a block gap provided in an embodiment of the present application;

[0034] Figures 18-21 are schematic diagrams of bridge blocks provided in embodiments of the present application;

[0035] FIG22 is a schematic diagram of the number of generated blocks provided in an embodiment of the present application;

[0036] FIG23 is a detailed flowchart of block generation provided in an embodiment of the present application;

[0037] FIG24 is a schematic diagram of a gateway provided in an embodiment of the present application;

[0038] FIG25 is a schematic diagram of generating a graph theory model according to an embodiment of the present application;

[0039] FIG26 is a schematic diagram of vertices of a graph theory model provided in an embodiment of the present application;

[0040] FIG27 is a schematic diagram of an arc of a graph theory model provided in an embodiment of the present application;

[0041] FIG28 is a schematic diagram of global path planning provided by an embodiment of the present application;

[0042] Figures 29-31 are schematic diagrams of direction optimization provided in embodiments of the present application;

[0043] 32-33 are schematic diagrams of local path optimization provided in an embodiment of the present application;

[0044] FIG34 is a schematic diagram of the structure of an image recognition device provided in an embodiment of the present application;

[0045] Figure 35 is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The embodiments of the present application will be described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0047] The terms "first" and "second" in the specification and claims of this application may explicitly or implicitly refer to one or more of the features. Throughout the description of this application, unless otherwise specified, "plurality" means two or more. Furthermore, "and / or" in the specification and claims refers to at least one of the connected entities, and the character " / " generally indicates an "or" relationship between the connected entities.

[0048] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

[0049] In the description of this application, it should be noted that, unless otherwise expressly specified or limited, the terms "mounted," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; and internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in this application based on the specific circumstances.

[0050] The image recognition method and device provided in the embodiments of the present application are described in detail below with reference to specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0051] Figure 1 is a flow chart of an image recognition method provided by an embodiment of the present application. As shown in Figure 1 , the image recognition method may include the contents shown in S101 to S104.

[0052] In S101 , the image to be identified is identified as a first type grid and a second type grid, where pixels of the first type grid are larger than a pixel threshold, and pixels of the second type grid are larger than a pixel threshold.

[0053] As shown in Figure 2, the first type of grid may be a white grid, and the second type of grid may be a black grid. The white grid represents a passable area, and the black grid represents an impassable area.

[0054] In S102 , based on a preset rule, the area consisting of the first type of grids is divided into a plurality of rectangles, and the adjacent edges of any two adjacent rectangles are determined as gateways.

[0055] The gateway is used to determine whether the target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle. The target object can be a navigation object, such as a vehicle, pedestrian, robot, etc., which is not limited in this embodiment of the application.

[0056] In S103 , a graph model is generated based on the gateway, and the vertices of the graph model are the gateways.

[0057] In S104 , a target path in the image to be recognized is determined based on the graph theory model, the starting point and the terminal point.

[0058] That is, the target path, ie, the channel, in the image to be identified can be determined through the above steps so that the target object can pass through the channel.

[0059] In an embodiment of the present application, the image to be identified is first identified as a first type of grid and a second type of grid, the pixels of the first type of grid being greater than a pixel threshold, and the pixels of the second type of grid being greater than a pixel threshold. Then, based on a preset rule, the area composed of the first type of grid is divided into multiple rectangles, and the adjacent edges of any two adjacent rectangles are determined as gateways. The gateway is used to determine whether the target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle. Then, based on the gateway, a graph model is generated, and the vertices of the image model are gateways. Finally, based on the graph model, the starting point and the terminal, the target path in the image to be identified is determined. The embodiment of the present application can be applied to various types of images. The generated grid is vector data, the data volume is smaller than that of a bitmap, and it is easy to transmit and save. Compared with the adjacency matrix of the scaled image, it is about the same speed, but more accurate.

[0060] As shown in Figure 2, the image to be identified is first identified as a black and white grid, where the white grid is the passable area. The white area is constructed into multiple large rectangles and gateways, then mapped to the graph theory model, and finally the target path is output.

[0061] Specifically, the white area of ​​the map can be divided into rectangular blocks of varying sizes. The blocks are connected by gateways formed by adjacent faces, forming an irregular block network. Navigation objects can move freely within the blocks (in a straight line). To reach other blocks, they need to pass through the gateways.

[0062] The gateway can be used for width checking. If the width of the target object exceeds the width of the gateway, it cannot pass. The gateway can also be used for direction checking. If the direction from the starting point of the target object to the gateway is opposite to the direction of the block, it cannot pass.

[0063] In a possible embodiment of the present application, dividing the area composed of the first type of grid into multiple rectangles based on preset rules can include: determining the vertices of the rectangles based on the preset rules, the preset rules including at least one of reducing the number of rectangles, increasing the area of ​​the rectangles, and reducing the aspect ratio of the rectangles; and determining multiple rectangles based on the vertices.

[0064] That is, the generation of a large rectangle, i.e., a block, can be determined by determining the vertices. For example, the coordinates of two opposite vertices of the rectangle can be used to reduce the amount of calculation.

[0065] Because more blocks mean more vertices in the graph theory model, path planning becomes slow. Therefore, the number of blocks should be minimized. When the total white area is constant, the generated blocks should be larger. For example, the same map can produce very different results depending on the partitioning method. As shown in Figure 3, there are at least two partitioning methods: the one on the left has a larger maximum area, while the one on the right is more square. Here, we will try to maximize the block area.

[0066] In a possible embodiment of the present application, determining the vertices of a rectangle based on preset rules may include: obtaining the coordinates of the first vertices of multiple rectangles; determining the first rectangle with the largest area corresponding to the first vertex, and the second vertex in the first rectangle opposite to the first vertex based on the preset rules and any first vertex, until the area composed of the first type of grid is divided into multiple rectangles with areas greater than the area threshold.

[0067] To find these squares, we first need to determine how to represent them. Since the image coordinate system uses right as positive X and bottom as positive Y, we can use two coordinates to mark them: the upper left corner and the lower right corner, named K and L, respectively. Their positions in the image coordinate system and the pixel positions of the squares are shown in Figure 4. By identifying the vertices, we can quickly identify multiple rectangles.

[0068] As shown in Figure 5, first determine the K point: This is relatively easy; any white pixel will do. Each K point has at least one L that can form a block with it (the smallest being itself). As you can see, the same K point can have many Ls corresponding to it, but with different areas. The largest one needs to be filtered out. Also, it's important to note that blocks at different K points can overlap with blocks at other K points. This means that when a block is generated, blocks elsewhere will be affected. Therefore, after a block is generated, the corresponding area needs to be blacked out, as shown in Figure 6.

[0069] Since there can be no black dots inside the square, when K is determined, L is within a rectangular range with a width of w and a height of h. However, since there can be no black dots inside the square, many white dots are filtered out and the remaining optional L is shown in Figure 7.

[0070] However, among these points, the ones that have the potential to form the largest area all have a significant characteristic: they are all located at a corner. To calculate the maximum area Sm of this point, we only need to select the largest area among these finite points L, as shown in Figure 8.

[0071] It is worth noting that if there is no black dot inside, the final L is at the farthest point, as shown in Figure 9.

[0072] Since L is at the inflection point, in order to find the specific coordinates of this point, we define three variables: minimum width (kw), previous minimum width (pw), current row maximum width (hw), and the minimum value min. We take the minimum value of pw and hw. The pw and hw of the first row are equal. The calculation formula is as follows: kw = min(pw, hw)

[0073] As shown in Figure 10, whenever pw and kw are not equal, a new L is generated, which together with the L in the last row constitutes all Ls. The largest of them is a 5X5 rectangle, so the area of ​​the largest rectangle at this point is 25, as shown in Figure 11.

[0074] When calculating the initial area, we need to know the maximum possible area of ​​a point. If it is less than the previously generated maximum area, all L calculations for that point are skipped. Since we need to quickly know the initial w and h, we can construct a table that records the distance from the black dot in the X and Y directions. The XxY area of ​​the point is called the maximum possible area Smay. If Smay is less than the maximum area Smax, skip the L calculation for that point, as shown in Figure 12.

[0075] Since blocks generated at different positions may overlap, in order to eliminate the problem of repeated block generation, the area affected by the largest block in the current map can be painted black, as shown in Figure 13. This prevents black dots from being counted as other white blocks. In a possible implementation of the present application, after determining the first rectangle with the largest area corresponding to the first vertex and the second vertex in the first rectangle opposite to the first vertex based on preset rules and the first vertex, the method may further include: marking the area where the determined first rectangle is located, the mark is used to distinguish the first rectangle from the first type of grid; updating the area composed of the first type of grid, and the area does not include the marked area.

[0076] After backfilling, the white table needs to be updated. Regenerating a new white table is too costly, so a partial update can be performed, as shown in Figure 14.

[0077] The purpose of using blocks instead of pixels is to reduce the computational effort of image recognition, such as navigation models. At some complex edges, due to the complexity of the pixels, there are black and white pixels. If there is no restriction, allowing one white point to generate one block will result in too many blocks. Moreover, target objects such as robots, people, and vehicles cannot actually reach these areas, as shown in the boxed areas in Figure 15. The minimum area is 0.01m 2 The number of blocks generated is at least 1216, which makes the calculation more complex.

[0078] The number of blocks can be reduced by increasing the minimum area. As shown in Figure 16, the minimum area is 1m 2 , the number of blocks generated is 64. In other words, after increasing the minimum area, larger blocks are generated, resulting in fewer blocks. However, this brings another problem: gaps appear between many large blocks, as shown in the box in Figure 17, which will cause navigation to fail.

[0079] In order to solve the problem of gaps, in a possible embodiment of the present application, after dividing the area composed of the first type of grid into multiple rectangles based on preset rules, the method may also include: determining multiple bridge areas based on areas with an area smaller than an area threshold, and the bridge areas are used to connect two adjacent rectangles without adjacent sides; when there are at least two bridge areas between two adjacent rectangles without adjacent sides, determining the bridge area with the largest width as the target bridge area of ​​the two adjacent rectangles without adjacent sides.

[0080] In other words, you can set up multiple bridge areas, or bridge blocks. These blocks are smaller than the minimum area and are used specifically to connect two large blocks. They are produced in the order of connecting two large blocks. With the bridge block as the center, there are large blocks in all four directions: up, down, left, and right. Any two of them can be connected. The black box in Figure 18 indicates the bridge area.

[0081] At the same time, contact surface verification is required. The contact surface represents the width of the bridge; the wider the better. Because bridge blocks cannot connect to other bridge blocks, failure to verify this could result in a narrow bridge interrupting a wider bridge. Furthermore, a bridge that is too narrow will be difficult for robots and humans to cross, rendering it useless once generated. As shown in Figures 19-21, bridge blocks are selected based on their larger contact surface. The bridge blocks shown in the right image of Figure 19 and Figure 21 are selected.

[0082] When the minimum area is set to 1m 2 The generated bridge block is shown in Figure 22. The minimum area is 1m 2 The total number of blocks generated (large blocks + bridge blocks) is 123, which greatly reduces the number of blocks and the amount of calculation.

[0083] In the subsequent navigation model, it is necessary to estimate the cost of navigating across blocks. If the blocks are sorted solely by area, the generated blocks may have a higher length than a non-empty block, resulting in errors in the subsequent navigation path length calculation. Therefore, it is more desirable to limit the length-to-length ratio of the blocks.

[0084] A very low aspect ratio is called bad width (badWidth), which is calculated by taking the square root of half the minimum generated area (minAreaSize). The calculation formula is: badWidth = Math.sqrt(minAreaSize / 2);

[0085] At the same time, a score is determined, which is equal to 30% of the current area, and different penalties and rewards are given to different blocks:

[0086] Low aspect ratio: score = minimum area + score * aspect ratio;

[0087] High length-to-short ratio: score = current area * (1 + length-to-short ratio);

[0088] Finally, since both robots and humans have a minimum width limit, the minimum width of the possible navigable objects is also limited.

[0089] Taking the minimum block area of ​​2 as an example, the generation process is shown in Figure 23.

[0090] The blocks have been generated, but to build a graph model, we need to identify arcs—the connections between blocks. The simplest approach is to use adjacent edges between blocks as graph arcs. Draw adjacent edges between two blocks, creating gates leading to each other, as shown by the black box in Figure 24.

[0091] In one possible implementation of the present application, generating a graph theory model based on the gateway may include: extracting the gateway within each rectangle to obtain the vertices of the graph theory model, where the gateway is an area composed of first-type grids adjacent to the adjacent edges of any two adjacent rectangles; connecting two adjacent gateways and determining the connecting line as an arc of the graph theory model, where the arc of the graph theory model has a direction; and generating the graph theory model based on the vertices and arcs of the graph theory model.

[0092] In the previous graph model, vertices were directly required to calculate movement costs. However, if the vertices were square, it was impossible to determine the cost of moving from square 3 to square 2; we only knew that it was possible to move from 3 to 2. Therefore, gateways were used as vertices, and the connections between gateways were directed graph arcs. The estimated cost was the straight-line distance from the midpoint of a gateway to the midpoint of another gateway, as shown in Figure 25. The vertices of the graph model are shown in Figure 26, and the arcs in the graph model are shown in Figure 27. The global planned path is shown in Figure 28.

[0093] In a possible implementation of the present application, the image recognition method may further include: when the cosine of the angle between the arc of the graph theory model and the direction of the rectangle is positive, the target object is passable.

[0094] As shown in Figure 29, when the zone's direction is right, the gateway directly connects to the midpoint, forming a centerline. The angle distribution between the centerline and the zone's direction is shown in Figure 29, showing that any angle with a positive cosine value is safe to pass.

[0095] Among them, the passability is dynamic only when the left direction of the gateway is orthogonal to the direction of the area. As shown in Figure 30, it is possible to reach the other side only when the width of the overlapping part of the two gateways is greater than the width of the navigation object, and it can only move within a limited range.

[0096] As shown in Figure 31, K is the maximum value of ac and L is the minimum value of bd. If you go from top to bottom, the opposite is true. Only the overlapping areas are processed because the centerline direction filtering has filtered out the non-overlapping legal range.

[0097] In a possible implementation of the present application, the image recognition method may further include: when at least two gateways are located in the same rectangle and the target path passes through at least two gateways, modifying the target path to pass through the same rectangle.

[0098] In other words, local path optimization can be performed. When both gateways are on one edge of a block, the waypoint can be pushed inward by half the width of the navigation object, as shown in Figure 32.

[0099] Other optimizations may include taking only one gateway point, because a difference of 1 pixel between the gateway points may cause the target object, such as a vehicle or robot, to perform invalid directional deflection. As shown in FIG33 , only one gateway may be used.

[0100] It is worth noting that the image to be identified in the embodiment of the present application can be a grayscale image or an image in other formats, such as PNG, JPE, etc., as long as the pixel image can be output in the end.

[0101] Figure 34 is a schematic diagram of an image recognition device provided in an embodiment of the present application. As shown in Figure 34, the image recognition device may include: a recognition module 3501, a division module 3502, a generation module 3503, and a determination module 3504.

[0102] Among them, the recognition module 3501 is used to identify the image to be identified as a first type of grid and a second type of grid, the pixels of the first type of grid are greater than the pixel threshold, and the pixels of the second type of grid are greater than the pixel threshold; the division module 3502 is used to divide the area composed of the first type of grid into multiple rectangles based on preset rules, and determine the adjacent edges of any two adjacent rectangles as gateways, and the gateway is used to determine whether the target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle; the generation module 3503 is used to generate a graph model based on the gateway, and the vertices of the image model are gateways; the determination module 3504 is used to determine the target path in the image to be identified based on the graph model, the starting point and the end point.

[0103] In an embodiment of the present application, first, the recognition module 3501 identifies the image to be recognized as a first type of grid and a second type of grid, where the pixels of the first type of grid are greater than the pixel threshold, and the pixels of the second type of grid are greater than the pixel threshold. Then, the division module 3502 divides the area composed of the first type of grid into multiple rectangles based on preset rules, and determines the adjacent edges of any two adjacent rectangles as gateways. The gateway is used to determine whether the target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle. The generation module 3503 then generates a graph model based on the gateway, with the vertices of the image model as gateways. Finally, the determination module 3504 determines the target path in the image to be recognized based on the graph model, the starting point, and the terminal. The embodiment of the present application can be applied to various types of images. The generated grid is vector data, which has a smaller data volume than a bitmap, is easy to transmit and save, and is similar in speed to the adjacency matrix of the scaled image, but more accurate.

[0104] In one possible implementation of the present application, the division module 3502 is used to: determine the vertices of the rectangle based on preset rules, where the preset rules include at least one of reducing the number of rectangles, increasing the area of ​​the rectangle, and reducing the aspect ratio of the rectangle; and determine multiple rectangles based on the vertices.

[0105] In one possible implementation of the present application, the division module 3502 is used to: obtain the coordinates of the first vertices of multiple rectangles; based on preset rules and any first vertex, determine the first rectangle with the largest area corresponding to the first vertex, and the second vertex in the first rectangle opposite to the first vertex, until the area composed of the first type of grid is divided into multiple rectangles with areas greater than the area threshold.

[0106] In a possible implementation of the present application, the image recognition device may further include: a marking module and an updating module.

[0107] The marking module is used to mark the area where the determined first rectangle is located, and the mark is used to distinguish the first rectangle from the first type of grid; the updating module is used to update the area composed of the first type of grid, and the area does not include the marked area.

[0108] In a possible implementation of the present application, the image recognition device may further include: a second determination module and a third determination module.

[0109] Among them, the second determination module is used to determine multiple bridge areas based on areas with an area smaller than an area threshold, and the bridge areas are used to connect two adjacent rectangles without adjacent sides; the third determination module is used to determine the bridge area with the largest width as the target bridge area of ​​the two adjacent rectangles without adjacent sides when there are at least two bridge areas between the two adjacent rectangles without adjacent sides.

[0110] In one possible implementation of the present application, generation module 3503 is used to: extract the gateway within each rectangle to obtain the vertices of the graph theory model, where the gateway is an area composed of first-type grids adjacent to the adjacent edges of any two adjacent rectangles; connect two adjacent gateways and determine the connecting line as an arc of the graph theory model, where the arc of the graph theory model has a direction; and generate a graph theory model based on the vertices and arcs of the graph theory model.

[0111] In a possible implementation manner of the present application, the image recognition device may further include: a fourth determination module.

[0112] The fourth determining module is configured to determine that the target object is passable when the cosine of the angle between the arc of the graph theory model and the direction of the rectangle is positive.

[0113] In a possible implementation of the present application, the image recognition device may further include: a correction module.

[0114] The correction module is configured to modify the target path to pass through the same rectangle when at least two gateways are located within the same rectangle and the target path passes through at least two gateways.

[0115] The image recognition device provided in the embodiment of the present application can implement the various processes implemented in the method embodiments of Figures 1-33 and achieve the same technical effects. To avoid repetition, they will not be described here.

[0116] As shown in Figure 35, an embodiment of the present application also provides an electronic device 3600, including a processor 3601, a memory 3602, and a program or instruction stored in the memory 3602 and executable on the processor 3601. When the program or instruction is executed by the processor 3601, the various processes of the above-mentioned image recognition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, they will not be described here.

[0117] The present application also provides a storage medium storing a program or instruction. When executed by a processor, the program or instruction implements the various processes of the image recognition method provided in any of the above-described embodiments. The same technical effects can be achieved, and to avoid repetition, they are not described here.

[0118] The processor is the processor in the electronic device described in the above embodiment. The storage medium includes a computer storage medium, such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.

[0119] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image recognition method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0120] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0121] An embodiment of the present application further provides a computer program / program product, which is stored in a storage medium. The computer program / program product is executed by at least one processor to implement the various processes of the above-mentioned image recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0122] An embodiment of the present application further provides a processing device, which is configured to execute the various processes of the above-mentioned image recognition method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0123] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device comprising the element. In addition, it should be noted that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in the opposite order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0125] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. An image recognition method, characterized in that, Including: Identifying the image to be recognized as a first type of grid and a second type of grid, where the pixels of the first type of grid are greater than a pixel threshold, and the pixels of the second type of grid are greater than the pixel threshold; Based on a preset rule, dividing the area composed of the first type of grid into multiple rectangles, and determining the adjacent sides of any two adjacent rectangles as gateways, where the gateways are used to determine whether a target object can enter the second rectangle from the first rectangle via the gateway between the first rectangle and the second rectangle; Generating a graph theory model according to the gateway, where the vertices of the image model are the gateways; Determining a target path in the image to be recognized based on the graph theory model, a starting point, and a terminal.

2. The method according to claim 1, wherein The dividing the area composed of the first type of grid into multiple rectangles based on the preset rule includes: Determining the vertices of the rectangles based on a preset rule, where the preset rule includes at least one of reducing the number of rectangles, increasing the area of the rectangles, and decreasing the aspect ratio of the rectangles; Determining multiple rectangles based on the vertices.

3. The method according to claim 2, wherein The determining the vertices of the rectangles based on the preset rule includes: Obtaining the coordinates of the first vertices of multiple rectangles; Based on the preset rule and any one of the first vertices, determining the first rectangle with the largest area corresponding to the first vertex, and the second vertex opposite to the first vertex in the first rectangle, until the area composed of the first type of grid is divided into multiple rectangles with an area greater than an area threshold.

4. The method according to claim 3, characterized in that, After determining the first rectangle with the largest area corresponding to the first vertex and the second vertex opposite to the first vertex in the first rectangle based on the preset rule and the first vertex, the method further includes: Marking the area where the determined first rectangle is located, where the marking is used to distinguish the first rectangle from the first type of grid; Updating the area composed of the first type of grid, where the area does not include the marked area.

5. The method according to claim 1, wherein After dividing the area composed of the first type of grid into multiple rectangles based on the preset rule, the method further includes: Determining multiple bridge areas based on the areas smaller than the area threshold, where the bridge areas are used to connect two adjacent rectangles without adjacent sides; In the case where there are at least two bridge areas between two adjacent rectangles without adjacent sides, determining the bridge area with the largest width as the target bridge area between the two adjacent rectangles without adjacent sides.

6. The method according to claim 1, wherein The generating a graph theory model according to the gateway includes: Extracting the gateways in each rectangle to obtain the vertices of the graph theory model, where the gateway is the area composed of the first type of grid adjacent to the adjacent sides of any two adjacent rectangles; Connecting two adjacent gateways, and determining the connecting line as the arc of the graph theory model, where the arc of the graph theory model has a direction; Generating the graph theory model based on the vertices of the graph theory model and the arcs of the graph theory model.

7. The method according to claim 1, wherein The method further includes: In the case where the cosine of the angle between the arc of the graph theory model and the direction of the rectangle is positive, the target object is passable.

8. The method according to claim 1, characterized in that, The method further includes: In the case where at least two of the gateways are within the same rectangle and the target path passes through the at least two gateways, modify the target path to pass through the interior of the same rectangle.

9. An image recognition device, characterized in that, Comprising: An identification module, configured to identify a to-be-identified image as a first type of grid and a second type of grid, wherein pixels of the first type of grid are greater than a pixel threshold, and pixels of the second type of grid are greater than the pixel threshold; A partitioning module, configured to divide, based on a preset rule, a region composed of the first type of grids into multiple rectangles, and determine an adjacent edge between any two adjacent rectangles as a gateway, where the gateway is used to determine Whether a target object can enter a second rectangle from a first rectangle via the gateway between the first rectangle and the second rectangle; A generation module, configured to generate a graph theory model according to the gateway, where vertices of the image model are the gateways; A determination module, configured to determine a target path in the to-be-identified image based on the graph theory model, a starting point, and a terminal point.

10. An electronic device, characterized in that, Comprising a processor, a memory, and a program or instruction stored on the memory and executable on the processor, where when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1-8 are implemented.