Point cloud connectivity segmentation method and system based on voxel hash and check set, computer readable storage medium and computer program product

Through the voxel hashing and union-find method, the problem of low efficiency in segmenting millions of point clouds is solved, and fast point cloud segmentation is achieved, which is suitable for 3D reconstruction, industrial inspection and autonomous driving environment perception.

CN120782807AActive Publication Date: 2025-10-14GUANGDONG AOPUTE TECH CO LTD

Patent Information

Application Number
CN202511188327.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-25
Publication Date
2025-10-14
Estimated Expiration
2045-08-25

AI Technical Summary

Technical Problem

Existing technologies have low efficiency in point cloud segmentation of millions or above, especially when the point cloud distribution is uneven or there is a lot of noise. The efficiency of kd-tree range search decreases, and the voxel hashing method still requires multiple hash searches and graph searches, resulting in poor overall efficiency.

Method used

A voxel hashing and union-find method is adopted to determine the regular grid by calculating the maximum connectivity distance threshold and bounding box, construct a voxel hash map, use Euclidean distance to determine adjacent edges, and perform path compression through the union-find structure to achieve fast connected area merging.

Benefits of technology

It significantly improves the efficiency of segmentation of millions of point clouds and is suitable for scenarios such as 3D reconstruction, industrial inspection, and autonomous driving environment perception, especially for scenarios such as industrial inspection and autonomous driving environment perception.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120782807A_ABST
    Figure CN120782807A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, and discloses a point cloud connectivity segmentation method and system based on voxel hash and a union-check set, a computer readable storage medium and a computer program product. The method comprises the following steps: calculating effective points of a point cloud to determine a bounding box, and voxelizing a three-dimensional space where the point cloud is located according to the bounding box and a predetermined voxel grid size to generate a regular grid; calculating a grid index of the voxel corresponding to each effective point; constructing Hash mapping from voxels to effective points through double-pass scanning; determining adjacent edges of the point cloud by using an Euclidean distance judgment method based on the Hash mapping, and constructing an adjacent edge set; and performing merging operation and path compression on the adjacent edges in the adjacent edge set by using a union check set structure to obtain a plurality of connected regions of the point cloud. According to the method, rapid spatial positioning is realized through the regular voxel grids, rapid communication and combination are realized by using the union-check set structure, and the segmentation efficiency of point clouds of million level and above scales can be remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of image processing, and in particular to a point cloud connectivity segmentation method and system based on voxel hashing and union-find set, a computer readable storage medium and a computer program product. BACKGROUND

[0002] With the development of three-dimensional acquisition devices such as laser scanning and depth cameras, the order of magnitude of point cloud data generated in industrial sites and scientific research fields is rising continuously, and it has become normal to reach the scale of millions or even tens of millions of data. After obtaining point data, it needs to be processed, and point cloud connectivity segmentation is a basic and key step in point cloud processing, which aims to aggregate points that are close to each other in space into the same connected region, so as to perform subsequent semantic recognition, geometric reconstruction or defect detection.

[0003] The existing common segmentation techniques mainly include kd-tree-based nearest neighbor search combined with region growing algorithm, Euclidean clustering-based segmentation, grid or octree-based space division method, etc. For kd-tree region growing, first, search the range of the seed point, add the points within the threshold distance, and mark and expand synchronously. Although it can complete the task well at the scale of tens of thousands of points, at the scale of millions of points, kd-tree range search will perform a large number of repeated queries, resulting in a fold decline in efficiency. At the same time, once the point distribution is uneven and the noise is large, the performance of tree search is more affected. In order to speed up the spatial index, researchers have proposed a nearest neighbor search method based on voxel hashing, that is, dividing the three-dimensional space into regular grids of fixed size (voxel), and then using a hash table or sparse array to record the point list in each grid, but most voxel hashing-based methods still need to access each grid in a linked list or multiple hash searches, and the subsequent connectivity judgment is still based on graph search or threshold judgment, and the overall efficiency is still not ideal.

[0004] Therefore, for those skilled in the art, how to optimize the segmentation technology and improve the segmentation efficiency of point clouds at the scale of millions or more has become a technical problem to be solved by those skilled in the art. SUMMARY

[0005] The present application aims to provide a point cloud connectivity segmentation method and system based on voxel hashing and union-find set, a computer readable storage medium and a computer program product, to solve or at least partially solve the technical problems mentioned in the background.

[0006] To achieve this purpose, the present application adopts the following technical solutions: In a first aspect, the present application provides a point cloud connectivity segmentation method based on voxel hashing and union-find set, comprising: calculating a maximum connected distance threshold of all valid points of the point cloud; and determining a bounding box according to the coordinates of all valid points of the point cloud in a three-dimensional space; voxelizing the three-dimensional space according to the bounding box and a predetermined voxel grid size to generate a regular grid; the predetermined voxel grid size is the maximum connected distance threshold; calculating the grid index of the voxel corresponding to each valid point respectively; constructing a hash mapping from voxel to valid point through double-pass scanning; determining the adjacent edges of the point cloud by using the Euclidean distance judgment method based on the hash mapping, and constructing an adjacent edge set; performing a merging operation on the adjacent edges in the adjacent edge set by using a union-find set structure and performing path compression to obtain a plurality of connected regions of the point cloud.

