A path search method, device and equipment
By converting the layout diagram of the target area into a matrix and performing convolution processing, the existing path search algorithm is solved and the problem of inefficient and waste of computing resources is achieved, and the effect of quickly finding the correct path is achieved.
Patent Information
- Application Number
- CN202110308067.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-23
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2041-03-23
AI Technical Summary
Existing path search algorithms may try multiple paths before finding the correct path, which is blind, resulting in wasteful computing resources and inefficient.
By converting the layout diagram of the target area through which the start and end points passes into a matrix, and convolution is performed through the path feature matrix, the matrix is updated until it is stable, and the target path is determined.
This method can quickly find a correct path while saving computing resources, improving path search efficiency.
Smart Images

Figure CN115115078B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and relates to but is not limited to a path search method, device, and equipment. Background Art
[0002] There are currently two main path search algorithms: breadth-first search algorithm and depth-first search algorithm.
[0003] Breadth-first search algorithm: Starting from the starting point, find all the positions that can be reached in one step, record these positions, and then start from these positions to find all the positions that can be reached by taking another step (that is, 2 steps from the starting point), and continue until the target point is found, and then find a path from these recorded positions (like a tree); this algorithm can find one or all shortest paths, but it needs to record a large number of positions and use a lot of memory.
[0004] Depth-first search algorithm: Start from the entrance and explore forward in a certain direction. If you can get through, continue to move forward; otherwise, return along the original path (backtracking), change the direction and continue to explore until all possible paths are explored. If you happen to explore the exit at a certain step, you have found the path from the entrance to the exit. In order to ensure that you can return along the original path at any point and prevent an infinite loop, you need to use a stack to save a large number of records. To solve the shortest path, you must search for all paths to the exit and compare them to get the shortest distance path. This will inevitably require an increase in data space to save the current shortest path during the search process, which increases the space complexity.
[0005] Currently, existing algorithms may have tried multiple paths before finding the correct path, which is somewhat blind, wastes computing resources, and is inefficient. Summary of the invention
[0006] The present application provides a path search method, device, and equipment that can quickly find a correct path while saving computing resources.
[0007] The technical solution of the embodiment of the present application is implemented as follows:
[0008] The present application provides a path search method, including:
[0009] Converting a layout diagram of a target area passed by a starting point and an end point into a first matrix; elements of the first matrix represent position points included in the layout diagram;
[0010] Expanding the first matrix according to the starting point and the end point to obtain a second matrix;
[0011] Convolutionally processing the second matrix through at least one path characteristic matrix to obtain a third matrix;
[0012] When the third matrix is different from the first matrix, the first matrix is updated to the third matrix, and the updated first matrix is further expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convolved with the path feature matrix to obtain a new third matrix, until the third matrix is the same as the first matrix;
[0013] Based on the third matrix, a target path from the starting point to the end point is determined.
[0014] The present application provides a path search device, the device comprising:
[0015] A conversion module, used to convert a layout diagram of a target area passed by a starting point and an end point into a first matrix; elements of the first matrix represent position points included in the layout diagram;
[0016] An expansion module, used for expanding the first matrix according to the starting point and the end point to obtain a second matrix;
[0017] A convolution module, configured to perform convolution processing on the second matrix through at least one path feature matrix to obtain a third matrix;
[0018] an updating module, configured to update the first matrix to the third matrix when the third matrix is different from the first matrix, until the third matrix is the same as the first matrix;
[0019] The expansion module is further used to continue expanding the updated first matrix according to the starting point and the end point to obtain a new second matrix;
[0020] The convolution module is further used to continue to perform convolution processing on the new second matrix through the path feature matrix to obtain a new third matrix;
[0021] A determination module is used to determine a target path from the starting point to the end point based on the third matrix.
[0022] An embodiment of the present application further provides an electronic device, including: a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the above-mentioned path search method when executing the program.
[0023] An embodiment of the present application further provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned path search method is implemented.
[0024] The path search method, device, equipment and storage medium provided in the present application convert the layout diagram of the target area passed by the starting point and the end point into a first matrix; the elements of the first matrix represent the position points included in the layout diagram; the first matrix is expanded according to the starting point and the end point to obtain a second matrix, and the second matrix is convolved by at least one path feature matrix to obtain a third matrix; when the third matrix is different from the first matrix, the first matrix is updated to the third matrix, and the updated first matrix is continued to be expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convolved by the path feature matrix to obtain a new third matrix until the third matrix is the same as the first matrix; based on the third matrix, the target path from the starting point to the end point is determined; thereby, the matrix after the conversion of the target area is convolved by the path feature matrix, and the passable path in the layout of the target area is purposefully found, and the target path from the specified starting point to the end point in the target area is quickly found, which can save computing resources while quickly finding a correct path and improving the efficiency of path search. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 An optional structural diagram of a path search system provided in an embodiment of the present application;
[0026] Figure 2 An optional flowchart of a path search method provided in an embodiment of the present application;
[0027] Figure 3 A schematic diagram of an optional layout of a target area provided in an embodiment of the present application;
[0028] Figure 4 An optional flowchart of a path search method provided in an embodiment of the present application;
[0029] Figure 5 An optional flowchart of a path search method provided in an embodiment of the present application;
[0030] Figure 6 An optional flowchart of a path search method provided in an embodiment of the present application;
[0031] Figure 7 A schematic diagram of an optional layout of a target area provided in an embodiment of the present application;
[0032] Figure 8 An optional schematic diagram of a target path provided in an embodiment of the present application;
[0033] Fig. 9A schematic diagram of an optional structure of a path search device provided in an embodiment of the present application;
[0034] Fig.10 An optional structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the specific technical solution of the application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application, but are not used to limit the scope of the present application.
[0036] The embodiments of the present application can provide a path search method and device, equipment and storage medium. In practical applications, the path search method can be implemented in a path search device, and each functional entity in the path search device can be collaboratively implemented by hardware resources of an electronic device (such as a terminal device), such as computing resources such as a processor, and communication resources (such as for supporting various communication methods such as optical cables and cellular).
[0037] The path search method provided in the embodiment of the present application is applied to a path search system, and the path search system is composed of a business system and a path search system.
[0038] As an example, the structure of data processing can be as follows Figure 1 As shown, it includes: a client 10 and a path search terminal 20.
[0039] In one example, the client 10 and the path search end 20 may be the same physical entity; in one example, Figure 1 As shown, the client 10 and the path search end 20 are different physical entities, and the client 10 and the path search end 20 interact with each other through a network 30 .
[0040] Here, the client 10 is installed with an application capable of inputting layout information or outputting path information, and the user operates the application to send a path search request to the path search terminal 20. The path search terminal performs a path search on the layout of the target area corresponding to the layout information based on the received path search request.
[0041] In the present application embodiment, based on Figure 1In the path search system shown, the path search end converts a layout diagram of a target area passed by a starting point and an end point into a first matrix; the elements of the first matrix represent the position points included in the layout diagram; the first matrix is expanded according to the starting point and the end point to obtain a second matrix, and the second matrix is convolved with at least one path feature matrix to obtain a third matrix; when the third matrix is different from the first matrix, the first matrix is updated to the third matrix, and the updated first matrix is continued to be expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convolved with the path feature matrix to obtain a new third matrix, until the third matrix is the same as the first matrix; based on the third matrix, the target path from the starting point to the end point is determined, and the target path is sent to the client.
[0042] The path search method provided by the present application makes up for the deficiencies of the prior art and can quickly find a pass path in a target area. In addition, the path search method provided by the embodiment of the present application can be used in application scenarios such as maze games and calculating the path between two points in a map.
[0043] Next, combine Figure 1 The schematic diagram of the path search system shown in the figure illustrates various embodiments of the path search method and apparatus, device and storage medium provided in the embodiments of the present application.
[0044] This embodiment provides a path search method, which is applied to a path search device, wherein the path search device can be implemented on an electronic device. The function implemented by the method can be implemented by calling a program code by a processor in the electronic device, and of course the program code can be stored in a computer storage medium. It can be seen that the electronic device at least includes a processor and a storage medium.
[0045] The electronic device may be any device with information processing capabilities. In one embodiment, the electronic device may be a smart terminal, such as a notebook or other electronic device with wireless communication capabilities, an AR / VR device, or a mobile terminal. In another embodiment, the electronic device may also be a terminal device with computing functions that is not easy to move, such as a desktop computer, a desktop computer, etc.
[0046] Of course, the embodiments of the present application are not limited to being provided as methods and hardware, and there may be multiple implementation methods, such as being provided as a storage medium (storing instructions for executing the path search method provided by the embodiments of the present application).
[0047] Figure 2 A schematic diagram of the implementation flow of a path search method according to an embodiment of the present application is shown in FIG. Figure 2 As shown, the method comprises the following steps:
[0048] S201, converting a layout diagram of a target area passed by a starting point and an end point into a first matrix;
[0049] The elements of the first matrix represent the location points included in the layout diagram.
[0050] The path search device converts the layout diagram of the target area into a first matrix having the same layout as the target area, wherein each element in the first matrix represents each position point in the layout diagram of the target area. In one example, the target area includes M*N position points, and the first matrix is an M*N matrix.
[0051] The position points of the elements in the first matrix are unit areas in the target area, that is, the target area is composed of position points. Here, the target area can be a maze or a partial area in a map.
[0052] In one example, the target area may be a maze, the start point and the end point are specified by the system, and the location point is a grid of the maze.
[0053] In one example, the target area is a partial area in a map, the starting point can be selected by the user and can be the user's current location, and the end point is selected by the user and the location point is a grid on the map.
[0054] In the embodiment of the present application, when the size of the path and obstacle in the layout diagram of the target area does not match the size of the location point, the path search device can convert the layout diagram into a matrix graphic according to the size of the location point, and determine the first matrix based on the matrix graphic. In one example, the target area can be a maze location point, and the layout diagram of the maze is as follows: Figure 3 As shown in 301, 302 and 303 are the starting point and the end point respectively. After the path search device converts the layout diagram of the maze according to the position point, the obtained matrix diagram is as shown in Figure 3 As shown in 304, the elements corresponding to the area 305 in the first matrix corresponding to the matrix graphic 304 are
[0055] In an embodiment of the present application, when the location point is a grid in a map, and the size of the area occupied by a route is different from the size of the grid, the area occupied by the route can be preprocessed so that the size of the area occupied by the route is the same as the size of the grid.
[0056] S202, expanding the first matrix according to the starting point and the end point to obtain a second matrix, and performing convolution processing on the second matrix through at least one path feature matrix to obtain a third matrix;
[0057] After the path search device determines the first matrix, it expands the first matrix according to the location points of the starting point and the end point, adds two rows of elements, and adds two columns of elements. Among the added elements, the values of the elements corresponding to the starting point and the elements corresponding to the end point are first values, indicating that the location points of the starting point and the end point are feasible.
[0058] Here, the expansion of the first matrix is to prepare for the next convolution. After the first matrix is expanded once, it can ensure that the number of rows and columns of the third matrix after the convolution is equal to the original first matrix.
[0059] Here, the first value may be 1, and the second value may be 0. The first value and the second value may also be other values, and the present application does not make any setting for the selection of the first value and the second value.
[0060] In one example, when the size of the first matrix is M*N, the size of the second matrix obtained by expanding the first matrix is (M+2)*(N+2).
[0061] After obtaining the second matrix, the path search device performs convolution processing on the second matrix through the path feature matrix to obtain a third matrix V2. The path feature matrix can reflect the characteristics of the target position point in the target path, and the path feature matrix is selected based on whether a position point is a blind end. The path feature matrix in the embodiment of the present application includes one or more.
[0062] In one example, the pathway feature matrix includes f indicates that the target position point itself is feasible and is feasible with adjacent position points on the non-diagonal line.
[0063] In one example, the pathway feature matrix includes: and Among them, f0 represents that the target position point itself is in a feasible state, and f1 represents that it is accessible to adjacent position points on the non-diagonal line.
[0064] In one example, the pathway feature matrix includes: and Among them, f2 represents that the target position point is passable with two or more of the four adjacent position points in the upper, lower, left and right directions.
[0065] In the embodiment of the present application, no limitation is imposed on the path characteristic matrix.
[0066] S203, determining whether the third matrix is the same as the first matrix;
[0067] When the third matrix is different from the first matrix, the first matrix is updated to the third matrix. Here, after the first matrix is updated to the third matrix, S202 is performed based on the updated first matrix, and the updated first matrix is continuously expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convoluted by the path feature matrix to obtain a new third matrix, until the third matrix is the same as the first matrix. The processing of each iteration is shown in S202.
[0068] After the path search device obtains the third matrix V2 based on the first iteration, it compares the third matrix V2 with the first matrix V0. When the third matrix V2 and the first matrix V0 are different, V2 is used as the new first matrix V01, and the second iteration is completed through the processing of S202 to obtain a new third matrix V21, and it is determined whether the third matrix V21 is the same as the first matrix V01. When they are different, the third matrix V21 is used as the new first matrix V02, and the next iteration is completed through the processing of S202 until the third matrix obtained again is the same as the first matrix.
[0069] In the embodiment of the present application, convolution of the first matrix and subsequent processing are to perform feature judgment on all position points in the current matrix, and each cycle, the length of the branch of all the inaccessible position points will be shortened by 1. This is repeated until there is no branch shortening before and after the processing, at which time all the inaccessible position points are removed, and only feasible paths remain.
[0070] S204: Determine a target path from the starting point to the end point based on the third matrix.
[0071] When the third matrix obtained after multiple iterations is the same as the first matrix, the current third matrix is determined as the target matrix. At this time, the state of the elements in the third matrix is stable, and the third matrix is processed in S202 again, and the values of the elements in the third matrix no longer change. The values of the elements in the third matrix can represent whether each position point in the target area meets the characteristics of the path.
[0072] In an embodiment of the present application, the target path may include one or more paths. In one example, the target path is a navigable path from a starting point to an end point in a target area. In one example, the target path is the shortest path from a starting point to an end point in a target area.
[0073] In some embodiments, the implementation of S204 includes: determining a target element in the third matrix whose value is the first value; and connecting position points corresponding to the target element to obtain the target path.
[0074] Here, the element whose value in the third matrix is the first value is the target element, and the position point corresponding to the target element is the target position point that can constitute the target path, and the path constituted by the target position point is the target path.
[0075] The path search method provided in the embodiment of the present application converts the layout diagram of the target area passed by the starting point and the end point into a first matrix; the elements of the first matrix represent the position points included in the layout diagram; the first matrix is expanded according to the starting point and the end point to obtain a second matrix, and the second matrix is convolved by at least one path feature matrix to obtain a third matrix; when the third matrix is different from the first matrix, the first matrix is updated to the third matrix, and the updated first matrix is continued to be expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convolved by the path feature matrix to obtain a new third matrix until the third matrix is the same as the first matrix; based on the third matrix, the target path from the starting point to the end point is determined; thereby, the matrix after the conversion of the target area is convolved by the path feature matrix, and the passable path in the layout diagram of the target area is purposefully searched, and the target path from the specified starting point to the end point in the target area is quickly found, which can save computing resources while quickly finding a correct path and improving the efficiency of path search.
[0076] In some embodiments, Figure 4 As shown, before S202, it also includes:
[0077] S205, obtaining access conditions;
[0078] The path condition includes: the position point state of the target position point is a feasible state and the position points adjacent to the target position point are in a feasible state.
[0079] S206: Determine the pathway characteristic matrix according to the pathway conditions.
[0080] In the embodiment of the present application, the path feature matrix may be a 3*3 matrix. Here, the 3*3 matrix can be used to determine the connectivity between a location point and an adjacent location point.
[0081] The access conditions include any one of the following conditions:
[0082] Condition 1: If the position state of the target position point is a feasible state, then the value of the element corresponding to the target position point in the path feature matrix is 1. At this time, the corresponding path feature matrix
[0083] Condition 2: If two or more of the four adjacent positions to the target position are in a feasible state, then the value of the element corresponding to two or more of the four adjacent positions to the target position in the path feature matrix is 1. In this case, the path feature matrix
[0084] Condition 3: If two or more of the four position points in the diagonal direction adjacent to the target position point are in a feasible state, then the value of the element corresponding to two or more of the four position points in the diagonal direction adjacent to the target position point in the path feature matrix is 1. In this case, the path feature matrix
[0085] Condition 4: If two or more of the position points above the target position point and the three position points on the lower left and lower right are feasible, then the value of the element corresponding to the position point above the target position point and the three position points on the lower left and lower right in the path feature matrix is 1. At this time, the path feature matrix
[0086] Condition 5: If two or more of the position points adjacent to the left of the target position point and the three position points on the upper right and lower right are feasible, then the value of the element corresponding to the position point adjacent to the left of the target position point and the three position points on the upper right and lower right in the path feature matrix is 1. At this time, the path feature matrix
[0087] Condition 6: If two or more of the position points below the target position point and the three position points on the upper left and upper right are feasible, then the value of the element corresponding to the position point below the target position point and the three position points on the upper left and upper right in the path feature matrix is 1. At this time, the path feature matrix
[0088] Condition 7: If two or more of the adjacent positions on the right of the target position and the three positions on the upper left and lower left are feasible, then the values of the elements corresponding to the adjacent positions on the right of the target position and the three positions on the upper left and lower left in the path feature matrix are 1. In this case, the path feature matrix
[0089] In practical applications, the implementation of S205 and S206 is located before the convolution of the second matrix by at least one path feature matrix in S202, and there is no limitation on the execution order of S205 and S206 and other steps.
[0090] In some embodiments, the implementation of S201 is as follows: Figure 5 As shown, including:
[0091] S2011, obtaining the position points in the layout diagram and the position point status of each position point;
[0092] The position point status includes: a feasible state and an infeasible state.
[0093] In the embodiment of the present application, the layout of the target area includes multiple location points, and each location point is characterized by a location point state as to whether the location point is passable. When the location point state is a feasible state, it indicates that the corresponding location point is passable, and when the location point state is an infeasible state, it indicates that the corresponding location point is infeasible. Among them, when a location point has one of the following conditions, the location point state of the location point is an infeasible state: there is an obstacle, congestion, etc.
[0094] The path search device detects whether there are obstacles or congestion at each location point. If there are obstacles, the location point state of the location point is determined to be an infeasible state. Otherwise, the location point state of the location point is determined to be a feasible state.
[0095] S2012. Set the value of each element in the first matrix according to the position point status of each position point.
[0096] The path search device sets the value of the element corresponding to each position point according to the position point status of each position point, wherein the value of the element is different when the position point status is different.
[0097] In one example, the implementation of S2012 includes: setting the value of the first element in the first matrix to a first value; the first element is an element representing a location point where the traffic state is a feasible state; setting the value of the second element in the first matrix to a second value; the second element is an element in the first matrix other than the first element; the first value is different from the second value.
[0098] When the position point state of the position point is a feasible state, the corresponding element is the first element, and the value of the first element is the first value. When the position point state of the position point is an infeasible state, the corresponding element is the second element, and the value of the second element is the second value.
[0099] In one example, the first value is 1 and the second value is 0. In one example, the first value is 0 and the second value is 1.
[0100] In some embodiments, the implementation of expanding the first matrix according to the starting point and the end point to obtain the second matrix in S202 includes: adding elements to the edge of the first matrix; setting the value of the third element representing the starting point and the end point in the added elements to the first value; and setting the value of the fourth element other than the third element in the added elements to the second value.
[0101] Here, the first value may be 1, and the second value may be 0. When the first value is 1, it can be ensured that the determination of the boundary connectivity of the first matrix is not affected.
[0102] In one example, the first matrix The starting point is above the second column of the first row, and the end point is below the fourth column of the fourth row. After adding elements to the edge of the first matrix V0, the resulting matrix is The element corresponding to the position point above the first row and second column and the element below the fourth row and fourth column are taken as the third element, the value of the third element is set to 1, and the value of the fourth element other than the third element in the added elements is set to 0, then the second matrix is obtained.
[0103] In some embodiments, the implementation of convolving the second matrix with at least one pathway feature matrix in S202 to obtain the third matrix includes: convolving the second matrix with each pathway feature matrix in the at least one pathway feature matrix with a convolution kernel to obtain at least one feature map matrix; integrating the at least one feature map matrix to obtain the third matrix.
[0104] The path search device uses the path feature matrix as the convolution kernel, and convolves the second matrix with a step size of 1 to obtain the corresponding feature map matrix. Here, in the case of only one feature map matrix, the values of the elements in the feature map matrix are adjusted based on the element threshold, and the feature map matrix after the element adjustment is used as the third matrix. In the case of multiple feature map matrices, the values of the elements in each feature map matrix are adjusted based on the element threshold, and the feature maps after the element adjustment are merged to obtain the third matrix. In actual applications, users can set the step size according to actual needs.
[0105] Based on the fact that the convolution kernels of each feature map matrix are different but the sizes of the convolution kernels are the same, the number of rows and columns of the feature map matrix relative to the second matrix are both less than 2, and the dimension of the feature map matrix is the same as the dimension of the first matrix. The dimension of the third matrix after the feature map matrices are merged is the same as the dimension of the first matrix.
[0106] In some embodiments, integrating the at least one feature map matrix to obtain a third matrix includes: comparing each element in the at least one feature map matrix with an element threshold; adjusting elements greater than or equal to the element threshold to a first value; adjusting elements less than the element threshold to a second value; and multiplying corresponding elements in the feature map matrix after element adjustment to obtain the third matrix.
[0107] Here, the element threshold value can be set according to actual conditions. In one example, the element threshold value is 2.
[0108] Taking the element threshold of 2 as an example, when the value of an element in the feature map matrix is greater than or equal to 2, the value of the element is adjusted to 1, and when the value of the element in the feature map matrix is less than 2, the value of the element is adjusted to 0.
[0109] After adjusting the value of each element in the feature map matrix, the path search device multiplies the corresponding elements in multiple feature map matrices to obtain a third matrix.
[0110] The path search method provided by the embodiment of the present application has a small number of iterations and a high search efficiency for finding the target path. In practical applications, the path search method provided by the embodiment of the present application uses fewer computing resources, and therefore can be implemented by a graphics processing unit (GPU).
[0111] Below, taking the target area as a maze as an example, the path search method provided in the embodiment of the present application is further explained.
[0112] The path search method provided in the embodiment of the present application uses convolution to find the target path, including: using a binary two-dimensional matrix to represent the maze, 0 indicates that there is an obstacle at the position point, 1 indicates that the position point is a channel, and the channel path width of the matrix is 1 (if the width of the channel path is not 1, the width of the channel path can be made 1 through some preprocessing), then the passable position points and the inpassable position points can be represented by different feature elements, if the maze matrix is convoluted and scanned with the path feature matrix as the convolution kernel, in the convolution result, if a certain position point meets the passing feature, then the position point is the current passable position point, set to 1, otherwise it is set to 0. Iterate in this way until the maze matrix before and after the iteration remains unchanged, at which time all the position points on the infeasible path of the maze are set to 0, leaving only the position points on the feasible path with a value of 1. Here, the passing feature is that if a position point is connected, then among all the position points adjacent to it, at least two elements corresponding to the position points are 1, and these two points are not adjacent in the horizontal and vertical directions. Among them, the passing path condition can be determined based on the passing feature.
[0113] like Figure 6As shown, the path search method provided in the embodiment of the present application includes:
[0114] S601. Set a maze matrix and a path feature matrix.
[0115] Here, the maze matrix is the first matrix.
[0116] S602: Expand the maze matrix according to the entrance and exit of the maze.
[0117] The expanded maze matrix is the second matrix.
[0118] S603, convolve the maze matrix through the path feature matrix to obtain a feature map matrix.
[0119] Here, the number of feature map matrices is the same as the number of pathway feature matrices. The maze matrix is convolved with each pathway feature matrix as a convolution kernel to obtain a feature map matrix corresponding to each pathway feature matrix.
[0120] S604, integrating the feature map matrix to obtain a new maze matrix.
[0121] The new maze matrix is the third matrix.
[0122] S605. Determine whether the new maze matrix is equal to the maze matrix before expansion?
[0123] If they are equal, execute S606; if they are not equal, execute S602 based on the new maze matrix.
[0124] S606: Determine a target path based on the new maze matrix.
[0125] Here, the position points with corresponding values of 1 in the maze matrix are connected to obtain the target path. The maze path may include one or more paths.
[0126] The above path search method is described below through different examples.
[0127] Example 1
[0128] When two adjacent position points in the horizontal direction and the vertical direction are 1, the position points are connected, and when two adjacent position points in the diagonal direction are 1, the position points are not connected.
[0129] S601A, set the maze matrix A0 and the path feature matrix.
[0130] The maze is represented as a two-dimensional binary matrix A0, where the elements with a value of 1 in A0 represent that the corresponding position point is a channel, and the elements with a value of 0 in A0 represent that the corresponding position point is an obstacle.
[0131] The conditions of the target location point include: condition 1 and condition 2.
[0132] Condition 1: The target location is a passable location, that is, the value of the element corresponding to the location is 1, then the corresponding path feature matrix
[0133] Condition 2: If the values of the elements corresponding to two or more of the four adjacent position points above, below, left, and right of the target position point are 1, then the path feature matrix
[0134] S602A, expand the maze matrix A0 to obtain the maze matrix A1.
[0135] The maze matrix is expanded at the edge with a width of 1, the position points corresponding to the entrance and exit are filled with 1, and the other position points are filled with 0, to obtain a new maze matrix A1.
[0136] S603A, convolve the maze matrix A1 through the path feature moment to obtain a feature map matrix.
[0137] The maze matrix is convolved with the path feature matrix f0 and the path feature matrix f1 to obtain the feature map matrix F0 and the feature map matrix F1. The maze matrix A1 is convolved with the path feature matrix f0 and f1 as the convolution kernel with a step size of 1.
[0138] S604A, integrate the feature map matrix to obtain a processed new maze matrix A2.
[0139] Here, each element in the feature map matrix F0 and the feature map matrix F1 is judged respectively, if it is greater than or equal to 2, it is set to 1, otherwise it is 0, and the corresponding elements of the reset feature map matrix F0 and the feature map matrix F1 are multiplied to obtain the maze matrix A2.
[0140] S605A. Determine whether the new maze matrix A2 is equal to the maze matrix A0 before convolution?
[0141] Compare the maze matrix A0 and the maze matrix A2. If they are not equal, continue to execute S602A-S605A based on the maze matrix A2; if they are equal, end the processing. At this time, the maze matrix A2 is the matrix representation from the starting point to the end point of the maze.
[0142] S606A: Determine a target path based on the new maze matrix.
[0143] Example 2
[0144] When two adjacent position points in the horizontal direction and the vertical direction are 1, the position points are connected, and when two adjacent position points in the diagonal direction are 1, the position points are connected.
[0145] S601B, set the maze matrix A0 and the path feature matrix.
[0146] The maze is represented as a two-dimensional binary matrix A0, where the elements with a value of 1 in A0 represent that the corresponding position point is a channel, and the elements with a value of 0 in A0 represent that the corresponding position point is an obstacle.
[0147] The condition of the target location point includes at least one of condition 1 and condition 2 to condition 7:
[0148] Condition 1: The target location is a passable location, that is, the value of the element corresponding to the location is 1. At this time, the corresponding path feature matrix
[0149] Condition 2: The values of the elements corresponding to two or more of the four adjacent position points above, below, left, and right of the target position point are 1. In this case, the path feature matrix
[0150] Condition 3: Among the four positions in the diagonal direction adjacent to the target position, two or more of the corresponding elements have a value of 1. In this case, the path feature matrix
[0151] Condition 4: The values of the elements corresponding to two or more of the three position points above the target position point and the three position points at the lower left and lower right are 1. In this case, the path feature matrix
[0152] Condition 5: The values of the elements corresponding to two or more of the three positions adjacent to the left of the target position and the three positions above and below the right are 1. In this case, the path feature matrix
[0153] Condition 6: The values of the elements corresponding to two or more of the three positions below the target position and the upper left and upper right positions are 1. In this case, the path feature matrix
[0154] Condition 7: The values of the elements corresponding to two or more of the three positions adjacent to the right of the target position and the upper left and lower left positions are 1. In this case, the path feature matrix
[0155] S602B, expand the maze matrix A0 to obtain the maze matrix A1.
[0156] The maze matrix is expanded at the edge with a width of 1, the position points corresponding to the entrance and exit are filled with 1, and the other position points are filled with 0, to obtain a new maze matrix A1.
[0157] S603B, convolve the maze matrix A1 through the path feature matrix to obtain a feature map matrix.
[0158] The maze matrix is convolved with the path feature matrix f0, the path feature matrix f1, and the path feature matrix f6 to obtain the feature map matrix F0, the feature map matrix F1 to the feature map matrix F6. The maze matrix A1 is convolved with the path feature matrix f0, f1 to f6 as the convolution kernel with a step size of 1.
[0159] S604B, integrate the feature map matrix to obtain a processed new maze matrix A2.
[0160] Here, each element in the feature map matrix F0, feature map matrix F1, and feature map matrix F6 is judged respectively, and if it is greater than or equal to 2, it is set to 1, otherwise it is 0, and the corresponding elements of the reset feature map matrix F1 and feature map matrix F1 to feature map matrix F6 are multiplied to obtain the maze matrix A2.
[0161] S605B. Determine whether the new maze matrix A2 is equal to the maze matrix A0 before convolution?
[0162] Compare the maze matrix A0 and the maze matrix A2. If they are not equal, continue to execute S602A-S605A based on the maze matrix A2; if they are equal, end the processing. At this time, the maze matrix A2 is the matrix representation from the starting point to the end point of the maze.
[0163] S606B, determine the target path based on the new maze matrix.
[0164] In one embodiment, when the maze is Figure 7 As shown, the path searched by the path search method provided by the embodiment of the present application is as follows Figure 8 shown.
[0165] The path search method provided in the embodiment of the present application has the following technical effects:
[0166] 1. Fewer iterations and higher efficiency. Here, these feature matrices are integrated to obtain fewer matrices with the same functions, which can reduce convolution operations and improve performance.
[0167] 2. There is no useless operation, and every step is closer to the target path.
[0168] 3. Matrix calculations can be accelerated with the help of vector operations and GPU.
[0169] Fig. 9 A schematic diagram of an implementation flow of a path search device according to an embodiment of the present application is shown in FIG. Fig. 9As shown, the device 900 includes:
[0170] A conversion module 901 is used to convert a layout diagram of a target area passed by a starting point and an end point into a first matrix; elements of the first matrix represent position points included in the layout diagram;
[0171] An expansion module 902, configured to expand the first matrix according to the starting point and the end point to obtain a second matrix;
[0172] A convolution module 903, configured to perform convolution processing on the second matrix through at least one path feature matrix to obtain a third matrix;
[0173] An updating module 904 is configured to update the first matrix to the third matrix when the third matrix is different from the first matrix, until the third matrix is the same as the first matrix;
[0174] The expansion module 902 is further used to continue expanding the updated first matrix according to the starting point and the end point to obtain a new second matrix;
[0175] The convolution module 903 is further used to continue to perform convolution processing on the new second matrix through the path feature matrix to obtain a new third matrix;
[0176] The determination module 905 is used to determine a target path from the starting point to the end point based on the third matrix.
[0177] In some embodiments, the apparatus 900 further includes: a matrix determination module, configured to:
[0178] Obtaining a path condition; the path condition includes: the position point state of the target position point is a feasible state and the position point adjacent to the target position point is a feasible state;
[0179] According to the path condition, the path characteristic matrix is determined.
[0180] In some embodiments, the conversion module 901 is further configured to:
[0181] Acquire the position points in the layout diagram and the position point status of each position point; the position point status includes: a feasible state and an infeasible state;
[0182] The value of each element in the first matrix is set according to the position point status of each position point.
[0183] In some embodiments, the conversion module 901 is further configured to:
[0184] In the first matrix, the value of the first element is set to be a first value; the first element is an element representing a location point where the traffic state is a feasible state;
[0185] In the first matrix, the value of the second element is set to a second value; the second element is an element in the first matrix other than the first element; and the first value is different from the second value.
[0186] In some embodiments, the expansion module 902 is further configured to:
[0187] Adding elements to the edge of the first matrix;
[0188] Setting the value of the third element representing the starting point and the end point in the added element to the first value;
[0189] The value of the fourth element other than the third element among the added elements is set to the second value.
[0190] In some embodiments, the convolution module 903 is further configured to:
[0191] Convolving the second matrix with each of the at least one path feature matrix using a convolution kernel to obtain at least one feature map matrix;
[0192] The at least one feature map matrix is integrated to obtain the third matrix.
[0193] In some embodiments, the convolution module 903 is further configured to:
[0194] comparing each element in the at least one feature map matrix with an element threshold;
[0195] Adjusting elements greater than or equal to the element threshold to a first value;
[0196] Adjusting elements smaller than the element threshold to a second value;
[0197] The corresponding elements in the feature map matrix after element adjustment are multiplied to obtain the third matrix.
[0198] In some embodiments, the determination module 905 is further configured to:
[0199] Determine a target element in the third matrix whose value is the first value;
[0200] The routes corresponding to the target elements are connected to obtain the target path.
[0201] It should be noted that the path search device provided in the embodiment of the present application includes the various units included, which can be implemented by a processor in an electronic device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU, Central Processing Unit), a microprocessor (MPU, Micro Processor Unit), a digital signal processor (DSP, Digital Signal Processor) or a field programmable gate array (FPGA, Field-Programmable Gate Array), etc.
[0202] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0203] It should be noted that in the embodiment of the present application, if the above-mentioned path search method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0204] Correspondingly, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the steps in the path search method provided in the above embodiment are implemented.
[0205] Correspondingly, an embodiment of the present application provides a storage medium, that is, a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the path search method provided in the above embodiment is implemented.
[0206] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0207] It should be noted that Fig.10 A hardware entity diagram of an electronic device according to an embodiment of the present application is shown in FIG. Fig.10 As shown, the electronic device 1000 includes: a processor 1001, at least one communication bus 1002, at least one external communication interface 1004 and a memory 1005. The communication bus 1002 is configured to realize the connection and communication between these components. The external communication interface 1004 may include a standard wired interface and a wireless interface. In some embodiments, the electronic device may also include: a user interface 1003, wherein the user interface 1003 may include a display screen.
[0208] The memory 1005 is configured to store instructions and applications executable by the processor 1001, and can also cache data to be processed or processed by the processor 1001 and various modules in the electronic device (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).
[0209] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in some embodiments" appearing throughout the specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application. The above-mentioned sequence numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.
[0210] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including 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 sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0211] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0212] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0213] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0214] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0215] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0216] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A path search method, characterized in that: The method comprises: Converting a layout diagram of a target area passed by a starting point and an end point into a first matrix; elements of the first matrix represent position points included in the layout diagram; The first matrix is expanded according to the starting point and the end point to obtain a second matrix, and the second matrix is convolved with each path feature matrix in at least one path feature matrix with a convolution kernel to obtain at least one feature map matrix, and the at least one feature map matrix is integrated to obtain a third matrix; wherein, the second matrix has two rows of elements and two columns of elements added relative to the first matrix, and in the second matrix, the values of the elements corresponding to the starting point and the elements corresponding to the end point represent that the position points where the starting point and the end point are located are feasible; When the third matrix is different from the first matrix, the first matrix is updated to the third matrix, and the updated first matrix is further expanded according to the starting point and the end point to obtain a new second matrix, and the new second matrix is convolved with the path feature matrix to obtain a new third matrix, until the third matrix is the same as the first matrix; Based on the third matrix, determining a target path from the starting point to the end point; The at least one feature map matrix is integrated to obtain a third matrix, including: adjusting a value of an element in the at least one feature map matrix based on an element threshold; In the case of only one feature map matrix, the feature map matrix after element adjustment is used as the third matrix; In the case of including multiple feature map matrices, the feature maps after element adjustment are merged to obtain the third matrix.
2. The method according to claim 1, characterized in that The method further comprises: Obtaining a path condition; the path condition includes: the position point state of the target position point is a feasible state and the position point adjacent to the target position point is a feasible state; According to the path condition, the path characteristic matrix is determined.
3. The method according to claim 1, characterized in that The step of converting the layout diagram of the target area passed by the starting point and the end point into a first matrix comprises: Acquire the position points in the layout diagram and the position point status of each position point; the position point status includes: a feasible state and an infeasible state; The value of each element in the first matrix is set according to the position point status of each position point.
4. The method according to claim 3, characterized in that The step of setting the value of each element in the first matrix according to the position point status of each position point includes: In the first matrix, the value of the first element is set to be a first value; the first element is an element representing a location point where the traffic state is a feasible state; In the first matrix, the value of the second element is set to a second value; the second element is an element in the first matrix other than the first element; and the first value is different from the second value.
5. The method according to claim 4, characterized in that The first matrix is expanded according to the starting point and the end point to obtain a second matrix, including: Adding elements to the edge of the first matrix; Setting the value of the third element representing the starting point and the end point in the added element to the first value; The value of the fourth element among the added elements except the third element is set to the second value.
6. The method according to claim 1, characterized in that The adjusting the value of the element in the at least one feature map matrix based on the element threshold comprises: comparing each element in the at least one feature map matrix with an element threshold; Adjusting elements greater than or equal to the element threshold to a first value; Elements smaller than the element threshold are adjusted to a second value.
7. The method according to claim 1, characterized in that The determining, based on the third matrix, a target path from the starting point to the end point includes: Determine a target element in the third matrix whose value is the first value; The position points corresponding to the target elements are connected to obtain the target path.
8. A route search device, characterized in that: The device comprises: A conversion module, used to convert a layout diagram of a target area passed by a starting point and an end point into a first matrix; elements of the first matrix represent position points included in the layout diagram; An expansion module, used for expanding the first matrix according to the starting point and the end point to obtain a second matrix; wherein the second matrix has two more rows of elements and two more columns of elements than the first matrix, and in the second matrix, the values of the elements corresponding to the starting point and the elements corresponding to the end point represent that the positions of the starting point and the end point are feasible; A convolution module, used to convolve the second matrix with each channel feature matrix in at least one channel feature matrix using a convolution kernel to obtain at least one feature map matrix, and integrate the at least one feature map matrix to obtain a third matrix; The at least one feature map matrix is integrated to obtain a third matrix, including: adjusting a value of an element in the at least one feature map matrix based on an element threshold; In the case of only one feature map matrix, the feature map matrix after element adjustment is used as the third matrix; In the case of including a plurality of feature map matrices, merging the feature maps after element adjustment to obtain the third matrix; an updating module, configured to update the first matrix to the third matrix when the third matrix is different from the first matrix, until the third matrix is the same as the first matrix; The expansion module is further used to continue expanding the updated first matrix according to the starting point and the end point to obtain a new second matrix; The convolution module is further used to continue to perform convolution processing on the new second matrix through the path feature matrix to obtain a new third matrix; A determination module is used to determine a target path from the starting point to the end point based on the third matrix.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, the path search method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Rescue robot three-dimensional environment map real-time construction method
CN104240297A
Robot global path planning method based on deeply enhanced learning
CN107065881A