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
By employing voxel hashing and disjoint-set data structures, the problem of low efficiency in large-scale point cloud segmentation is solved, enabling fast point cloud connectivity segmentation, which is suitable for applications such as 3D reconstruction and autonomous driving environmental perception.
Patent Information
- Application Number
- CN202511188327.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-08-25
AI Technical Summary
Existing technologies have low segmentation efficiency when processing point clouds of millions or more, especially when the point cloud distribution is uneven or there is a lot of noise. The voxel hashing method still requires multiple hash lookups and graph searches, resulting in poor overall efficiency.
A method based on voxel hashing and disjoint-set data structure is adopted to determine adjacent edges by calculating the maximum connected distance threshold, constructing a regular grid, hash mapping and Euclidean distance judgment method, and using disjoint-set data structure for path compression to achieve fast connected region merging.
It significantly improves the segmentation efficiency of point clouds with a scale of millions or more, and is suitable for scenarios such as 3D reconstruction, industrial inspection and autonomous driving environmental perception, reducing computing time and increasing processing speed.
Smart Images

Figure CN120782807B_ABST
Abstract
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 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 space index, researchers have proposed a voxel hashing-based neighbor search method, that is, to divide the three-dimensional space into regular grids of fixed size (voxel), and then use 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:
[0007] In a first aspect, the present application provides a point cloud connectivity segmentation method based on voxel hashing and union-find set, comprising:
[0008] 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;
[0009] 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;
[0010] calculating the grid index of the voxel corresponding to each valid point respectively;
[0011] constructing a hash mapping from voxel to valid point through double-pass scanning;
[0012] 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;
[0013] 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.
[0014] Optionally, the method for calculating the maximum connected distance threshold of all valid points of the point cloud comprises:
[0015] uniformly or randomly sampling K valid points from the point cloud P, and recording them as sampling points;
[0016] querying the nearest k neighborhood points of each sampling point through a pre-constructed kd-tree;
[0017] counting the Euclidean distances between all sampling points and their neighborhood points, and calculating the average value of all Euclidean distances, the calculation formula being:
[0018] ;
[0019] wherein, is the Euclidean distance between the sampling point and its neighborhood point ;
[0020] setting the maximum connected distance threshold as ; wherein, .
[0021] 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:
[0022] assuming that the point cloud is P, and the coordinates of the point cloud P in the three-dimensional space are expressed as:
[0023] wherein N is the number of valid points in the point cloud;
[0024] The bounding box is:
[0025] wherein, , are the minimum and maximum values of , respectively, , are the minimum and maximum values of , respectively, , are the minimum and maximum values of , respectively.
[0026] Optionally, the method for calculating the grid index of the voxel corresponding to each valid point is:
[0027] For each valid point P of the point cloud P, , the voxel coordinate corresponding to the valid point is calculated , and the method is:
[0028] ;
[0029] The voxel coordinate is limited in the range of , and the one-dimensional array of the grid index is obtained by transformation:
[0030] , , , are respectively:
[0031] , the voxel grid size , and the number of voxel grids of the regular grid is .
[0032] Optionally, the method for constructing the hash mapping of the voxel to the valid point by double scanning includes:
[0033] By double scanning, the grid index of all voxels contained in each voxel grid of the regular grid is obtained;
[0034] A predetermined hash function is used to establish a voxel hash table, wherein the predetermined hash function is:
[0035] 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.
[0036] Optionally, the adjacent edges of the point cloud are determined based on the hash mapping by using a Euclidean distance judgment method, and an adjacent edge set is constructed, and specifically includes:
[0037] For each valid point in the point cloud P , its adjacent voxels in the regular grid are enumerated respectively; and the valid point corresponding to the adjacent voxels is recorded as ;
[0038] Each is traversed, the Euclidean distance between and is calculated, and whether the following relationship is satisfied is judged:
[0039] ;
[0040] If yes, the edge pair (i, j) is formed by and , and is inserted into the adjacent edge set E;
[0041] If no, it is determined that and cannot form an edge pair.
[0042] Optionally, the merging operation is performed on the adjacent edges in the adjacent edge set by using the union-find set structure, and path compression is performed, to obtain a plurality of connected regions of the point cloud, and specifically includes:
[0043] The union-find set structure UF is initialized, and for each edge pair (i, j) E, the merging operation is performed and the path compression is performed, to obtain a plurality of connected regions;
[0044] Each connected region to which each valid point belongs is marked as a root node index, and the number of occurrences of each root node is counted, to obtain the size of each connected region.
[0045] Optionally, after the merging operation is performed on the adjacent edges in the adjacent edge set by using the union-find set structure and the path compression is performed, to obtain a plurality of connected regions of the point cloud, the method further includes:
[0046] According to a pre-set minimum effective region size threshold, small clusters with a size smaller than the minimum effective region size threshold are screened out from the plurality of connected regions, and valid connected regions are output.
[0047] Optionally, a is 73856093, b is 19349663, and c is 83492791.
[0048] Optionally, for each valid point in the point cloud P , its adjacent voxels in the regular grid are enumerated, and specifically includes:
[0049] For each valid point its corresponding voxel coordinates are , enumerate its 26 adjacent voxels, the coordinates of adjacent voxels are , .
[0050] In a second aspect, the present application provides a point cloud connectivity segmentation system based on voxel hashing and union-find set, comprising:
[0051] A point cloud data processing module is configured to calculate the maximum connected distance threshold of all valid points of the point cloud, and determine the bounding box of the point cloud according to the coordinates of all valid points of the point cloud in the three-dimensional space.
[0052] A network reconstruction module is electrically connected to the point cloud data processing module and is 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 connected distance threshold.
[0053] The network reconstruction module is further configured to calculate the grid index of the voxel corresponding to each valid point, respectively.
[0054] A mapping module is electrically connected to the network reconstruction module and is configured to construct a hash mapping from voxels to valid points through double-pass scanning.
[0055] A connected region operation module is electrically connected to the mapping module and is 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; the connected region operation module is 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 regions of the point cloud.
[0056] Optionally, the method for calculating the maximum connected distance threshold of all valid points of the point cloud comprises:
[0057] K valid points are uniformly or randomly sampled from the point cloud P and are denoted as sampling points.
[0058] The nearest k neighborhood points of each sampling point are queried through a pre-constructed kd-tree.
[0059] The Euclidean distances between all sampling points and their neighborhood points are counted, and the average value of all Euclidean distances is calculated, and the calculation formula is:
[0060] ;
[0061] wherein, is the Euclidean distance between the sampling point and its neighborhood point ;
[0062] The maximum connected distance threshold is set as ; wherein .
[0063] Optionally, the bounding box is determined according to coordinates of all valid points of the point cloud in the three-dimensional space, and specifically includes:
[0064] Supposing the point cloud is P, coordinates of the point cloud P in the three-dimensional space are expressed as:
[0065] wherein N is the number of valid points in the point cloud;
[0066] The bounding box is:
[0067] wherein, , are minimum and maximum values of , respectively, , are minimum and maximum values of , respectively, , are minimum and maximum values of , respectively.
[0068] Optionally, the grid index of the voxel corresponding to each valid point is calculated respectively, and the method is:
[0069] for each valid point of the point cloud P, the voxel coordinate corresponding to the valid point is calculated , and the method is:
[0070] ;
[0071] The voxel coordinate is limited in the range of , and a one-dimensional array of grid indexes is obtained by transformation:
[0072] , , , are respectively:
[0073] , the voxel grid size , and the number of voxel grids of the regular grid is .
[0074] Optionally, the mapping module is specifically used for:
[0075] Through double scanning, the grid index of all voxels contained in each voxel grid of the regular grid is obtained;
[0076] A predetermined hash function is used to establish a voxel hash table, wherein the predetermined hash function is:
[0077] hash(v) = x * a^y * b^z * c, hash(v) is a hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.
[0078] Optionally, the connected region operation module is specifically configured to:
[0079] 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 ;
[0080] Traverse each , calculate the Euclidean distance between and and determine whether the following relationship is satisfied:
[0081] ;
[0082] If yes, the edge pair (i, j) is formed by and , and is inserted into the adjacent edge set E;
[0083] If no, it is determined that and cannot form an edge pair.
[0084] Optionally, the connected region operation module is specifically further configured to:
[0085] Initialize the union-find set structure UF, perform the merging operation and perform the path compression for each edge pair (i, j) E, to obtain a plurality of connected regions;
[0086] Mark 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.
[0087] Optionally, the connected region operation module is specifically further configured to:
[0088] According to a pre-set minimum effective region size threshold, small clusters with a size smaller than the minimum effective region size threshold are screened out from the plurality of connected regions, and valid connected regions are output.
[0089] Optionally, a is 73856093, b is 19349663, and c is 83492791.
[0090] Optionally, for each valid point in the point cloud P , the adjacent voxels in the regular grid are enumerated respectively, and specifically:
[0091] For each valid point , its corresponding voxel coordinate is , enumerate its 26 adjacent voxels, the coordinates of adjacent voxels are , .
[0092] In a third aspect, the present application also provides a computer readable storage medium, the storage medium stores at least one instruction, the instruction is loaded and executed by the processor to realize the point cloud connectivity segmentation method based on voxel hashing and union-find set as described above.
[0093] In a fourth aspect, the present application also provides a computer program product, comprising computer programs / instructions, when the computer programs / instructions are executed by the processor, the point cloud connectivity segmentation method based on voxel hashing and union-find set as described above is realized.
[0094] Compared with the prior art, the present application has the following beneficial effects:
[0095] 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 point clouds with a scale of one million or more. The method can be widely applied to scenes such as three-dimensional reconstruction, industrial detection, and automatic driving environment perception. BRIEF DESCRIPTION OF DRAWINGS
[0096] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. 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.
[0097] Figure 1 A flowchart of the point cloud connectivity segmentation method based on voxel hashing and union-find set provided by the embodiment of the present application.
[0098] Figure 2 A schematic diagram of the original point cloud provided by the embodiment of the present application.
[0099] 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 the embodiment of the present application.
[0100] Figure 4 Another schematic diagram of the original point cloud provided by the embodiment of the present application.
[0101] Figure 5 A comparison chart of the calculation running time of the point cloud processed by the point cloud connectivity segmentation method based on voxel hashing and the union set and the kd-Tree region growing algorithm provided by the embodiment of the present application. Figure 4 A comparison chart of the calculation running time of the point cloud processed by the point cloud connectivity segmentation method based on voxel hashing and the union set and the kd-Tree region growing algorithm provided by the embodiment of the present application.
[0102] Figure 6 A comparison chart of the calculation running time of the point cloud processed by the point cloud connectivity segmentation method based on voxel hashing and the union set and the kd-Tree region growing algorithm provided by the embodiment of the present application. Figure 4 A comparison chart of the calculation running time of the point cloud processed by the point cloud connectivity segmentation method based on voxel hashing and the union set and the kd-Tree region growing algorithm provided by the embodiment of the present application.
[0103] Figure 7 A comparison chart of the calculation running time of the point cloud processed by the point cloud connectivity segmentation method based on voxel hashing and the union set and the kd-Tree region growing algorithm provided by the embodiment of the present application. DETAILED DESCRIPTION
[0104] In order to make the purpose, characteristics and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the embodiments described below are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0105] Embodiment one:
[0106] Please refer to Figure 1 , Figure 1 A flowchart of the point cloud connectivity segmentation method based on voxel hashing and the union set provided by the embodiment of the present application, which specifically includes:
[0107] The preset step 100 acquires the original point cloud data.
[0108] Let the original point cloud be P. In order to facilitate the description, in the embodiment, the coordinate of the point cloud P in the three-dimensional space is expressed as:
[0109] Where N is the number of effective points in the point cloud P.
[0110] Step 110, calculate the maximum connectivity distance threshold of all effective points of the point cloud; and determine the bounding box according to the coordinates of all effective points of the point cloud in the three-dimensional space.
[0111] Specifically, as an optional implementation, step 110 includes:
[0112] Step 111, uniformly or randomly sample K effective points from the point cloud P, and record them as sampling points.
[0113] Step 112, query the k nearest neighbor points of each sampling point respectively through the pre-constructed kd-tree.
[0114] 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 neighbor points through kd-tree are known prior art, so the process and principle will not be described in this embodiment.
[0115] Step 113, calculate the average value of the Euclidean distance between all sampling points and their neighbor points.
[0116] More specifically, in step 113, the average value of the Euclidean distance is calculated as follows:
[0117] , wherein, is the Euclidean distance between the sampling point and its neighbor point .
[0118] Step 114, set the maximum connected distance threshold value as ; wherein, .
[0119] Step 115, determine the bounding box according to the coordinates of all effective points of the point cloud in the three-dimensional space.
[0120] In this embodiment, the bounding box is set as: ;
[0121] , wherein, , are the minimum and maximum values of , , are the minimum and maximum values of , , are the minimum and maximum values of .
[0122] Step 120, voxelize the three-dimensional space according to the bounding box and the predetermined voxel grid size, to generate a regular grid.
[0123] In step 120, the predetermined voxel grid size is set as , that is, the voxel grid size is the maximum connected distance threshold value obtained in step 114.
[0124] The number of voxel grids of the regular grid generated after voxelization is , wherein, , , Respectively:
[0125] .
[0126] Step 130, respectively calculate the grid index of the voxel corresponding to each valid point.
[0127] Specifically, the calculation method of the grid index includes:
[0128] Step 131, for each valid point of the point cloud P , calculate the corresponding voxel coordinates.
[0129] Specifically, let The corresponding voxel coordinates are , and the calculation method of the coordinates is:
[0130] ;
[0131] Step 132, according to the calculated voxel coordinates, transform to obtain the corresponding grid index.
[0132] Specifically, limit the voxel coordinates to the range , and then transform to obtain the grid index of the one-dimensional array:
[0133] .
[0134] Step 140, construct the hash mapping from voxel to valid point by double scanning.
[0135] Step 140 specifically includes:
[0136] Step 141, by double scanning, obtain the grid index of all voxels contained in each voxel grid of the regular grid.
[0137] Specifically, step 141 further includes:
[0138] Step 1411, first pass parallel counting. The method is:
[0139] For each valid point of the point cloud P, calculate the grid number to which it belongs , obtain the array ; use thread private accumulation or atomic addition to let the array increment by one to obtain the number of points C[c] contained in each grid;
[0140] Step 1412, prefix sum calculation. The method is:
[0141] Initialize the array start length n+1, start[0]=0, for start[c+1]=start[c]+C[c] is executed in turn.
[0142] Step 1413, second pass parallel writing. The method is:
[0143] An integer array D with length N is allocated, and start[c] is copied to a temporary index array idx[c];
[0144] All valid points of the point cloud P are traversed again, for each point, the writing start position pos=idx[cid_i] is found through "cid_i", then D[pos]=i is executed, and idx[cid_i] is incremented by 1;
[0145] After this is done, the index interval [start[c], start[c]+C[c]) in the array D is continuously stored with all points falling into voxel c.
[0146] Step 142, a predetermined hash function is used to establish a voxel hash table.
[0147] In step 142, the predetermined hash function is:
[0148] hash(v)=x*a^y*b^z*c, hash(v) is a hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.
[0149] 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.
[0150] 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.
[0151] Specifically, step 150 includes:
[0152] Step 151, for each valid point in the 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 .
[0153] Exemplarily, in the present embodiment, for each valid point , its corresponding voxel coordinates are ;
[0154] Its 26 adjacent voxels are enumerated, and the coordinates of the adjacent voxels are recorded as , wherein ;
[0155] When within the legal index range, let the adjacent voxel number be The corresponding storage interval is [start[nc], start[nc]+C[nc])[start[nc], start[nc]+C[nc]).
[0156] Step 152, traverse each , calculate the Euclidean distance between and and determine whether the following relationship is satisfied:
[0157] ;
[0158] If yes, step 153 is executed; if no, step 154 is executed.
[0159] Step 153, the edge pair (i, j) is composed of and , and is inserted into the adjacent edge set E.
[0160] Step 154, it is determined that and cannot form an edge pair.
[0161] 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 the edge pair to avoid multi-thread competition.
[0162] Step 160, the merging operation is performed on the adjacent edges in the adjacent edge set by using the union-find set structure, and path compression is performed, to obtain several connected regions of the point cloud.
[0163] Step 160 specifically includes:
[0164] Step 161, initialize the union-find set structure UF, perform the merging operation and perform path compression for each edge pair (i, j) E, to obtain several connected regions.
[0165] For example, it is assumed 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, UF.unite(i, j) is executed in parallel, and parallel parallel_for is used for segmented merging;
[0166] After merging, roots[i]=UF.find(i) is executed once for all points in [0, N) in parallel, to perform path compression on the union-find set tree, so that the parent node of each point directly points to the root node.
[0167] Step 162, mark each 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.
[0168] The number of root nodes is the number of regions, and the size of the region pointed to by the root node is the number of region points.
[0169] Step 160 further comprises:
[0170] Step 170, according to the pre-set minimum effective region size threshold, screen out small clusters in several connected regions whose region size is less than the minimum effective region size threshold, and output the effective connected region.
[0171] For example, set the minimum effective region size threshold s_min (such as 3~1000), screen out small clusters (i.e. screen out the connected region with a region size of s_min in step 160), and finally output all connected regions that meet the conditions, each region corresponding to a group of point indexes.
[0172] For ease of understanding, specific implementation cases are also given below:
[0173] 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 using the point cloud connectivity segmentation method based on voxel hashing and union-find set provided by an embodiment of the present application to segment Figure 2 .
[0174] As shown in Figure 2 , the number of valid points of the point cloud data is 113662;
[0175] First, K points (K=1000) are uniformly or randomly sampled from the entire point cloud, and a kd-Tree is constructed to accelerate the nearest neighbor search;
[0176] The average point distance is calculated as 0.006, alpha=4 is taken, and the voxel grid size is calculated as 0.024;
[0177] The bounding box is: [1.151989, 3.519531], [0.815273, 2.761719], [0.726409, 1.530428].
[0178] 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.
[0179] Two-pass scanning is used to construct the hash mapping from voxel to point:
[0180] The following hash function is used to build the voxel hash table:
[0181] hash(v) = x * 73856093^y * 19349663^z * 83492791. The constants selected in the formula are coprime large prime numbers, which are used to enhance the discrete uniformity of spatial coordinate mapping.
[0182] For each valid point Determine its voxel number v i And enumerate its 26 neighboring voxels. j ;
[0183] Iterate through all pairs of points ( , ),calculate and Determine whether the Euclidean distance between them satisfies the following relationship:
[0184] ;
[0185] If satisfied, and Form edge pairs (i,j) and insert them into the adjacent edge set E. This step is accelerated using TBB parallelism, and all edge pairs are stored in a concurrent vector to avoid write conflicts.
[0186] Initialize the disjoint-set data structure UF. For each edge pair (i,j)∈E, perform a merge operation: UF.unite(i,j) and perform path compression: root[i]=UF.find(i).
[0187] Mark the connected region to which each point belongs as the final root node index; count the occurrences of each root node, which is the region size.
[0188] Set a minimum effective region size threshold s_min (e.g., 3~1000) to filter out small clusters. Finally, output all connected regions that meet the conditions, with each region corresponding to a set of point indices.
[0189] The final point cloud segmentation result is as follows Figure 3 As shown.
[0190] To compare the overall algorithm's time optimization performance, this embodiment also provides the following comparative examples:
[0191] First, we tested the point cloud connectivity segmentation method based on voxel hashing and disjoint-set data structure provided in this embodiment. Figure 4 The segmentation processing time for the midpoint cloud data is shown in the appendix. Figure 6 Then, compare the computation time of the kd-Tree region growing algorithm, see...Figure 5 ;
[0192] By Figure 5 It can be concluded from the observation that the segmentation technology of the embodiment realizes an algorithm running time acceleration of 33.7% compared with the kd-Tree region growing algorithm effect.
[0193] In summary, compared with the prior art, the point cloud connectivity segmentation method based on voxel hashing and union-find set provided by the embodiment has at least the following beneficial effects:
[0194] 1) The regular voxel grid is constructed by two-pass scanning 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.
[0195] 2) By introducing the TBB parallel framework, the voxel construction, adjacency collection, union-find set merging and path compression can be concurrently executed, which is significantly accelerated in a multi-core environment.
[0196] 3) The amortized union and path compression operations reduce the original O(n) operation complexity to nearly O(1) constant time, which can be almost considered as a constant.
[0197] 4) The speed is improved compared with the traditional method on a million-level point cloud, and it is especially suitable for industrial defect detection, environment mapping and other scenes that require real-time or near real-time calculation.
[0198] Embodiment two:
[0199] Please refer to Figure 7 , Figure 7 The embodiment of the application provides a kind of based on the architecture principle diagram of voxel hashing and union-find set's point cloud connectivity segmentation system. The system specifically includes:
[0200] 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;
[0201] Network reconstruction module 20, electric connection point cloud data processing module 10, for according to bounding box and voxel grid size, three-dimensional space is voxelized, generates regular grid;Wherein, voxel grid size is defined as maximum connected distance threshold;
[0202] Network reconstruction module 20 is also used to calculate the grid index of the voxel corresponding to each valid point respectively;
[0203] Mapping module 30, electric connection network reconstruction module 20, for constructing hash mapping of voxel to valid point by double-pass scanning;
[0204] The communication area operation module 40 is electrically connected to the mapping module 30, configured to determine the adjacent edges of the point cloud based on the hash mapping and the Euclidean distance judgment method, and construct an adjacent edge set; and further configured to perform a merging operation on the adjacent edges in the adjacent edge set and perform path compression by using a union-find set structure, to obtain a plurality of connected areas of the point cloud.
[0205] The method for calculating the maximum connected distance threshold of all effective points of the point cloud, the determination method of the bounding box, and the calculation method of the grid index have been clearly described in Embodiment One, and thus will not be described again in this embodiment.
[0206] Specifically, the mapping module 30 is specifically configured to:
[0207] Through the double-pass scanning, the grid index of all voxels contained in each voxel grid of the regular grid is obtained;
[0208] A predetermined hash function is used to establish a voxel hash table, wherein the predetermined hash function is:
[0209] hash(v) = x * a ^ y * b ^ z * c, hash(v) is a hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b, and c in the function are co-prime prime numbers.
[0210] Specifically, the communication area operation module 40 is specifically configured to:
[0211] For each effective point in the point cloud P , its adjacent voxels in the regular grid are enumerated respectively; which is implemented as: for each effective point , the voxel coordinates corresponding to the effective point are , 26 adjacent voxels are enumerated, and the coordinates of the adjacent voxels are denoted as , .
[0212] Let the effective point corresponding to the adjacent voxel be ;
[0213] Each is traversed, and the Euclidean distance between and is calculated and it is judged whether the following relationship is satisfied:
[0214]
[0215] If yes, the edge pair (i, j) composed of and is inserted into the adjacent edge set E;
[0216] If no, it is determined that and Cannot form an edge pair.
[0217] Specifically, the connected region operation module 40 is further configured to:
[0218] Initialize the union-find set structure UF, perform the merging operation and path compression for each edge pair (i, j) E, and obtain a plurality of connected regions;
[0219] Mark 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.
[0220] Specifically, the connected region operation module 40 is further configured to:
[0221] According to the pre-set minimum effective region size threshold, the small clusters in the plurality of connected regions that are smaller than the minimum effective region size threshold are screened out, and the valid connected regions are output.
[0222] The point cloud connectivity segmentation system based on voxel hashing and union-find set provided in the embodiment can realize fast spatial positioning through a regular voxel grid, and can realize fast connectivity merging by using the union-find set structure, so that the segmentation efficiency of a million-level or more scale point cloud can be significantly improved. The system can be widely applied to scenes such as three-dimensional reconstruction, industrial detection, and automatic driving environment perception.
[0223] Embodiment three:
[0224] The embodiment 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 according to the embodiment one.
[0225] Since the point cloud connectivity segmentation method based on voxel hashing and union-find set has been described in detail in the embodiment one, the description will not be repeated in the embodiment.
[0226] Embodiment four:
[0227] The application further provides a computer program product, which comprises a computer program / instruction. When the computer program / instruction is executed by a processor, a point cloud connectivity segmentation method based on voxel hashing and union-find set according to the embodiment one is implemented.
[0228] Since the point cloud connectivity segmentation method based on voxel hashing and union-find set has been described in detail in the embodiment one, the description will not be repeated in the embodiment.
[0229] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or by program instructing relevant 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, etc. Based on such understanding, the technical solutions of the present application, or the entire or part of the technical solutions which essentially contribute to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0230] The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them. Although the present 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 replacements for part of the technical features. Such 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 present application.
Claims
1. A method for point cloud connectivity segmentation based on voxel hashing and union-find set, characterized in that, The method comprises the following steps: calculating a maximum connected distance threshold of all valid points of the point cloud; 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 each voxel corresponding to each valid point respectively; constructing a hash mapping from voxels to valid points through double-pass scanning; determining the adjacent edges of the point cloud based on the hash mapping and using the Euclidean distance judgment method to construct an adjacent edge set; performing a merging operation on the adjacent edges in the adjacent edge set and performing path compression using a union-find set structure to obtain a plurality of connected regions of the point cloud; wherein the method of determining the adjacent edges of the point cloud based on the hash mapping and using the Euclidean distance judgment method to construct an adjacent edge set comprises: For each valid point in the point cloud P , enumerate its neighboring voxels in the regular grid respectively; and record the valid point corresponding to the neighboring voxels as ; traverse each , calculate and euclidean distance between and determine whether to meet the following relationship: ; If so, then and composing the edge pair (i, j) and inserting it into the set of adjacent edges E; If not, then determine and cannot form an edge pair; the method of performing a merging operation on the adjacent edges in the adjacent edge set and performing path compression using a union-find set structure to obtain a plurality of connected regions of the point cloud comprises: initializing the union-find set structure UF, performing a merging operation on each edge (i, j) E and performing path compression to obtain a plurality of connected regions; labeling each 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.
2. The method of claim 1, wherein, The method of 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 recording them as sampling points; querying the nearest k neighborhood points of each sampling point through a pre-constructed kd-tree; counting 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 points ; The maximum connectivity distance threshold is set to ; wherein .
3. The method of claim 2, wherein, The method of determining a bounding box according to the coordinates of all valid points of the point cloud in a three-dimensional space comprises: letting the point cloud be P and the coordinates of the point cloud P in a three-dimensional space be expressed as: where N is the number of valid points in the point cloud; then the bounding box is: wherein , are minimum and maximum values, respectively , , are minimum and maximum values, respectively , , are minimum and maximum values, respectively .
4. The method of claim 3, wherein, The method of calculating the grid index of each voxel corresponding to each valid point comprises: For each valid point of the point cloud P , its corresponding voxel coordinates are calculated , the method is: ; Transform the voxel coordinates restricted to a range, and further transform to get the one-dimensional array of lattice indices: , , , respectively. , the voxel grid size , the number of voxel grids of the regular grid is .
5. The method of claim 4, wherein, The method of constructing a hash mapping from voxels to valid points through double-pass scanning comprises: obtaining all voxel grid indexes contained in each voxel grid of the regular grid through double-pass scanning; establishing a voxel hash table using a predetermined hash function; the predetermined hash function is: hash(v) = x * a ^ y * b ^ z * c, hash(v) is a hash index calculated based on the voxel coordinates (x, y, z), and the three constants a, b and c in the function are co-prime prime numbers.
6. The method of claim 1, wherein, After the merging operation on the adjacent edges in the adjacent edge set and the path compression using the union-find set structure to obtain a plurality of connected regions of the point cloud, the method further comprises: screening out small clusters with a size smaller than a predetermined minimum effective region size threshold from the plurality of connected regions and outputting effective connected regions according to the minimum effective region size threshold.
7. The method of claim 5, wherein, a is 73856093, b is 19349663, and c is 83492791.
8. The method of claim 1, wherein, Said for each valid point in the point cloud P , respectively, enumerate its adjacent voxel in the regular grid, specifically: For each valid point whose corresponding voxel coordinate is enumerate its 26 neighboring voxels, whose coordinates are denoted as , .
9. A system for point cloud connectivity segmentation based on voxel hashing and union-find set, the system comprising: The method comprises the following steps: calculating a maximum connected distance threshold of all valid points of the point cloud by a point cloud data processing module; and a bounding box determined according to coordinates of all valid points of the point cloud in a 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 a voxel grid size, to generate a regular grid; wherein the voxel grid size is defined as the maximum connected distance threshold; the network reconstruction module is further configured to calculate a grid index of a voxel corresponding to each valid point, respectively; a mapping module electrically connected to the network reconstruction module, configured to construct a hash mapping of voxels to valid points by double-pass scanning; a connected region operation module electrically connected to the mapping module, configured to determine adjacent edges of the point cloud by using a Euclidean distance judgment method based on the hash mapping, to 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 regions of the point cloud; the connected region operation module is specifically configured to: For each valid point in the point cloud P , enumerate its neighboring voxels in the regular grid respectively; and record the valid point corresponding to the neighboring voxels as ; traverse each , calculate and euclidean distance between and determine whether to meet the following relationship: ; If so, then and composing the edge pair (i, j) and inserting it into the set of adjacent edges E; If not, then determine and cannot form an edge pair; the connected region operation module is further specifically configured to: initialize the union-find set structure UF, perform a merging operation on each edge pair (i, j) E and perform path compression, to obtain a plurality of connected regions; label a 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.
10. The system of claim 9, wherein, 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 K valid points as sampling points; querying the nearest k neighborhood points of each sampling point by using a pre-constructed kd-tree; counting the Euclidean distances between all sampling points and their neighborhood points, and calculating the average value of all Euclidean distances, according to the formula: ; wherein, is the Euclidean distance between the sampling point and its neighborhood points ; The maximum connectivity distance threshold is set to ; wherein, .
11. The system of claim 10, wherein, 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: denoting the point cloud as P, and denoting the coordinates of the point cloud P in the three-dimensional space as: where N is the number of valid points in the point cloud; then the bounding box is: wherein , are minimum and maximum values, respectively , , are minimum and maximum values, respectively , , are minimum and maximum values, respectively .
12. The system of claim 11, wherein, the method for calculating the grid index of the voxel corresponding to each valid point comprises: For each valid point of the point cloud P , its corresponding voxel coordinates are calculated , the method is: ; Transform the voxel coordinates restricted to a range, and further transform to get the one-dimensional array of lattice indices: , , , respectively: , the voxel grid size , the voxel grid number of the regular grid is .
13. The system of claim 12, wherein, the mapping module is specifically configured to: obtain all grid indexes of voxels contained in each voxel grid of the regular grid by double-pass scanning; establish a voxel hash table by 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.
14. The system of claim 9, wherein, the connected region operation module is further specifically configured to: filter out small clusters with a size less than a pre-set minimum effective region size threshold from the plurality of connected regions, and output valid connected regions.
15. The system of claim 13, wherein, a is 73856093, b is 19349663, and c is 83492791.
16. The system of claim 9, wherein, Said for each valid point in the point cloud P , respectively, enumerate its adjacent voxel in the regular grid, specifically: For each valid point whose corresponding voxel coordinate is enumerate its 26 neighboring voxels, whose coordinates are denoted as , .
17. A computer-readable storage medium, having stored therein at least one instruction, the medium comprising: The instructions are loaded and executed by the processor to implement the point cloud connectivity segmentation method based on voxel hashing and union-find set as claimed in any one of claims 1-8.
18. A computer program product comprising computer programs / instructions, characterized in that, When the computer program / instructions are executed by the processor, the point cloud connectivity segmentation method based on voxel hashing and union-find set as claimed in any one of claims 1-8 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