[0007] Optionally, the method for calculating the maximum connected distance threshold of all valid points of the point cloud is: uniformly or randomly sampling K valid points from the point cloud P, and denoting the sampling points as querying the nearest k neighborhood points of each sampling point through a pre-constructed kd-tree; statistically calculating the Euclidean distances between all sampling points and their neighborhood points, and calculating the average value of all Euclidean distances, the calculation formula being: ; wherein, is the Euclidean distance between the sampling point and its neighborhood point ; setting the maximum connected distance threshold as ; wherein, .

[0008] Optionally, the method for determining the bounding box according to the coordinates of all valid points of the point cloud in the three-dimensional space comprises: assuming that the point cloud is P, and the coordinates of the point cloud P in the three-dimensional space are expressed as: wherein N is the number of valid points in the point cloud; then the bounding box is: wherein, , are the minimum value and the maximum value of , , are the minimum value and the maximum value of , , the minimum and maximum values of respectively.

[0009] Optionally, the method for calculating the grid index of the voxel corresponding to each valid point respectively comprises: for each valid point in the point cloud P , the corresponding voxel coordinate is calculated by: ; limiting the voxel coordinate to the range , and then transforming to obtain the grid index of the one-dimensional array: , , , respectively: , the voxel grid size , and the number of voxel grids of the regular grid is .

