Point cloud processing method and device, computer equipment and storage medium
By dividing the KD tree into a master node tree and a slave node tree, and using preset query requests to perform hierarchical search of the master node tree and a slave node tree, the problem of low point cloud processing search in the existing technology is solved, and more efficient point cloud data search is achieved.
Patent Information
- Application Number
- CN202411720319.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
Existing point cloud processing technologies have the problem of low search efficiency, especially when processing large amounts of point cloud data.
By dividing the KD tree into one master node tree and multiple slave node trees, the preset number of query requests is used to search the master node tree first, and the query requests corresponding to each leaf node of the master node tree are obtained, and then the slave node tree is searched separately based on these query requests, and then the adjacent points of the target coordinate point are obtained.
The search efficiency of point cloud data is improved. Compared with the method of randomly searching the entire KD tree in the prior art to obtain adjacent points, the adjacent points of the target coordinate point can be found more quickly.
Smart Images

Figure CN119647565A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of point cloud data processing, and in particular to a point cloud processing method, device, computer equipment and storage medium. Background Art
[0002] Point cloud processing technology is an important method to achieve environmental understanding, trajectory evaluation and distance measurement in the field of automatic (unmanned) driving technology.
[0003] Existing point cloud processing technology mainly processes point cloud data by constructing the acquired point cloud data into a KD tree and then performing a random search on the KD number. For example, in the process of searching for adjacent points, it is necessary to search for an adjacent point before searching for the next adjacent point.
[0004] However, with the continuous improvement of LiDAR accuracy, the number of points that need to be processed in a frame of point cloud data can reach tens of thousands or even more, which leads to the problem of low search efficiency in existing point cloud processing technology. Summary of the invention
[0005] The embodiments of the present invention provide a point cloud processing method, apparatus, computer equipment and storage medium to solve the problem of low search efficiency in existing point cloud processing technologies.
[0006] A point cloud processing method, the method comprising: Obtain a point cloud KD tree, wherein the point cloud KD tree includes a master node tree and multiple slave node trees; Search the main node tree through a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree; Based on the query request corresponding to each leaf node of the master node tree, the slave node tree is searched respectively to obtain the query request corresponding to each leaf node of the slave node tree; Based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree, obtaining the neighboring points of the target coordinate point; Wherein, the leaf nodes of the master node tree are respectively the root nodes of the slave node tree.
[0007] In the above method, optionally, searching the main node tree through a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree includes: Inputting the preset number of query requests into the root node of the main node tree, and searching each node of the main node tree; For each of the query requests, determining whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching toward the right branch node to obtain the query request corresponding to the leaf node of the main node tree, and the query request is added to the queue space of the leaf node of the main node tree; If the value of the node where the query request is currently located is less than the value of the query request, continue searching to the left branch node to obtain the query request corresponding to the leaf node of the main node tree, and the query request is added to the queue space of the leaf node of the main node tree.
[0008] The above method, optionally, starts executing the target step when the queue space of any leaf node of the main node tree is full of query requests. The target step is: based on the query requests corresponding to each leaf node of the main node tree, search the slave node tree separately to obtain the query requests corresponding to each leaf node of the slave node tree.
[0009] The above method, optionally, searching the slave node tree respectively based on the query request corresponding to each leaf node of the master node tree to obtain the query request corresponding to each leaf node of the slave node tree includes: For each of the query requests, determining whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching toward the right branch node until a leaf node of the slave node tree is found; If the value of the node where the query request is currently located is less than the value of the query request, the search continues to the left branch node until a leaf node of the slave node tree is found.
[0010] The above method may optionally add the nodes searched by the query request in the slave node tree to the corresponding stack, so as to facilitate backtracking when the nodes in the stack are popped out of the stack.
[0011] In the above method, optionally, obtaining the neighboring points of the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree includes: Based on the leaf node coordinate value of the slave node tree and the coordinate value of the target coordinate point carried in the query request, calculate the spatial distance between the leaf node of the slave node tree and the target coordinate point; Determine whether the second to last node popped out of the stack is a left branch node of the last node; If the second-to-last node popped out of the stack is the left branch node of the last node, search the right branch node of the last node based on the query request, and after searching for the backtracking leaf node, calculate the spatial distance between the backtracking leaf node and the target coordinate point; Based on the leaf nodes of the slave node tree and the backtracking leaf nodes, the neighboring points of the target coordinate point are obtained.
[0012] In the above method, optionally, the point cloud KD tree is obtained by: Get point cloud data; Constructing an original KD tree corresponding to the point cloud data; Adding main node tree attributes to nodes of the target number of layers in the original KD tree to obtain the main node tree; Adding slave node tree attributes to the remaining nodes marked with master node tree attributes in the original KD tree to obtain a plurality of slave node trees; Based on the master node tree and the slave node tree, the point cloud KD tree is obtained.
[0013] A point cloud processing device, comprising: A KD tree construction unit, used to obtain a point cloud KD tree based on the acquired point cloud data, wherein the point cloud KD tree includes a master node tree and multiple slave node trees; A first search unit, configured to search the main node tree based on a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree; A second search unit is used to search the slave node tree respectively based on the query request corresponding to each leaf node of the master node tree to obtain the query request corresponding to each leaf node of the slave node tree; A neighboring point acquisition unit, configured to obtain a point closest to the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree; Wherein, the leaf nodes of the master node tree are respectively the root nodes of the slave node tree.
[0014] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned point cloud processing method when executing the computer program.
[0015] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the point cloud processing method described above is implemented.
[0016] In summary, the present invention discloses a point cloud processing method, device, computer equipment and storage medium, which divides the KD tree into a main node tree and multiple slave node trees, thereby first searching the main node through a preset number of query requests, and after obtaining the query request corresponding to each leaf node of the main node tree, the slave node trees are searched respectively based on the query request corresponding to each leaf node of the main node tree to obtain the query request corresponding to each leaf node of the slave node tree, and then based on the target coordinate point carried by the query request, the point closest to the target coordinate point is obtained. It can be seen that in the present invention, by dividing the KD tree into a main node tree and multiple slave node trees, and then searching the main node tree to divide the preset number of query requests into different numbers of slave nodes, and then searching different slave node trees respectively to obtain the nearby points of the target coordinate point, compared with the method of randomly searching the entire KD tree to obtain nearby points in the prior art, the purpose of improving the search efficiency can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0018] Figure 1 It is a flowchart of a point cloud processing method disclosed in Embodiment 1 of the present invention; Figure 2 It is a schematic diagram of the structure of a point cloud KD tree disclosed in the first embodiment of the present invention; Figure 3 It is a partial flow chart of a point cloud processing method disclosed in the first embodiment of the present invention; Figure 4 It is a partial flow chart of a point cloud processing method disclosed in the first embodiment of the present invention; Figure 5 It is a partial flow chart of a point cloud processing method disclosed in the first embodiment of the present invention; Figure 6 It is a partial flow chart of a point cloud processing method disclosed in the first embodiment of the present invention; Figure 7 is a structural schematic diagram of a point cloud processing device disclosed in Embodiment 2 of the present invention; Figure 8 It is a schematic diagram of the structure of a computer device disclosed in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] The present invention discloses a point cloud processing method, device, computer equipment and storage medium. The method divides a KD tree into a main node tree and multiple slave node trees, thereby first searching the main node through a preset number of query requests, and after obtaining the query request corresponding to each leaf node of the main node tree, the slave node trees are searched separately based on the query request corresponding to each leaf node of the main node tree to obtain the query request corresponding to each leaf node of the slave node tree, and then based on the target coordinate point carried by the query request, the point closest to the target coordinate point is obtained. It can be understood that in the present invention, after the KD tree is divided into a main node tree and multiple slave node trees, after the main node tree is searched to obtain the query request corresponding to each leaf node of the main node tree, the query request corresponding to the root node of each slave node tree is obtained, and then each slave node is searched separately based on the query request corresponding to the root node of each slave node tree, and the search of different slave node trees is performed independently. It can be seen that in the present invention, the KD tree is divided into a main node tree and multiple slave node trees, and then a preset number of query requests are divided into different numbers of slave nodes by searching the main node tree, and then different slave node trees are searched respectively to obtain the nearby points of the target coordinate point. Compared with the method of randomly searching the entire KD tree to obtain nearby points in the prior art, the purpose of improving the search efficiency can be achieved.
[0021] Embodiment 1 like Figure 1 FIG. 1 is a flow chart of a point cloud processing method disclosed in Embodiment 1 of the present invention, which is specifically as follows: S101: Obtain the point cloud KD tree.
[0022] Among them, the point cloud KD tree includes a master node tree and multiple slave node trees.
[0023] Point cloud data is acquired through a point cloud acquisition device, such as a laser radar, and then a point cloud KD tree is constructed based on the acquired point cloud data, and then the point cloud KD tree is divided to obtain a master node tree and multiple slave node trees. Alternatively, in the process of constructing the point cloud KD tree, a master node tree is first constructed and then multiple slave node trees are constructed based on the master node tree, and the master node tree and multiple slave node trees together constitute the point cloud KD tree.
[0024] In a specific implementation, in this embodiment, the point cloud KD tree can be divided into a main node tree and multiple slave node trees according to the number of layers of the point cloud KD tree. The points of the preset number of layers in the point cloud KD tree are used as the main node tree, and the remaining subtrees connected to the leaf nodes of the main node tree are used as slave node trees, such as Figure 2 As shown, Figure 2 Each circle in the figure (including solid circles and dotted circles) is a node in the point cloud KD tree, where the solid circles in the solid frame together constitute the main node tree, that is, the nodes of the 1st to 3rd layers of the point cloud KD tree are the main node tree; the dotted circle in the dotted frame and node S1 together constitute a slave node tree, that is, the slave node tree of the nodes of the 3rd to 5th layers of the point cloud KD tree. It can be seen that node S1 is a leaf node of the main node tree, and node S1 is also the root node of a slave node tree, and so on. Figure 2 S1 to S4 are leaf nodes of the main node tree, and are also root nodes of slave nodes. Therefore, the point cloud KD tree can be divided into a main node tree and multiple slave node trees according to the number of layers of the point cloud KD tree.
[0025] It should be understood that the above method of dividing the point cloud KD tree into a main node tree and multiple slave node trees according to the different numbers of layers of the point cloud KD tree is only one implementation method in this embodiment, and is not the only implementation method, and is not specifically limited in this embodiment.
[0026] In addition, each node in the point cloud KD tree in this embodiment, S102: Search the main node tree through a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree.
[0027] The search starts from the root node of the main node tree, a preset number of query requests are input into the root node of the main node tree, and then the preset number of query requests are distributed to the leaf nodes of the main node tree according to the branch nodes of the main node, and the query requests corresponding to each leaf node of the main node tree are obtained. After that, the subsequent steps of point cloud processing are executed according to the query requests corresponding to each leaf node of the main node.
[0028] It should be noted that the number of query requests in this embodiment is related to the number of points in the point cloud data actually obtained, for example, the number of query requests is equal to the number of points in the point cloud data actually obtained.
[0029] S103: Based on the query request corresponding to each leaf node of the master node tree, the slave node trees are searched respectively to obtain the query request corresponding to each leaf node of the slave node tree.
[0030] Each leaf node of the main node tree is the root node of a slave node tree. Therefore, based on the query request corresponding to each leaf node of the main node tree, the corresponding slave node tree can be searched to obtain the query request corresponding to each leaf node of the slave node tree.
[0031] S104: Obtain neighboring points of the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree.
[0032] In a specific implementation, in this embodiment, after the query request searches for a leaf node from the node tree, the spatial distance between the target coordinate point and the leaf node can be calculated based on the coordinate value of the target coordinate point carried in the query request and the coordinate value of the corresponding leaf node, and then the spatial distance between the leaf nodes on other branch nodes in the node tree and the target coordinate point carried in the query request can be calculated, and then one or more neighboring points of the target coordinate point can be obtained by comparing the spatial distances. For example, when it is required to obtain a neighboring point of the target coordinate point carried in the query request, based on the obtained spatial distance between the leaf node and the target coordinate point carried in the query request, the leaf node with the smallest spatial distance is selected as the neighboring point of the query request. Similarly, when it is required to obtain two neighboring points of the target coordinate point carried in the query request, based on the obtained spatial distance between the leaf node and the target coordinate point carried in the query request, the two leaf nodes with the smallest spatial distance are selected as the neighboring points of the query request. Based on this, the neighboring points of the target coordinate point can be obtained.
[0033] In summary, the first embodiment of the present invention discloses a point cloud processing method, apparatus, computer equipment and storage medium, which divides the KD tree into a main node tree and multiple slave node trees, thereby first searching the main node through a preset number of query requests, and after obtaining the query request corresponding to each leaf node of the main node tree, the slave node trees are searched respectively based on the query request corresponding to each leaf node of the main node tree to obtain the query request corresponding to each leaf node of the slave node tree, and then based on the target coordinate point carried by the query request, the point closest to the target coordinate point is obtained. It can be seen that in the present invention, by dividing the KD tree into a main node tree and multiple slave node trees, and then searching the main node tree to divide the preset number of query requests into different numbers of slave nodes, and then searching different slave node trees respectively to obtain the nearby points of the target coordinate point, compared with the method of randomly searching the entire KD tree to obtain nearby points in the prior art, the purpose of improving the search efficiency can be achieved.
[0034] Based on Figure 1 In the specific implementation, step S102 can be implemented by the following steps: Figure 3 As shown: S301: Input a preset number of query requests to the root node of the main node tree, and search each node of the main node tree.
[0035] In a specific implementation, after a preset number of query requests are input into the root node of the main node tree, the main node tree is searched for each query request input into the main node tree, thereby completing the search of the main node tree.
[0036] S302: For each query request, determine whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request.
[0037] The coordinate value of the query request is the coordinate value of the target coordinate point carried in the query request. The coordinate value of the target coordinate point carried in each query request is different. The specific coordinate value is set according to actual needs.
[0038] If the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request, then execute step S303, that is, continue searching to the right branch node. If the coordinate value of the node where the query request is currently located is less than the coordinate value of the query request, then execute step S304, that is, continue searching to the left branch node.
[0039] In a specific implementation, in this embodiment, the coordinate value of the target coordinate point carried by the query request and the coordinate value of the node where the query request is located can be obtained first, and then it is determined whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request. For example, if the coordinate value of the target coordinate point carried by the query request is (19, 14, 16), and the coordinate value of the node where the query request is located is (12, 13, 15), it can be seen that the coordinate value of the target coordinate point is greater than the coordinate value of the node where the query request is located. Therefore, the right branch node of the node where the query request is located is searched, and vice versa, the left branch node of the node where the query request is located is searched. In this way, the search of the main node tree can be realized.
[0040] S303: Continue searching toward the right branch node.
[0041] It should be understood that in the process of continuing to search toward the right branch node, when the query request reaches the next node, it is determined based on the coordinate value of the node whether the coordinate value of the node is greater than the coordinate value of the query request. If the coordinate value of the node is greater than the coordinate value of the query request, the search continues toward the right branch node. If the coordinate value of the node is less than the coordinate value of the query request, the search continues toward the left branch node, and so on, until the query request reaches the leaf node of the main node.
[0042] When a query request searches for a leaf node of the main node tree, the query request will be added to the queue space corresponding to the leaf node of the main node tree, thereby obtaining a query request corresponding to the leaf node of the main node tree.
[0043] In a specific implementation, the queue space of the leaf node of the main node tree in this embodiment is used to store query requests, and the number of query requests that can be stored in the queue space is related to the number of leaf nodes of the main node tree and the total number of query requests. For example, when there are 100 leaf nodes in the main node tree and the total number of query requests is related to 10,000, then the number of query requests that can be stored in the queue space of a leaf node is 10,000 / 100=100 query requests, that is, the queue space of a leaf node can only store 100 query requests.
[0044] In one implementation, when the queue space of any leaf node of the main node tree is full of query requests, the target step is executed: based on the query requests corresponding to each leaf node of the main node tree, the slave node trees are searched separately to obtain the query requests corresponding to each leaf node of the slave node tree.
[0045] It can be understood that after the queue space of the leaf node of the main node tree in this embodiment is full of query requests, it can start searching the slave node tree with the leaf node as the root node, without waiting for the queue space of each leaf node of the main node tree to be full of query requests before starting the search of the slave node tree at the same time.
[0046] S304: Continue searching toward the left branch node.
[0047] It should be understood that in the process of continuing to search toward the left branch node, when the query request reaches the next node, it is determined based on the coordinate value of the node whether the coordinate value of the node is greater than the coordinate value of the query request. If the coordinate value of the node is less than the coordinate value of the query request, the search continues toward the left branch node. If the coordinate value of the node is greater than the coordinate value of the query request, the search continues toward the right branch node, and so on, until the query request reaches the leaf node of the main node.
[0048] When a query request searches for a leaf node of the main node tree, the query request will be added to the queue space corresponding to the leaf node of the main node tree, thereby obtaining a query request corresponding to the leaf node of the main node tree.
[0049] In a specific implementation, the queue space of the leaf node of the main node tree in this embodiment is used to store query requests, and the number of query requests that can be stored in the queue space is related to the number of leaf nodes of the main node tree and the total number of query requests. For example, when there are 100 leaf nodes in the main node tree and the total number of query requests is related to 10,000, then the number of query requests that can be stored in the queue space of a leaf node is 10,000 / 100=100 query requests, that is, the queue space of a leaf node can only store 100 query requests.
[0050] In one implementation, when the queue space of any leaf node of the main node tree is full of query requests, the target step is executed: based on the query requests corresponding to each leaf node of the main node tree, the slave node trees are searched separately to obtain the query requests corresponding to each leaf node of the slave node tree.
[0051] It can be understood that after the queue space of the leaf node of the main node tree in this embodiment is full of query requests, it can start searching the slave node tree with the leaf node as the root node, without waiting for the queue space of each leaf node of the main node tree to be full of query requests before starting the search of the slave node tree at the same time.
[0052] It can be seen that after the queue space of the leaf node of the main node tree in this embodiment is filled with query requests, the slave node tree can be searched. The searches of different slave node trees are performed independently, which can achieve the purpose of improving search efficiency.
[0053] based on Figure 1 In the specific implementation, step S103 can be implemented by the following steps: Figure 4 As shown: S401: For each query request, determine whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request.
[0054] The coordinate value of the query request is the coordinate value of the target coordinate point carried in the query request. The coordinate value of the target coordinate point carried in each query request is different. The specific coordinate value is set according to actual needs.
[0055] If the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request, then execute step S402, that is, continue searching to the right branch node until the leaf node of the slave node tree is searched. If the coordinate value of the node where the query request is currently located is less than the coordinate value of the query request, then execute step S403, that is, continue searching to the left branch node until the leaf node of the slave node tree is searched.
[0056] In a specific implementation, in this embodiment, the coordinate value of the target coordinate point carried by the query request and the coordinate value of the node where the query request is located can be obtained first, and then it is determined whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request. For example, taking the latitude of the X-axis as an example, if the coordinate value of the target coordinate point carried by the query request is (19, 14, 16), and the coordinate value of the node where the query request is located is (12, 7, 9), it can be seen that the coordinate value of the target coordinate point is greater than the coordinate value of the node where the query request is located. Therefore, the right branch node of the node where the query request is located is searched, and vice versa, the left branch node of the node where the query request is located is searched. In this way, the search from the node tree can be realized.
[0057] S402: Continue searching for the right branch node until a leaf node of the slave node tree is found.
[0058] It should be understood that in the process of continuing to search toward the right branch node, when the query request reaches the next node, it is determined whether the coordinate value of the node is greater than the coordinate value of the query request based on the coordinate value of the node. If the coordinate value of the node is greater than the coordinate value of the query request, the search continues toward the right branch node. If the coordinate value of the node is less than the coordinate value of the query request, the search continues toward the left branch node, and so on, until the query request reaches the leaf node of the main node and obtains the leaf node corresponding to the search request.
[0059] It should be noted that there is only one query request that searches for a leaf node from the node tree, that is, each leaf node from the node tree corresponds to only one query request, and subsequent steps of point cloud processing are performed for the query request.
[0060] S403: Continue searching for the left branch node until a leaf node of the slave node tree is found.
[0061] It should be understood that in the process of continuing to search toward the left branch node, when the query request reaches the next node, it is determined whether the coordinate value of the node is greater than the coordinate value of the query request based on the coordinate value of the node. If the coordinate value of the node is less than the coordinate value of the query request, the search continues to the left branch node. If the coordinate value of the node is greater than the coordinate value of the query request, the search continues to the right branch node, and so on, until the query request reaches the leaf node of the main node and obtains the leaf node corresponding to the search request.
[0062] It should be noted that there is only one query request that searches for a leaf node from the node tree, that is, each leaf node from the node tree corresponds to only one query request, and subsequent steps of point cloud processing are performed for the query request.
[0063] It can be seen that in this embodiment, based on the query requests in the queue space of each leaf node in the main node tree, different slave node trees are searched separately. That is to say, it is possible to search multiple slave node trees at the same time. Compared with the prior art method of randomly searching the entire point cloud KD tree, the search efficiency can be greatly improved.
[0064] In one implementation, in this embodiment, the nodes searched by the query request in the node tree are added to the corresponding stack, so as to facilitate backtracking when the nodes in the stack are popped out of the stack.
[0065] In a specific implementation, the stack in this embodiment can be a stack Stack, which follows the first-in-last-out principle of the stack. During the search of the slave node tree based on the query request, the first node added to the stack is also the last node popped from the stack. Backtracking is performed based on the order in which the nodes are popped from the stack.
[0066] Based on Figure 1 In the specific implementation, step S104 can be implemented by the following steps: Figure 5 As shown: S501: Based on the coordinate values of the leaf nodes of the slave node tree and the coordinate values of the target coordinate point carried in the query request, calculate the spatial distance between the leaf nodes of the slave node tree and the target coordinate point.
[0067] In the specific implementation, in this embodiment, the spatial distance between the leaf node of the node tree and the target coordinate point can be calculated by the Euclidean distance calculation formula, and the index value and spatial distance of the leaf node can be recorded in a pre-set distance set for use in executing subsequent steps of point cloud processing.
[0068] The Euclidean distance calculation formula can be specifically shown as follows: in, Represents the three-dimensional coordinates of the leaf nodes from the node tree, Represents the three-dimensional coordinates of the target coordinate point, It is the spatial distance between the leaf node of the node tree and the target coordinate point.
[0069] It should be noted that the above-mentioned method of calculating the spatial distance between the leaf node of the slave node tree and the target coordinate point through the Euclidean distance calculation formula is only one implementation method in this embodiment, and is not the only method. For example, the spatial distance between the leaf node of the slave node tree and the target coordinate point is calculated through the Manhattan distance calculation method. In this embodiment, the method for calculating the spatial distance between the leaf node of the slave node tree and the target coordinate point is not limited.
[0070] S502: Determine whether the second-to-last node popped out of the stack is a left branch node of the last node.
[0071] If the second-to-last node popped out of the stack is the left branch node of the last node, step S503 is executed, that is, the right branch node of the last node is searched based on the query request, and after searching the backtracking leaf node, the spatial distance between the backtracking leaf node and the target coordinate point is calculated. If the second-to-last node popped out of the stack is the right branch node of the last node, the search starts towards the left node of the last node.
[0072] In a specific implementation, in this embodiment, it is possible to determine whether the penultimate node is the left branch node of the last node based on the coordinate value of the last node and the coordinate value of the penultimate node. For example, taking the latitude of the X-axis as an example, if the coordinate value of the last node popped out of the stack is (19, 15, 11), and the penultimate node is (14, 9, 8), it can be seen that the coordinate value of the last node is greater than the coordinate value of the penultimate node, and the penultimate node can be determined to be the left branch node of the last node. Conversely, the penultimate node can be determined to be the right branch node of the last node. Based on this, it is possible to determine whether the penultimate node popped out of the stack is the left branch node of the last node.
[0073] S503: Search the right branch node of the last node based on the query request, and after searching for the backtracking leaf node, calculate the spatial distance between the backtracking leaf node and the target coordinate point.
[0074] In the specific implementation, in this embodiment, the spatial distance between the backtracking leaf node from the node tree and the target coordinate point can be calculated by the Euclidean distance calculation formula, and the index value and spatial distance of the backtracking leaf node can be recorded in a pre-set distance set for use in executing subsequent steps of point cloud processing.
[0075] The Euclidean distance calculation formula can be specifically shown as follows: in, Represents the three-dimensional coordinates of the leaf nodes from the node tree, Represents the three-dimensional coordinates of the target coordinate point, It is the spatial distance between the backtracking leaf node of the node tree and the target coordinate point.
[0076] S504: Obtain neighboring points of the target coordinate point based on the leaf node corresponding to the query request and the backtracking leaf node.
[0077] Among them, the number of neighboring points of the target coordinate point can be set according to actual needs, that is, 1 neighboring point, 2 neighboring points, or 5 neighboring points of the target coordinate point can be finally obtained, which is not limited in this embodiment.
[0078] In a specific implementation, the leaf nodes and backtracking leaf nodes obtained in this embodiment are not necessarily the nearest neighboring points to the target coordinate point. Therefore, it is necessary to use the spatial distance between the leaf node of the node tree and the target coordinate point as the radius and the target coordinate point as the center to make a spherical domain, so as to obtain the nodes of the KD tree located in the spherical domain, and calculate the spatial distance between these nodes of the KD tree located in the spherical domain and the target coordinate point through the Euclidean distance formula. Similarly, use the spatial distance between the backtracking leaf node of the node tree and the target coordinate point as the radius and the target coordinate point as the center to make a spherical domain, so as to obtain the nodes of the KD tree located in the spherical domain, and calculate the spatial distance between these nodes of the KD tree located in the spherical domain and the target coordinate point through the Euclidean distance formula. After that, all the obtained nodes (including the leaf nodes and backtracking leaf nodes corresponding to the query request) are sorted according to the size of the spatial distance to the target coordinate point, wherein the node with the smallest spatial distance is the nearest neighboring point of the target coordinate point. For example, the leaf node corresponding to the query request has the smallest spatial distance to the target coordinate point, then it can be determined that the leaf node corresponding to the query request is the nearest neighboring point of the target coordinate point. In addition, according to the number of neighboring points that need to be obtained, the nodes with the smallest spatial distance can be selected as neighboring points according to the order of spatial distance.
[0079] It should be noted that in this embodiment, not only can the right branch node be searched when it is determined that the second to last node popped out of the stack is the left branch node of the last node, but the left branch node can also be searched when it is determined that the second to last node popped out of the stack is the right branch node of the last node, and this is not limited in the embodiment.
[0080] In summary, in this embodiment, backtracking is performed to find backtracking leaf nodes on different branch nodes of the same slave node tree, so as to achieve a comprehensive search for the neighboring points of the target coordinate point. The neighboring points of the target coordinate point can be obtained based on the leaf nodes corresponding to the query request and the backtracking leaf nodes.
[0081] In one implementation, the point cloud KD tree can be obtained by the following steps: Figure 6 As shown: S601: Obtain point cloud data.
[0082] In a specific implementation, in this embodiment, point cloud data can be acquired through a point cloud acquisition device, such as a laser radar, and then a point cloud KD tree is constructed based on the acquired point cloud data.
[0083] S602: Construct an original KD tree corresponding to the point cloud data.
[0084] In a specific implementation, in this embodiment, the point cloud space of the point cloud data can be spatially divided according to the coordinates of the points in the point cloud space of the point cloud data, and then an overall original KD tree can be constructed, in which the nodes in the original KD tree correspond to the completed point cloud data.
[0085] S603: Add main node tree attributes to the nodes of the target number of layers in the original KD tree to obtain a main node tree.
[0086] In a specific implementation, in this embodiment, an application with an attribute adding function can be used to add attributes to the nodes of the original KD tree. By setting the attribute marking layer number, the main node tree attribute is added to the nodes of the target layer number in the original KD tree, such as Figure 2 As shown, the three-layer nodes in the solid box are the main node tree marked with the main node tree attributes, the dotted box is a slave node tree marked with the slave node tree attributes, and nodes S1-S4 respectively correspond to a slave node tree, that is, it is necessary to add slave node tree attributes to all nodes except the main node tree. In addition, nodes S1-S4 are respectively marked with the main node tree attributes and the slave node tree attributes, so that the search of the main node tree ends with nodes S1-S4, and the search of the slave node tree starts with nodes S1-S4.
[0087] S604: adding slave node tree attributes to the remaining nodes marked with the master node tree attributes in the original KD tree to obtain multiple slave node trees.
[0088] S605: Obtain a point cloud KD tree based on the master node tree and the slave node tree.
[0089] That is to say, the original KD tree to which the main node tree attributes and the slave node tree attributes are added is the point cloud KD tree, and each step of point cloud processing in this embodiment is performed based on the point cloud KD tree.
[0090] In summary, in this embodiment, the original KD tree is segmented by adding the main node tree attributes and the slave node tree attributes to the original KD tree, and the main node tree and multiple slave node trees constituting the point cloud KD tree are obtained. In the process of searching the point cloud KD tree, the main node tree and the slave node tree can be searched separately based on the attributes carried in the point cloud KD tree.
[0091] It should be understood that the order of execution of the steps in the above embodiment does not necessarily 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 invention.
[0092] Embodiment 2 like Figure 1FIG. 1 is a schematic diagram of the structure of a point cloud processing device disclosed in Embodiment 2 of the present invention, which is specifically as follows: A KD tree construction unit 701 is used to obtain a point cloud KD tree based on the acquired point cloud data, where the point cloud KD tree includes a master node tree and multiple slave node trees; A first search unit 702 is used to search the main node tree through a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree; The second search unit 703 is used to search the slave node tree respectively based on the query request corresponding to each leaf node of the master node tree to obtain the query request corresponding to each leaf node of the slave node tree; The adjacent point acquisition unit 704 is used to obtain the point closest to the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree; The leaf nodes of the master node tree are respectively the root nodes of a slave node tree.
[0093] In one implementation, the first search unit 702 is specifically configured to: Input a preset number of query requests to the root node of the main node tree, and search each node of the main node tree; For each query request, determine whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching toward the right branch node to obtain the query request corresponding to the leaf node of the main node tree, wherein the query request is added to the queue space of the leaf node of the main node tree; If the value of the node where the query request is currently located is less than the value of the query request, continue searching to the left branch node to obtain the query request corresponding to the leaf node of the main node tree, where the query request is added to the queue space of the leaf node of the main node tree.
[0094] In one implementation, when the queue space of any leaf node of the main node tree is full of query requests, the target step is executed. The target step is: based on the query requests corresponding to each leaf node of the main node tree, the slave node tree is searched separately to obtain the query requests corresponding to each leaf node of the slave node tree.
[0095] In one implementation, the second search unit 703 is specifically configured to: For each query request, determine whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching to the right branch node until the leaf node of the slave node tree is found; If the value of the node where the query request is currently located is less than the value of the query request, continue searching to the left branch node until the leaf node of the slave node tree is found.
[0096] In one implementation, the nodes searched by the query request in the node tree are added to the corresponding stack, so as to facilitate backtracking when the nodes in the stack are popped out of the stack.
[0097] In one implementation, the adjacent point acquisition unit 704 is specifically configured to: Based on the leaf node coordinate value of the slave node tree and the coordinate value of the target coordinate point carried in the query request, the spatial distance between the leaf node of the slave node tree and the target coordinate point is calculated; Determine whether the second-to-last node popped from the stack is the left branch node of the last node; If the second-to-last node popped from the stack is the left branch node of the last node, search the right branch node of the last node based on the query request, and after searching the backtracking leaf node, calculate the spatial distance between the backtracking leaf node and the target coordinate point; Based on the leaf nodes of the node tree and backtracking the leaf nodes, the neighboring points of the target coordinate point are obtained.
[0098] In one implementation, the point cloud KD tree is obtained by: Get point cloud data; Construct the original KD tree corresponding to the point cloud data; Add the main node tree attributes to the nodes of the target layer in the original KD tree to obtain the main node tree; Add slave node tree attributes to the remaining nodes marked with master node tree attributes in the original KD tree to obtain multiple slave node trees; Based on the master node tree and the slave node tree, the point cloud KD tree is obtained.
[0099] For the specific definition of the point cloud processing device, please refer to the relevant definition of the point cloud processing method above, which will not be repeated here. Each module in the above-mentioned point cloud processing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0100] Embodiment 3 Embodiment 3 of the present application discloses a computer device, which may be a server, and its internal structure diagram may be as follows: Figure 8As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a point cloud processing method is implemented.
[0101] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: Get the point cloud KD tree, which includes a master node tree and multiple slave node trees; Search the main node tree through a preset number of query requests to obtain query requests corresponding to each leaf node of the main node tree; Based on the query request corresponding to each leaf node of the master node tree, the slave node tree is searched respectively to obtain the query request corresponding to each leaf node of the slave node tree; Based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree, obtain the neighboring points of the target coordinate point; The leaf nodes of the master node tree are respectively the root nodes of a slave node tree.
[0102] Embodiment 4 Embodiment 4 of the present application discloses a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor in a computer device, the computer device can execute the steps of any embodiment of a point cloud processing method disclosed in the present invention. The computer-readable storage medium can be non-volatile or volatile.
[0103] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: Get the point cloud KD tree, which includes a master node tree and multiple slave node trees; Search the main node tree through a preset number of query requests to obtain query requests corresponding to each leaf node of the main node tree; Based on the query request corresponding to each leaf node of the master node tree, the slave node tree is searched respectively to obtain the query request corresponding to each leaf node of the slave node tree; Based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree, obtain the neighboring points of the target coordinate point; The leaf nodes of the master node tree are respectively the root nodes of a slave node tree.
[0104] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0105] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0106] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A point cloud processing method, characterized in that: The method comprises: Obtain a point cloud KD tree, wherein the point cloud KD tree includes a master node tree and multiple slave node trees; Search the main node tree through a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree; Based on the query request corresponding to each leaf node of the master node tree, the slave node tree is searched respectively to obtain the query request corresponding to each leaf node of the slave node tree; Based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree, obtaining the neighboring points of the target coordinate point; Wherein, the leaf nodes of the master node tree are respectively the root nodes of the slave node tree.
2. The point cloud processing method according to claim 1, characterized in that: The step of searching the main node tree by using a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree includes: Inputting the preset number of query requests into the root node of the main node tree, and searching each node of the main node tree; For each of the query requests, determining whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching toward the right branch node to obtain the query request corresponding to the leaf node of the main node tree, and the query request is added to the queue space of the leaf node of the main node tree; If the value of the node where the query request is currently located is less than the value of the query request, continue searching to the left branch node to obtain the query request corresponding to the leaf node of the main node tree, and the query request is added to the queue space of the leaf node of the main node tree.
3. The point cloud processing method according to claim 2, characterized in that: When the queue space of any leaf node of the main node tree is filled with the query request, the target step is executed. The target step is: based on the query request corresponding to each leaf node of the main node tree, the slave node tree is searched separately to obtain the query request corresponding to each leaf node of the slave node tree.
4. The point cloud processing method according to claim 1, characterized in that: The step of searching the slave node tree based on the query request corresponding to each leaf node of the master node tree to obtain the query request corresponding to each leaf node of the slave node tree includes: For each of the query requests, determining whether the coordinate value of the node where the query request is currently located is greater than the coordinate value of the query request; If the value of the node where the query request is currently located is greater than the value of the query request, continue searching toward the right branch node until a leaf node of the slave node tree is found; If the value of the node where the query request is currently located is less than the value of the query request, the search continues to the left branch node until a leaf node of the slave node tree is found.
5. The point cloud processing method according to claim 4, characterized in that: The nodes searched by the query request in the slave node tree are added to the corresponding stack, so as to facilitate backtracking when the nodes in the stack are popped out of the stack.
6. The point cloud processing method according to claim 5, characterized in that: The step of obtaining the neighboring points of the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree includes: Based on the leaf node coordinate value of the slave node tree and the coordinate value of the target coordinate point carried in the query request, calculate the spatial distance between the leaf node of the slave node tree and the target coordinate point; Determine whether the second to last node popped out of the stack is a left branch node of the last node; If the second-to-last node popped out of the stack is the left branch node of the last node, search the right branch node of the last node based on the query request, and after searching for the backtracking leaf node, calculate the spatial distance between the backtracking leaf node and the target coordinate point; Based on the leaf nodes of the slave node tree and the backtracking leaf nodes, the neighboring points of the target coordinate point are obtained.
7. The point cloud processing method according to claim 1, characterized in that: The point cloud KD tree is obtained in the following way: Get point cloud data; Constructing an original KD tree corresponding to the point cloud data; Adding main node tree attributes to nodes of the target number of layers in the original KD tree to obtain the main node tree; Adding slave node tree attributes to the remaining nodes marked with master node tree attributes in the original KD tree to obtain a plurality of slave node trees; Based on the master node tree and the slave node tree, the point cloud KD tree is obtained.
8. A point cloud processing device, characterized in that: include: A KD tree construction unit, used to obtain a point cloud KD tree based on the acquired point cloud data, wherein the point cloud KD tree includes a master node tree and multiple slave node trees; A first search unit, configured to search the main node tree based on a preset number of query requests to obtain a query request corresponding to each leaf node of the main node tree; A second search unit is used to search the slave node tree respectively based on the query request corresponding to each leaf node of the master node tree to obtain the query request corresponding to each leaf node of the slave node tree; A neighboring point acquisition unit, configured to obtain a point closest to the target coordinate point based on the target coordinate point carried in the query request corresponding to the leaf node of the slave node tree; Wherein, the leaf nodes of the master node tree are respectively the root nodes of the slave node tree.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the point cloud processing method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the point cloud processing method according to any one of claims 1 to 7 is implemented.