[0010] Optionally, the method for constructing the hash mapping from voxel to valid point by double scanning comprises: by double scanning, obtaining the grid index of all voxels contained in each voxel grid of the regular grid; adopting a predetermined hash function to establish a voxel hash table: wherein the predetermined hash function is: hash(v) = x * a ^ y * b ^ z * c, hash(v) is a hash index calculated based on the voxel coordinate (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.

[0011] Optionally, the method for determining the adjacent edges of the point cloud by using the Euclidean distance judgment method based on the hash mapping, and constructing an adjacent edge set comprises: for each valid point in the point cloud P , the adjacent voxels in the regular grid are enumerated respectively; and the valid points corresponding to the adjacent voxels are denoted as ; traverse each , calculate the Euclidean distance between and and determine whether the following relationship is satisfied: ; if yes, the edge pair (i, j) is composed of and , and is inserted into the adjacent edge set E; if not, it is determined that and Cannot form side pairs.

[0012] Optionally, the using of the union-find structure to perform a merging operation on the adjacent edges in the adjacent edge set and perform path compression to obtain a plurality of connected regions of the point cloud specifically includes: Initialize the union-find structure UF, perform a merge operation and path compression on each edge pair (i, j)∈E, and obtain several connected regions; The connected area to which each valid point belongs is marked as the root node index, and the number of occurrences of each root node is counted to obtain the size of each connected area.

[0013] Optionally, after performing a merging operation and path compression on the adjacent edges in the adjacent edge set using a union-find structure to obtain a plurality of connected regions of the point cloud, the method further includes: According to a preset minimum valid region size threshold, small clusters whose sizes are smaller than the minimum valid region size threshold are screened out from the plurality of connected regions, and valid connected regions are output.

[0014] Optionally, a is 73856093, b is 19349663, and c is 83492791.

[0015] Optionally, for each valid point in the point cloud P , respectively enumerate its neighboring voxels in a regular grid, specifically: For each valid point , and its corresponding voxel coordinates are , enumerate its 26 neighboring voxels, the coordinates of the neighboring voxels are , .

[0016] In a second aspect, the present invention provides a point cloud connectivity segmentation system based on voxel hashing and union-find, comprising: a point cloud data processing module, configured to calculate a maximum connectivity distance threshold for all valid points in the point cloud; and to determine a bounding box of the point cloud based on the coordinates of all valid points in the point cloud in three-dimensional space; a network reconstruction module, electrically connected to the point cloud data processing module, configured to voxelize the three-dimensional space according to the bounding box and the voxel grid size to generate a regular grid; wherein the voxel grid size is defined as the maximum connectivity distance threshold; The network reconstruction module is further used to respectively calculate the grid index of the voxel corresponding to each valid point; a mapping module, electrically connected to the network reconstruction module, for constructing a hash mapping from voxels to valid points through double-pass scanning; The communication area operation module is electrically connected with the mapping module, configured to determine the adjacent edges of the point cloud by using the Euclidean distance judgment method based on the hash mapping, and construct an adjacent edge set; and further configured to perform a merging operation on the adjacent edges in the adjacent edge set by using a union-find set structure and perform path compression to obtain a plurality of connected areas of the point cloud.

[0017] Optionally, the method for calculating the maximum connected distance threshold of all valid points of the point cloud comprises: uniformly or randomly sampling K valid points from the point cloud P, and denoting the sampled points as querying the nearest k neighborhood points of each sampled point by using a pre-constructed kd-tree; statistically recording the Euclidean distances between all the sampled points and the neighborhood points thereof, and calculating the average value of all the Euclidean distances, the calculation formula being: ; wherein, is the Euclidean distance between the sampled point and the neighborhood point thereof; setting the maximum connected distance threshold as ; wherein, .

[0018] Optionally, the method for determining the bounding box according to the coordinates of all the valid points of the point cloud in the three-dimensional space comprises: denoting the point cloud as P, and the coordinates of the point cloud P in the three-dimensional space as wherein N is the number of valid points in the point cloud; the bounding box being wherein, , are the minimum value and the maximum value of , , are the minimum value and the maximum value of , , are the minimum value and the maximum value of .

[0019] Optionally, the method for calculating the lattice index of the voxel corresponding to each valid point comprises: for each valid point of the point cloud P, calculating the voxel coordinate corresponding thereto by using the following formula: ; limiting the voxel coordinate to ​The grid index of the one-dimensional array is obtained by further transformation within the range: , , , respectively: , the size of the voxel grid , the number of voxel grids of the regular grid is .

[0020] Optionally, the mapping module is specifically configured to: obtain the grid index of all voxels contained in each voxel grid of the regular grid through double scanning; establish a voxel hash table using a predetermined hash function: wherein the predetermined hash function is: hash(v) = x * a ^ y * b ^ z * c, hash(v) is a hash index calculated based on voxel coordinates (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.

[0021] Optionally, the connected region operation module is specifically configured to: for each valid point in the point cloud P , enumerate its adjacent voxels in the regular grid respectively; and record the valid points corresponding to the adjacent voxels as ; traverse each , calculate the Euclidean distance between and and determine whether the following relationship is satisfied: ; If yes, the edge pair (i, j) is formed by and , and is inserted into the adjacent edge set E; If not, it is determined that and cannot form an edge pair.

[0022] Optionally, the connected region operation module is specifically configured to: initialize the union-find set structure UF, perform the merging operation for each edge pair (i, j) ∈ E, and perform path compression to obtain a plurality of connected regions; label the connected region to which each valid point belongs as a root node index, and count the number of occurrences of each root node to obtain the size of each connected region.

[0023] Optionally, the connected region operation module is specifically configured to: According to a preset minimum effective region size threshold, small clusters with a size less than the minimum effective region size threshold are screened out from the plurality of connected regions, and effective connected regions are output.

[0024] Optionally, a is 73856093, b is 19349663, and c is 83492791.

[0025] Optionally, for each effective point in the point cloud P , its adjacent voxels in the regular grid are enumerated, specifically: For each effective point , its corresponding voxel coordinates are , 26 adjacent voxels are enumerated, and the coordinates of the adjacent voxels are , .

[0026] In a third aspect, the present application further provides a computer readable storage medium, and the storage medium stores at least one instruction, the instruction is loaded and executed by a processor to implement the point cloud connectivity segmentation method based on voxel hashing and union-find set as described above.

[0027] In a fourth aspect, the present application further provides a computer program product, comprising a computer program / instruction, when the computer program / instruction is executed by a processor, the point cloud connectivity segmentation method based on voxel hashing and union-find set as described above is implemented.

[0028] Compared with the prior art, the present application has the following beneficial effects: The point cloud connectivity segmentation method based on voxel hashing and union-find set provided in the present application realizes fast spatial positioning through a regular voxel grid, and realizes fast connectivity merging by using a union-find set structure, which can significantly improve the segmentation efficiency of a million-level or more scale point cloud, and the method can be widely applied to scenes such as three-dimensional reconstruction, industrial detection, and automatic driving environment perception. BRIEF DESCRIPTION OF DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings.

[0030] Figure 1 A flowchart of a point cloud connectivity segmentation method based on voxel hashing and union-find set provided by an embodiment of the present application.

[0031] Figure 2 A schematic diagram of an original point cloud provided by an embodiment of the present application.

[0032] Figure 3 The point cloud connectivity segmentation method based on voxel hashing and union-find provided in the embodiment of the present invention is used to segment the Figure 2 The result image obtained by segmenting the point cloud.

[0033] Figure 4 A schematic diagram of another original point cloud provided by an embodiment of the present invention.

[0034] Figure 5 The embodiment of the present invention provides a point cloud connectivity segmentation method based on voxel hashing and union-find set and a kd-Tree region growing algorithm for processing Figure 4 Comparison of computational runtimes for point clouds.

[0035] Figure 6 The point cloud connectivity segmentation method based on voxel hashing and union-find provided in the embodiment of the present invention is used to segment the Figure 4 The result image obtained by segmenting the point cloud.

[0036] Figure 7 A schematic diagram of the architecture of a point cloud connectivity segmentation system based on voxel hashing and union-find provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, features, and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only 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 making creative work are within the scope of protection of the present invention.

[0038] Example 1: Please refer to Figure 1 , Figure 1 A flowchart of a point cloud connectivity segmentation method based on voxel hashing and union-find is provided in an embodiment of the present invention. The method specifically includes: Preset step 100: obtaining original point cloud data.

[0039] Assume that the original point cloud is P. For ease of explanation, in this embodiment, the coordinates of the point cloud P in three-dimensional space are expressed as: , where N is the number of valid points in the point cloud P.

[0040] Step 110 : Calculate the maximum connectivity distance threshold of all valid points of the point cloud; and determine a bounding box according to the coordinates of all valid points of the point cloud in three-dimensional space.

[0041] Specifically, as an optional implementation, step 110 comprises: Step 111, uniformly or randomly sampling K valid points from the point cloud P, and recording as sampling points.

[0042] Step 112, respectively querying the nearest k neighborhood points of each sampling point through a pre-constructed kd-tree.

[0043] In step 112, kd-tree is the abbreviation of k-dimensional tree, which is a known tree data structure. The construction method or the means of querying neighborhood points through the kd-tree are all known prior art, so the process and principle will not be described in detail in this embodiment.

[0044] Step 113, statistics the Euclidean distance between all sampling points and their neighborhood points, and calculates the average value of all Euclidean distances.

[0045] More specifically, in step 113, the calculation formula of the average value of the Euclidean distance is: wherein, is the Euclidean distance between the sampling point and its neighborhood point .

[0046] Step 114, setting the maximum connected distance threshold as ; wherein, .

[0047] Step 115, determining the bounding box according to the coordinates of all valid points of the point cloud in the three-dimensional space.

[0048] In this embodiment, the bounding box is set as: ; wherein, , are the minimum value and the maximum value of , , are the minimum value and the maximum value of , , are the minimum value and the maximum value of .

[0049] Step 120, voxelizing the three-dimensional space according to the bounding box and the predetermined voxel grid size, to generate a regular grid.

[0050] In step 120, the predetermined voxel grid size is set as , that is, the voxel grid size is the maximum connected distance threshold obtained in step 114.

[0051] The number of the regular grid of voxels generated after voxelization is wherein, , , are respectively: .

[0052] Step 130, the grid index of the voxel corresponding to each valid point is calculated respectively.

[0053] Specifically, the calculation method of the grid index comprises: Step 131, for each valid point of the point cloud P , the corresponding voxel coordinate is calculated.

[0054] Specifically, let the corresponding voxel coordinate be , and the calculation method of the coordinate is: ; Step 132, the corresponding grid index is transformed according to the calculated voxel coordinate.

[0055] Specifically, the voxel coordinate is limited in the range of , and then the grid index of the one-dimensional array is transformed: .

[0056] Step 140, a hash mapping from voxels to valid points is constructed by double-pass scanning.

[0057] Step 140 specifically comprises: Step 141, by double-pass scanning, the grid index of all voxels contained in each voxel grid of the regular grid is obtained.

[0058] Specifically, step 141 further comprises: Step 1411, first-pass parallel counting. The method is: For each valid point of the point cloud P, the grid number to which the point belongs is calculated , and an array is obtained; the array is incremented by using thread private accumulation or atomic addition to obtain the number of points C[c] contained in each grid; Step 1412, prefix sum calculation. The method is: Initialize the array start with a length of n+1, start[0]=0, and for , execute start[c+1]=start[c]+C[c] in turn.

[0059] Step 1413, second-pass parallel writing. The method is: An integer array D of length N is allocated, and start[c] is copied to temporary index array idx[c]; Again, traverse all valid points of point cloud P, for each point, find the write start position pos = idx[cid_i] through "cid_i", then execute D[pos] = i, and let idx[cid_i] ++; After this is done, the index interval [start[c], start[c] + C[c]) in array D continuously stores all the grid indices of the points falling into voxel c. Step 142, a predetermined hash function is used to establish a voxel hash table.

[0060] In step 142, the predetermined hash function is: hash(v) = x * a^y * b^z * c, hash(v) is a hash index calculated based on voxel coordinates (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.

[0061] Preferably, a, b, and c are all large natural numbers, and in an exemplary embodiment, a is 73856093, b is 19349663, and c is 83492791.

[0062] Step 150, based on the hash mapping, the Euclidean distance judgment method is used to determine the adjacent edges of the point cloud, and an adjacent edge set is constructed.

[0063] Specifically, step 150 includes: Step 151, for each valid point in point cloud P , its adjacent voxels in the regular grid are enumerated respectively; and the valid points corresponding to the adjacent voxels are recorded as .

[0064] Exemplarily, in the present embodiment, for each valid point , let its corresponding voxel coordinates be ; Enumerate its 26 adjacent voxels, and the coordinates of the adjacent voxels are denoted as , wherein ; When within the legal index range, let the adjacent voxel number be , and the corresponding storage interval is [start[nc], start[nc] + C[nc])[start[nc], start[nc] + C[nc)].

[0065] Step 152, traverse each , calculate and Euclidean distance between them and determine whether to meet the following relationship: ; If yes, step 153 is executed; if no, step 154 is executed.

[0066] Step 153, the and composing edge pair (i, j), and inserting into the adjacent edge set E.

[0067] Step 154, determine and can not constitute edge pair.

[0068] In this embodiment, in order to accelerate the construction of the adjacent edge set, TBB parallel parallel_for is used, and tbb: concurrent_vector is used to store edge pairs to avoid multi-thread competition.

[0069] Step 160, using the union-find set structure to perform merging operation on the adjacent edges in the adjacent edge set and performing path compression to obtain several connected regions of the point cloud.

[0070] Step 160 specifically includes: Step 161, initializing the union-find set structure UF, performing merging operation and performing path compression for each edge pair (i, j) E, to obtain several connected regions.

[0071] For example, assuming that UF contains N elements, each element pointer points to itself, and the rank array initial value is 0. For all edges (i, j) in the set E, parallelly execute UF.unite(i, j) using parallel parallel_for segmented merging; After merging, roots[i]=UF.find(i) is executed for all points in [0, N) in parallel, and the path compression is performed on the union-find set tree, so that the parent node of each point directly points to the root node.

[0072] Step 162, marking each valid point belonging to the connected region as the root node index, and counting the number of occurrences of each root node to obtain the size of each connected region.

[0073] The number of root nodes is the number of regions, and the size of the root node pointing set is the number of region points.

[0074] Step 160 further includes: Step 170, according to the pre-set minimum effective region size threshold, screening out small clusters in several connected regions whose region size is less than the minimum effective region size threshold, and outputting the effective connected region.

[0075] Exemplarily, a minimum effective region size threshold s_min (such as 3-1000) is set, small clusters (i.e. the connected regions with a region size of s_min in the screening step 160) are screened out, and finally all connected regions meeting the conditions are output, each region corresponding to a group of point indexes.

[0076] For the convenience of understanding, specific implementation cases are also given below: Please refer to Figure 2 and Figure 3 , Figure 2 A schematic diagram of a raw point cloud provided by an embodiment of the present application, Figure 3 A result diagram obtained by segmenting the point cloud of Figure 2 by using the point cloud connectivity segmentation method based on voxel hashing and union-find set provided by an embodiment of the present application.

[0077] As shown in Figure 2 , the effective point number of the point cloud data is 113662; First, K points (K=1000) are uniformly or randomly sampled from the whole point cloud, and a kd-Tree is constructed to accelerate the nearest neighbor search; The average point distance is calculated as 0.006, alpha=4 is taken, and the voxel grid size=0.024 is calculated; The bounding box is: [1.151989, 3.519531], [0.815273, 2.761719], [0.726409, 1.530428].

[0078] The point cloud is reconstructed by spatial voxel hashing, and the 3D space is divided into regular grids according to a fixed grid size. After voxelization, n=99*82*34=276012 voxel grids can be obtained.

[0079] Two-pass scanning is used to construct the hash mapping from voxel to point: The following hash function is used to establish the voxel hash table: hash(v)=x*73856093^y*19349663^z*83492791, the selected constant in the formula is a pair of coprime large prime numbers, which is used to enhance the discrete uniformity of the spatial coordinate mapping.

[0080] For each effective point , its voxel number v i is determined, and its 26 adjacent voxels v j are enumerated; All point pairs , are traversed, the Euclidean distance between and is calculated, and whether the following relationship is satisfied is judged: If satisfied, will and constitute edge pair (i, j), and insert into the adjacent edge set E. This step uses TBB parallel acceleration, all edge pairs are stored in concurrent_vector, avoiding write conflicts.

[0081] Initialize the union-find set structure UF, and for each edge pair (i, j) ∈ E, perform the merge operation: UF.unite(i, j), and perform path compression: root[i] = UF.find(i); Mark the connected region to which each point belongs as the final root node index; count the number of occurrences of each root node, which is the region size.

[0082] Set the minimum effective region size threshold s_min (such as 3~1000), and screen out small clusters. Finally, output all connected regions that meet the conditions, and each region corresponds to a set of point indexes.

[0083] The final point cloud segmentation result is shown in Figure 3 .

[0084] In order to compare the time-consuming optimization effect of the overall algorithm, the following comparative example is also given: First, test the segmentation processing time of the point cloud connectivity segmentation method based on voxel hashing and union-find set provided in the embodiment on Figure 4 point cloud data, and the segmentation result is shown in Figure 6 .Then, compare the calculation running time of the kd-Tree region growing algorithm, see Figure 5 . From Figure 5 , it can be observed that the segmentation technology of the embodiment has achieved 33.7% speedup of the algorithm running time compared with the kd-Tree region growing algorithm.

[0085] In summary, compared with the prior art, the point cloud connectivity segmentation method based on voxel hashing and union-find set provided in the embodiment has at least the following beneficial effects: 1) The regular voxel grid is constructed by two scans, without dynamic expansion of the hash table, so that the spatial positioning of a single point only needs O(1) complexity operation, compared with the O(logN) complexity of the kd-Tree range query, the voxel neighborhood scanning only needs to access the continuous memory of 26 adjacent grids, which is cache-friendly and easy to parallel.

[0086] 2) By introducing the TBB parallel framework, voxel construction, adjacent collection, union set merging and path compression can be performed concurrently, which is significantly accelerated in a multi-core environment.

[0087] 3) After the union and path compression operations are performed and amortized, the original O(n) operation complexity is reduced to nearly O(1) constant time, which can be regarded as a constant.

[0088] 4) The speed is improved compared with the traditional method on a million-level point cloud, and is particularly suitable for industrial defect detection, environment mapping and other scenes that require real-time or near real-time calculation.

[0089] Embodiment two: Please refer to Figure 7 , Figure 7 The embodiment of the application provides a kind of based on the architecture principle diagram of voxel Hash and connected set of point cloud connectivity segmentation system. The system specifically includes: Point cloud data processing module 10, for calculating the maximum connected distance threshold of all valid points of point cloud;And, according to the coordinates of all valid points of point cloud in three-dimensional space to determine bounding box; Network reconstruction module 20, electric connection point cloud data processing module 10, for according to bounding box and voxel grid size, three-dimensional space voxelization is generated Regular grid;Wherein, voxel grid size is defined as maximum connected distance threshold; Network reconstruction module 20 is also used to calculate the grid index of each voxel corresponding to each valid point; Mapping module 30, electric connection network reconstruction module 20, for constructing the hash mapping of voxel to valid point by double-pass scanning; Connected region operation module 40, electric connection mapping module 30, for determining the adjacent edge of point cloud based on hash mapping, using Euclidean distance judgment method;Adjacent edge set is constructed;Also for using union-set structure to perform merging operation on adjacent edge in adjacent edge set and carry out path compression, obtain several connected regions of point cloud.

[0090] Wherein, the method for calculating the maximum connected distance threshold of all valid points of point cloud, the determination method of bounding box, the calculation method of grid index are already clearly set forth in embodiment one, therefore in this embodiment will not be repeated.

[0091] Specifically, mapping module 30 is specifically used for: Through double-pass scanning, the grid index of all voxels contained by each voxel grid of regular grid is obtained; A predetermined hash function is used to establish voxel hash table: wherein, the predetermined hash function is: hash (v) = x * a ^ y * b ^ z * c, hash (v) is the hash index calculated based on voxel coordinates (x, y, z), three constants a, b, c in the function are relatively prime prime numbers.

[0092] Specifically, connected region operation module 40 is specifically used for: For each valid point in the point cloud P , enumerate its neighboring voxels in the regular grid respectively; implemented as: for each valid point , its corresponding voxel coordinates are , enumerate its 26 neighboring voxels, and the coordinates of the neighboring voxels are denoted as , .

[0093] Denote the valid point corresponding to the neighboring voxel as ; Traverse each , calculate the Euclidean distance between and and determine whether the following relationship is satisfied: If yes, then and form an edge pair (i, j), and are inserted into the adjacent edge set E; If no, then determine that and cannot form an edge pair.

[0094] Specifically, the connected region operation module 40 is specifically further used for: Initializing the union-find set structure UF, performing a merging operation and performing path compression for each edge pair (i, j) E, to obtain a plurality of connected regions; Marking the connected region to which each valid point belongs as a root node index, and counting the number of occurrences of each root node to obtain the size of each connected region.

[0095] Specifically, the connected region operation module 40 is specifically further used for: According to the pre-set minimum effective region size threshold, screen out small clusters in the plurality of connected regions that are smaller than the minimum effective region size threshold, and output the effective connected regions.

[0096] The point cloud connectivity segmentation system based on voxel hashing and union-find set provided in the embodiment achieves fast spatial positioning through a regular voxel grid, and realizes fast connectivity merging by using a union-find set structure, which can significantly improve the segmentation efficiency of a million-level or larger scale point cloud. The system can be widely applied to scenes such as three-dimensional reconstruction, industrial detection, and automatic driving environment perception.

[0097] Embodiment Three The embodiment also provides a computer readable storage medium, the storage medium storing at least one instruction, the instruction being loaded and executed by a processor to implement the point cloud connectivity segmentation method based on voxel hashing and union-find set according to the embodiment one.

[0098] Since the point cloud connectivity segmentation method based on voxel hashing and union-find set has been described in detail in Embodiment One, the description will not be repeated in this embodiment.

[0099] Embodiment Four: The application also provides a computer program product, comprising computer programs / instructions, which, when executed by a processor, implement the point cloud connectivity segmentation method based on voxel hashing and union-find set as described in Embodiment One.

[0100] Since the point cloud connectivity segmentation method based on voxel hashing and union-find set has been described in detail in Embodiment One, the description will not be repeated in this embodiment.

[0101] Those skilled in the art can understand that all or part of the steps of the above embodiments can be completed by hardware, or by program instructions to instruct related hardware to complete, and the program can be stored in a computer readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk. Based on this understanding, the technical solutions of the application or the part that contributes to the prior art, or all or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes instructions to make a computer device (which can be a personal computer, a server, or a network device) execute all or part of the steps of the method described in each embodiment of the application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0102] The above description and the above embodiments are only used to illustrate the technical solutions of the application, but not to limit it; although the application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to some technical features; and these modifications or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the application.

Claims

1. A point cloud connectivity segmentation method based on voxel hashing and union-find, characterized in that: include: Calculate the maximum connectivity distance threshold of all valid points in the point cloud; and determining a bounding box based on the coordinates of all valid points of the point cloud in three-dimensional space; voxelize the three-dimensional space according to the bounding box and a predetermined voxel grid size to generate a regular grid; the predetermined voxel grid size is the maximum connectivity distance threshold; Calculate the grid index of the voxel corresponding to each valid point respectively; Construct a hash map from voxels to valid points through double-pass scanning; Based on the hash map, the adjacent edges of the point cloud are determined using the Euclidean distance judgment method to construct an adjacent edge set; A union-find structure is used to perform a merging operation on the adjacent edges in the adjacent edge set and perform path compression to obtain a number of connected regions of the point cloud.

2. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 1, characterized in that: The maximum connectivity distance threshold of all valid points in the point cloud is calculated as follows: Sample K valid points uniformly or randomly from the point cloud P and record them as sampling points; Through the pre-constructed kd-tree, query the k nearest neighboring points of each sampling point respectively; Count the Euclidean distances between all sampling points and their neighboring points, and calculate the average of all Euclidean distances. The calculation formula is: ; in, For sampling points and its neighboring points The Euclidean distance between Set the maximum connectivity distance threshold to ;in, .

3. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 2, characterized in that: Determining the bounding box according to the coordinates of all valid points of the point cloud in the three-dimensional space specifically includes: Let the point cloud be P. The coordinates of point cloud P in three-dimensional space are expressed as: , where N is the number of valid points in the point cloud; The bounding box is: ,in, 、 They are The minimum and maximum values ​​of 、 They are The minimum and maximum values ​​of 、 They are The minimum and maximum values ​​of .

4. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 3, characterized in that: The grid index of the voxel corresponding to each valid point is calculated separately by: For each valid point in the point cloud P , calculate the corresponding voxel coordinates , the method is: ; The voxel coordinates Restricted to The range is then transformed to obtain the grid index of the one-dimensional array: , 、 、 They are: , voxel grid size , the number of voxel grids of the regular grid is .

5. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 4, characterized in that: The method of constructing a hash map from voxels to valid points by double-pass scanning specifically includes: Obtaining grid indexes of all voxels contained in each voxel grid of the regular grid through double-pass scanning; A voxel hash table is established using a predetermined hash function: wherein the predetermined hash function is: hash(v)=x*a^y*b^z*c, hash(v) is the hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b, and c in this function are coprime numbers.

6. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 5, characterized in that: The method of determining adjacent edges of the point cloud based on the hash map and constructing an adjacent edge set by using the Euclidean distance judgment method specifically includes: For every valid point in the point cloud P , enumerate the neighboring voxels in the regular grid respectively; and record the valid points corresponding to the neighboring voxels as ; Traverse each ,calculate and The Euclidean distance between them and whether the following relationship is satisfied: ; If so, then and Form an edge pair (i, j) and insert it into the adjacent edge set E; If not, then determine and Cannot form side pairs.

7. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 6, characterized in that: The union-find structure is used to merge the adjacent edges in the adjacent edge set and perform path compression to obtain several connected regions of the point cloud, specifically including: Initialize the union-find structure UF, perform a merge operation and path compression on each edge pair (i, j)∈E, and obtain several connected regions; The connected area to which each valid point belongs is marked as the root node index, and the number of occurrences of each root node is counted to obtain the size of each connected area.

8. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 7, characterized in that: After performing a merging operation and path compression on the adjacent edges in the adjacent edge set using the union-find structure to obtain a plurality of connected regions of the point cloud, the method further includes: According to a preset minimum valid region size threshold, small clusters whose sizes are smaller than the minimum valid region size threshold are screened out from the plurality of connected regions, and valid connected regions are output.

9. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 5, characterized in that: a is 73856093, b is 19349663, and c is 83492791.

10. The point cloud connectivity segmentation method based on voxel hashing and union-find according to claim 6, characterized in that: For each valid point in the point cloud P , respectively enumerate its neighboring voxels in a regular grid, specifically: For each valid point , and its corresponding voxel coordinates are , enumerate its 26 neighboring voxels, the coordinates of the neighboring voxels are , .

11. A point cloud connectivity segmentation system based on voxel hashing and union-find, characterized in that: include: Point cloud data processing module, used to calculate the maximum connectivity distance threshold of all valid points in the point cloud; and determining a bounding box based on the coordinates of all valid points of the point cloud in three-dimensional space; a network reconstruction module, electrically connected to the point cloud data processing module, configured to voxelize the three-dimensional space according to the bounding box and the voxel grid size to generate a regular grid; wherein the voxel grid size is defined as the maximum connectivity distance threshold; The network reconstruction module is further used to respectively calculate the grid index of the voxel corresponding to each valid point; a mapping module, electrically connected to the network reconstruction module, for constructing a hash mapping from voxels to valid points through double-pass scanning; A connected region operation module is electrically connected to the mapping module and is used to determine the adjacent edges of the point cloud based on the hash mapping using the Euclidean distance judgment method to construct an adjacent edge set; and is also used to use a union-find structure to perform a merging operation on the adjacent edges in the adjacent edge set and perform path compression to obtain a number of connected regions of the point cloud.

12. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 11, characterized in that: The maximum connectivity distance threshold of all valid points in the point cloud is calculated as follows: Sample K valid points uniformly or randomly from the point cloud P and record them as sampling points; Through the pre-constructed kd-tree, query the k nearest neighboring points of each sampling point respectively; Count the Euclidean distances between all sampling points and their neighboring points, and calculate the average of all Euclidean distances. The calculation formula is: ; in, For sampling points and its neighboring points The Euclidean distance between Set the maximum connectivity distance threshold to ;in, .

13. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 12, characterized in that: Determining the bounding box according to the coordinates of all valid points of the point cloud in the three-dimensional space specifically includes: Let the point cloud be P. The coordinates of point cloud P in three-dimensional space are expressed as: , where N is the number of valid points in the point cloud; The bounding box is: ,in, 、 They are The minimum and maximum values ​​of 、 They are The minimum and maximum values ​​of 、 They are The minimum and maximum values ​​of .

14. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 13, characterized in that: The grid index of the voxel corresponding to each valid point is calculated separately by: For each valid point in the point cloud P , calculate the corresponding voxel coordinates , the method is: ; The voxel coordinates Restricted to The range is then transformed to obtain the grid index of the one-dimensional array: , 、 、 They are: , voxel grid size , the number of voxel grids of the regular grid is .

15. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 14, characterized in that: The mapping module is specifically used for: Obtaining grid indexes of all voxels contained in each voxel grid of the regular grid through double-pass scanning; A voxel hash table is established using a predetermined hash function: wherein the predetermined hash function is: hash(v)=x*a^y*b^z*c, hash(v) is the hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b, and c in this function are coprime numbers.

16. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 15, characterized in that: The connected region calculation module is specifically used for: For every valid point in the point cloud P , enumerate the neighboring voxels in the regular grid respectively; and record the valid points corresponding to the neighboring voxels as ; Traverse each ,calculate and The Euclidean distance between them and whether the following relationship is satisfied: ; If so, then and Form an edge pair (i, j) and insert it into the adjacent edge set E; If not, then determine and Cannot form side pairs.

17. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 16, characterized in that: The connected region calculation module is further configured to: Initialize the union-find structure UF, perform a merge operation and path compression on each edge pair (i, j)∈E, and obtain several connected regions; The connected area to which each valid point belongs is marked as the root node index, and the number of occurrences of each root node is counted to obtain the size of each connected area.

18. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 17, characterized in that: The connected region calculation module is further configured to: According to a preset minimum valid region size threshold, small clusters whose sizes are smaller than the minimum valid region size threshold are screened out from the plurality of connected regions, and valid connected regions are output.

19. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 15, characterized in that: a is 73856093, b is 19349663, and c is 83492791.

20. The point cloud connectivity segmentation system based on voxel hashing and union-find according to claim 16, characterized in that: For each valid point in the point cloud P , respectively enumerate its neighboring voxels in a regular grid, specifically: For each valid point , and its corresponding voxel coordinates are , enumerate its 26 neighboring voxels, the coordinates of the neighboring voxels are , .

21. A computer-readable storage medium, wherein at least one instruction is stored in the storage medium, characterized in that: The instructions are loaded and executed by the processor to implement a point cloud connectivity segmentation method based on voxel hashing and union-find as described in any one of claims 1 to 10.

22. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, a point cloud connectivity segmentation method based on voxel hashing and union-find as described in any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Virtual reality scene modeling system and method based on three-dimensional point cloud

    CN117036610A

  • Three-dimensional representation by multi-scale voxel hashing

    US20190385355A1

Cited By

  • Grid ray intersection method based on multi-dimensional Hash acceleration

    CN121053306A

  • Target identification method and device, equipment and storage medium

    CN122244572A