Laser point cloud background difference method and system
By performing Morton coding and reordering on point clouds, the problem of low efficiency in background difference analysis of LiDAR point clouds is solved, achieving efficient background difference processing and storage optimization, which is suitable for embedded devices.
Patent Information
- Application Number
- CN202511454578.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-10-13
AI Technical Summary
In existing technologies, the background subtraction method for LiDAR point clouds suffers from low efficiency and high storage overhead, especially on embedded devices, which limits the real-time performance of the algorithm.
By reordering the point cloud after performing Morton encoding, spatially adjacent points in the point cloud are also as adjacent as possible in memory, reducing the time for subsequent neighbor point lookup and background difference. The sorting and difference processing are performed using grid partitioning and Morton index calculation, combined with parallel computing devices.
It improves the efficiency of nearest neighbor search, enhances the accuracy and speed of background subtraction, reduces storage overhead, and is suitable for embedded devices.
Smart Images

Figure CN120931691B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of point cloud processing, in particular to a laser point cloud background difference method and system. BACKGROUND
[0002] The laser point cloud background difference technology constructs a reference point cloud of a static scene, compares current frame data in real time, and removes fixed environmental point clouds, so as to retain dynamic targets or new objects. The background difference can filter a large amount of redundant data, greatly improves the processing efficiency of subsequent clustering and other links, and helps to reduce the interference of noise on target recognition, which is of great significance for perimeter intrusion detection. However, the laser radar can generate hundreds of thousands of points per second, and the large-scale input data will seriously affect the real-time performance of the algorithm.
[0003] At present, the industry usually uses KDTree data structure for background difference. This method has double delay, that is, the tree structure construction and the near neighbor search both need to consume a lot of time. In addition, KDTree needs to pre-store a large amount of space structure information for acceleration search, and the storage overhead is several times that of the original point cloud. For embedded devices, it may crash due to insufficient memory.
[0004] At present, there is no effective solution to the above problems in the prior art. SUMMARY
[0005] To solve the above problems, the present application provides a laser point cloud background difference method and system. The points in the point cloud are reordered after Morden coding, so that the spatial adjacent points in the point cloud are also adjacent in memory as much as possible, reducing the subsequent neighbor point search time and background difference time, to solve the problem of low background difference efficiency in the prior art.
[0006] To achieve the above purpose, the present application provides a laser point cloud background difference method, comprising: acquiring a current frame point cloud; preprocessing the current frame point cloud according to scene prior information to obtain a processed point cloud; dividing the processed point cloud into grids according to a preset grid length, and calculating the grid coordinates of each point in the processed point cloud; wherein the preset grid length is a preset search radius; calculating the first index value of each point according to the grid coordinates according to a preset rule; sorting all points in the processed point cloud according to the first index value to obtain a first sorted point cloud; traversing each point in the first sorted point cloud, searching for adjacent points in the second sorted point cloud according to the preset search radius, and determining background points according to the number of adjacent points; wherein the second sorted point cloud is a sorted point cloud obtained in advance according to a background point cloud, and the steps of obtaining the second sorted point cloud according to the background point cloud are consistent with the steps of obtaining the first sorted point cloud according to the current frame point cloud.
[0007] Further optionally, the Morton index calculation according to the grid coordinates and according to the preset rule to obtain the first index value corresponding to each point comprises: for any point in the point cloud, according to the preset rule, performing a shift on the x coordinate in the grid coordinates to which the point belongs, performing a bitwise OR operation on the shifted coordinate and the unshifted coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain an x direction index value; according to the preset rule, performing a shift on the y coordinate in the grid coordinates to which the point belongs, performing a bitwise OR operation on the shifted coordinate and the unshifted coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a y direction index value; according to the preset rule, performing a shift on the z coordinate in the grid coordinates to which the point belongs, performing a bitwise OR operation on the shifted coordinate and the unshifted coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a z direction index value; and performing a combination of a shift and a bitwise OR operation according to the x direction index value, the y direction index value and the z direction index value to obtain the first index value of the point.
[0008] Further optionally, the sorting of all points in the point cloud according to the first index value to obtain the first sorted point cloud comprises: combining the first index value corresponding to each point and the original serial number thereof to form an index pair, and arranging the index pairs in ascending order of the original serial number to obtain sorting input data; dividing the sorting input data into a plurality of data segments, and assigning each data segment to a computing core for processing; dividing each data segment into a plurality of slices, and sequentially executing a move-in task, a sorting task and a move-out task for each slice; wherein different tasks in different slices are processed in parallel; merging the sorting results of the slices to obtain a data segment sorting result, and then merging the data segment sorting results to obtain the first sorted point cloud.
[0009] Further optionally, the traversing each point in the first ordered point cloud, searching for a neighboring point in the second ordered point cloud according to the preset search radius, and determining a background point according to the number of neighboring points comprises: performing hierarchical division on each point in the first ordered point cloud and the second ordered point cloud according to the difference in the number of last bits of the index values; for a current point in the first ordered point cloud, finding a point in the second ordered point cloud whose second index value is closest to the first index value of the current point, and taking the point as a starting point for searching; judging whether the grid corresponding to the current point is a boundary grid of a current layer from low to high, and if so, performing boundary grid judgment of a higher layer; otherwise, recording the current layer as a target layer; when the target layer is less than a preset number of layers, sequentially searching for the number of neighboring points in the positive direction and the negative direction of the second ordered point cloud from the starting point for searching, and if the number of neighboring points reaches a preset number threshold, determining that the current point is a background point, and if the number of neighboring points does not reach the preset number threshold until the end of searching in the negative direction, determining that the current point is a foreground point; when the grid of the point found and the grid of the current point are not in the same layer, the searching in any direction ends; when the target layer is greater than or equal to the preset number of layers, searching for neighboring points in the positive direction and the negative direction of the second ordered point cloud from the starting point for searching in the eight grids around the grid of the starting point for searching, and counting the total number of neighboring points, and if the total number is greater than the preset number threshold, determining that the current point is a background point; for the remaining points that have not been determined, constructing a KDTree for all points in the adjacent grids of the grid of the starting point for searching and performing radius search on the remaining points, and when the number of neighboring points searched is greater than or equal to the preset number threshold, determining that the remaining point is a background point, otherwise, a foreground point.
[0010] Further optionally, the preprocessing the current frame point cloud according to scene prior information to obtain a processed point cloud comprises: performing straight-through filtering on the current frame point cloud according to the range of the defense area; performing ground fitting, and removing points below the ground in the current frame point cloud according to the fitting result.
[0011] In another aspect, the present application also provides a laser point cloud background difference system, comprising: a preprocessing module configured to obtain a current frame point cloud; pre-process the current frame point cloud according to scene prior information to obtain a processed point cloud; a grid division module configured to divide the processed point cloud into grids according to a preset grid length, and calculate the grid coordinates of each point in the processed point cloud; wherein the preset grid length is a preset search radius; an index calculation module configured to calculate a first index value of each point according to the grid coordinates according to a preset rule; an ordering module configured to order all points in the processed point cloud according to the first index value to obtain a first ordered point cloud; and a difference module configured to search for neighboring points in a second ordered point cloud according to the preset search radius, and determine background points according to the number of neighboring points; wherein the second ordered point cloud is an ordered point cloud obtained in advance according to a background point cloud, and the steps of obtaining the second ordered point cloud according to the background point cloud are consistent with the steps of obtaining the first ordered point cloud according to the current frame point cloud.
[0012] Further optionally, the index calculation comprises: a first index value calculation submodule configured to, for any point in the processed point cloud, shift the x coordinate in the grid coordinates to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain an x direction index value; a second index value calculation submodule configured to, for any point in the processed point cloud, shift the y coordinate in the grid coordinates to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a y direction index value; a third index value calculation submodule configured to, for any point in the processed point cloud, shift the z coordinate in the grid coordinates to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a z direction index value; and an index combination submodule configured to combine the x direction index value, the y direction index value and the z direction index value by shifting and bitwise OR to obtain the first index value of the point.
[0013] Further optionally, the sorting module comprises: an index pair calculation submodule, configured to form an index pair by combining a first index value corresponding to each point with an original serial number of the point, and arrange the index pairs in ascending order of the original serial numbers to obtain sorting input data; a data distribution submodule, configured to divide the sorting input data into a plurality of data segments, and assign each data segment to a computing core for processing; a slice sorting submodule, configured to divide each data segment into a plurality of slices, and sequentially execute a moving-in task, a sorting task and a moving-out task on each slice; wherein different tasks of different slices are processed in parallel; and a merging submodule, configured to merge sorting results of the slices to obtain a data segment sorting result, and further merge the data segment sorting results to obtain a first sorted point cloud.
[0014] Further optionally, the difference module comprises: a grid layering submodule, configured to divide each grid corresponding to a point in the first sorted point cloud and the second sorted point cloud into layers according to differences in the number of last digits of the index values; a starting point determination submodule, configured to, for a current point in the first sorted point cloud, find a point in the second sorted point cloud whose second index value is closest to the first index value of the current point, and take the point as a starting point of searching; a target layer determination submodule, configured to judge whether the grid corresponding to the current point is a boundary grid of a current layer from low to high layer by layer, if yes, perform a boundary grid judgment of a higher layer, and if not, record the current layer as a target layer; a first determination submodule, configured to, when the target layer is smaller than a preset number of layers, sequentially search for a number of adjacent points in a positive direction and a negative direction of the second sorted point cloud from the starting point of searching, and if the number of adjacent points reaches a preset number threshold, determine that the current point is a background point, and if the number of adjacent points does not reach the preset number threshold until the end of searching in the negative direction, determine that the current point is a foreground point; wherein the searching in either direction ends when the grid of the searching point and the grid of the current point are not in the same layer; a second determination submodule, configured to, when the target layer is greater than or equal to the preset number of layers, search for adjacent points in the positive direction and the negative direction of the second sorted point cloud from the starting point of searching in the eight grids around the grid corresponding to the starting point of searching, and count a total number of the adjacent points, and if the total number is greater than the preset number threshold, determine that the current point is a background point; and a third determination submodule, configured to, for remaining points that have not been determined, construct a KDTree for all points in adjacent grids of the grid corresponding to the starting point of searching, and perform a radius search on the remaining points, and when a number of adjacent points searched is greater than or equal to the preset number threshold, determine that the remaining point is a background point, and otherwise, a foreground point.
[0015] Further optionally, the preprocessing module comprises: a first redundant point removal submodule, configured to perform a straight-through filtering on the current frame point cloud according to a guard range; and a second redundant point removal submodule, configured to perform ground fitting, and remove points below the ground in the current frame point cloud according to a fitting result.
[0016] The technical scheme has the following beneficial effects: by performing grid division and Morden index calculation on the point cloud, and re-allocating memory of the point cloud according to the index sorting, the spatial adjacent points in the point cloud are also adjacent in the sorting sequence, the searching efficiency of the adjacent points is improved, and the background difference accuracy and speed are further improved. BRIEF DESCRIPTION OF DRAWINGS
[0017] 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 the prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.
[0018] Figure 1 is a flow chart of the laser point cloud background difference method provided by the embodiment of the present application;
[0019] Figure 2 is a flow chart of the Morden index calculation method provided by the embodiment of the present application;
[0020] Figure 3 is a flow chart of the point cloud sorting method provided by the embodiment of the present application;
[0021] Figure 4 is a flow chart of the background point segmentation method provided by the embodiment of the present application;
[0022] Figure 5 is a flow chart of the point cloud preprocessing method provided by the embodiment of the present application;
[0023] Figure 6 is a structural schematic diagram of the laser point cloud background difference system provided by the embodiment of the present application;
[0024] Figure 7 is a structural schematic diagram of the index calculation module provided by the embodiment of the present application;
[0025] Figure 8 is a structural schematic diagram of the sorting module provided by the embodiment of the present application;
[0026] Figure 9 is a structural schematic diagram of the difference module provided by the embodiment of the present application;
[0027] Figure 10 is a structural schematic diagram of the preprocessing module provided by the embodiment of the present application.
[0028] Reference numerals: 100-Preprocessing module; 1001-First redundant point removal submodule; 1002-Second redundant point removal submodule; 200-Raster partitioning module; 300-Index calculation module; 3001-First index value calculation submodule; 3002-Second index value calculation submodule; 3003-Third index value calculation submodule; 3004-Index combination submodule; 400-Sorting module; 4001-Index pair calculation submodule; 4002-Data allocation submodule; 4003-Slice sorting submodule; 4004-Merge submodule; 500-Differential module; 5001-Raster layering submodule; 5002-Search starting point determination submodule; 5003-Target layer determination submodule; 5004-First decision submodule; 5005-Second decision submodule; 5006-Third decision submodule. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] To address the low efficiency of background subtraction in target recognition processes in existing technologies, this invention provides a laser point cloud background subtraction method. Figure 1 This is a flowchart of the laser point cloud background subtraction method provided in the embodiments of the present invention, such as... Figure 1 As shown, it includes:
[0031] S1. Obtain the point cloud of the current frame; preprocess the point cloud of the current frame based on the prior information of the scene to obtain the processed point cloud.
[0032] The current frame point cloud refers to the raw 3D spatial point cloud data acquired at the current moment through LiDAR or other 3D sensing devices. This point cloud data typically includes a large number of 3D coordinate points. These 3D coordinate points include background points (static environment structures) and foreground points (dynamic targets).
[0033] To improve the efficiency and accuracy of subsequent point cloud processing, the current frame's point cloud needs to be preprocessed using prior scene information to remove redundant data and obtain the processed point cloud. Prior information about the scene may include, but is not limited to: the installation height and angle of the lidar, the spatial boundaries of the monitored area, and ground feature models.
[0034] S2. Divide the processed point cloud into grids according to the preset grid side length, and calculate the grid coordinates of each point in the processed point cloud corresponding to the grid; wherein, the preset grid side length is the preset search radius.
[0035] Edge length of the set grid Search radius for adjacent points For processing the point cloud Each point with coordinates , , , the grid coordinates of the grid where it is located are calculated as follows:
[0036] ;
[0037] Where, represents the floor function.
[0038] S3, according to the grid coordinates, a Minton index is calculated according to a preset rule to obtain a first index value corresponding to each point.
[0039] For each grid coordinate of a point obtained by grid division , a one-dimensional processing is performed on the three-dimensional grid coordinates according to a preset rule to obtain a first index value for sorting.
[0040] Specifically, the preset rule is: the integer values of the grid coordinates in three directions are represented in binary respectively, and are combined by bit interleaving, so that the bits in X, Y and Z directions are arranged in turn, thereby forming an encoding value corresponding to the three-dimensional grid position, i.e. Minton index. In this way, the point cloud position originally distributed in three-dimensional space can be mapped to a monotonically increasing one-dimensional value, ensuring that the indices with similar values correspond to points adjacent in space.
[0041] S4, according to the first index value, all points in the processing point cloud are sorted to obtain a first sorted point cloud.
[0042] Taking the first index value calculated for each point as the basis for sorting, the global sorting operation of ascending or descending is performed on all points in the processing point cloud. The sorted point cloud has continuity in data sequence consistent with the spatial position. Through this sorting process, points adjacent in space can also be adjacent in storage structure, thereby reducing random access overhead in subsequent adjacent point search and hierarchical division, improving cache hit rate and overall processing efficiency of data access.
[0043] The sorting can be sequentially executed on a general-purpose processor, or can be accelerated by using a parallel sorting algorithm on a parallel computing device (such as GPU, NPU).
[0044] S5, traverse each point in the first ordered point cloud, search for adjacent points in the second ordered point cloud within a preset search radius, and determine the background point according to the number of adjacent points; wherein the second ordered point cloud is an ordered point cloud obtained in advance according to the background point cloud, and the step of obtaining the second ordered point cloud according to the background point cloud is consistent with the step of obtaining the first ordered point cloud according to the current frame point cloud.
[0045] The background point cloud refers to a set of static points that stably exist in a scene after multiple frames of statistics or scene modeling in a laser point cloud sequence. These points usually correspond to fixed objects or structures in the scene, such as the ground, walls, buildings, fixed facilities, etc., and their positions in multiple frames of point cloud data collected at different times do not change substantially. The role of the background point cloud is to serve as reference data in subsequent background difference processing, and to compare with the current frame point cloud to distinguish newly appearing, moving or disappearing points (i.e. foreground points) for target detection, dynamic object segmentation, etc.
[0046] The background point cloud also needs to undergo the same preprocessing, grid division, Morton coding and ordering operations as the current frame point cloud to obtain a second ordered point cloud, which includes a second index value of each point corresponding to a grid.
[0047] Each point in the first ordered point cloud is traversed. For the current traversal point, an adjacent point search operation is performed in the second ordered point cloud. When performing the adjacent point search, the corresponding point of the current traversal point in the second ordered point cloud is taken as the center, a preset search radius is set, and all points in the second ordered point cloud with a spatial distance from the point not greater than the search radius are found. These points are the adjacent points of the current point. The number of these adjacent points is counted and compared with a preset number threshold When the number of adjacent points is greater than or equal to the preset number threshold , the current point is determined to be a background point.
[0048] Through this adjacent point search based on ordered point cloud, the consistency of the first ordered point cloud and the second ordered point cloud in spatial arrangement can be utilized to quickly locate and retrieve the potential adjacent point set, reduce unnecessary distance calculation, and improve the efficiency and accuracy of background point determination.
[0049] As an optional implementation, Figure 2 is a flowchart of the Morton index calculation method provided by the embodiment of the application, as shown in Figure 2 , the Morton index calculation is performed according to the grid coordinates according to a preset rule to obtain a first index value corresponding to each point, including:
[0050] S301, for a point in the point cloud, according to a preset rule, the x coordinate of the grid coordinate to which the point belongs is shifted, the shifted coordinate and the coordinate before shifting are operated by bit or, and the coordinate after bit or operation and the mask are operated by bit and, to obtain an index value in the x direction.
[0051] S302, according to a preset rule, the y coordinate of the grid coordinate to which the point belongs is shifted, the shifted coordinate and the coordinate before shifting are operated by bit or, and the coordinate after bit or operation and the mask are operated by bit and, to obtain an index value in the y direction.
[0052] S303, according to a preset rule, the z coordinate of the grid coordinate to which the point belongs is shifted, the shifted coordinate and the coordinate before shifting are operated by bit or, and the coordinate after bit or operation and the mask are operated by bit and, to obtain an index value in the z direction.
[0053] According to the calculation result of the grid coordinate, the index is synthesized by fusing the information of X, Y and Z directions for sorting. The traditional index formula is as follows, wherein and are the total number of grids in the X axis and the Y axis respectively:
[0054]
[0055] The index calculated by the traditional method will make the points adjacent in space far apart in memory after sorting, which is not conducive to subsequent neighbor point retrieval. The fusion method in the embodiment can make the calculated index grow in a zigzag shape in three-dimensional space, so that the indexes of adjacent points are as close as possible.
[0056] For each point in the point cloud, the x coordinate, y coordinate and z coordinate of the grid where the point is located are all operated according to a preset rule. Taking the x coordinate as an example to explain the preset rule, first, the x coordinate is shifted to obtain the shifted coordinate, the shifted coordinate and the coordinate before shifting are operated by bit or, and the calculation result is operated by bit and with the mask to obtain a new coordinate value. The new coordinate value is still input for the next round of operation, and the x direction index value is obtained after multiple rounds of operation.
[0057] Specifically, assuming that the storage mode on the computer is 32 bits, taking the grid x coordinate as an example, the Morton coding rule of the embodiment is as follows:
[0058] (1) Shift left 16 bits to record as ; , and , and the result is operated by bit or, and the result is operated by bit and with 50331903, and the result is recorded as ;
[0059] (2) left shift 8 bits of is recorded as , and then and are operated by bitwise OR, and the result is operated by bitwise AND with 50393103, and the result is recorded as ;
[0060] (3) left shift 4 bits of is recorded as , and then and are operated by bitwise OR, and the result is operated by bitwise AND with 51130563, and the result is recorded as ;
[0061] (4) left shift 2 bits of is recorded as , and then and are operated by bitwise OR, and the result is operated by bitwise AND with 153391689, and the result is recorded as , , which is the x-direction index value.
[0062] After the same encoding operation is performed on the y coordinate and the z coordinate of the grid, the y-direction index value and the z-direction index value are obtained, respectively.
[0063] S304, according to the x-direction index value, the y-direction index value and the z-direction index value, the combination of shifting and bitwise OR is performed to obtain the first index value of the point.
[0064] The x-direction index value , the y-direction index value and the z-direction index value obtained above are fused, and the specific fusion manner is as follows:
[0065] ;
[0066] wherein represents a bitwise OR operation, represents a left shift.
[0067] Through the above manner, the first index value corresponding to each point in the point cloud can be obtained.
[0068] As an optional implementation manner, Figure 3 is a flowchart of the point cloud sorting method provided by the embodiment of the application, as shown in Figure 3As shown, all points in the point cloud are sorted according to the first index value to obtain a first sorted point cloud, including:
[0069] S401, the first index value corresponding to each point and its original serial number form an index pair, and the original serial number is arranged in ascending order to obtain sorted input data.
[0070] For the processed point cloud, the first index value and the corresponding serial number are preprocessed before sorting, that is, they are taken as a pair, denoted as , and arranged in ascending order to form the sorting input data of the NPU ; then the input data is copied to the NPU device denoted as . Wherein, the serial number i is the original serial number of each point in the current frame point cloud.
[0071] Parallel computing devices can be selected according to needs, such as NVIDIA's GPU and Huawei Ascend's NPU. In this embodiment, the Ascend NPU device is selected to accelerate the point cloud sorting process.
[0072] S402, the sorting input data is divided into multiple data segments, and each data segment is allocated to a computing core for processing.
[0073] Assuming that the NPU device has cores, the sorting input data can be divided into data segments, each segment has data, and the last segment is filled with insufficient data.
[0074] S403, each data segment is divided into multiple slices, and each slice is sequentially executed to move in, sort and move out; wherein different tasks in different slices are processed in parallel.
[0075] The n data on each data segment is sliced, assuming that the maximum data that can be sorted at a time is , then the total data n is divided by the single processing data , when the remaining data is less than the single processing amount, it is processed as a slice, thereby obtaining the total number of slices of the data segment .
[0076] Each slice needs to sequentially execute the move-in task (moving data from to the computing unit), the sorting operation and the move-out task (moving the sorted result from the computing unit back to ). For the same slice, the moving-in, sorting and moving-out operations are processed in series, while different slices can have multiple tasks processed in parallel at the same time point.
[0077] The parallel processing flow among different slices is shown in the following examples:
[0078] At time ①, slice a performs the moving-in task to move data from to the computing unit.
[0079] At time ②, slice a performs the sorting task to perform the sorting operation; at the same time, slice b performs the moving-in task.
[0080] At time ③, slice a performs the moving-out task to move the sorted results from the computing unit back to ; slice b performs the sorting task; and slice c performs the moving-in task.
[0081] At time ④, slice b performs the moving-out task; slice c performs the sorting task; and slice d performs the moving-in task.
[0082] At time ⑤, slice c performs the moving-out task; slice d performs the sorting task; and slice e performs the moving-in task.
[0083] At time ⑥, and so on.
[0084] S404, merge the sorting results of each slice to obtain a data segment sorting result, and then merge each data segment sorting result to obtain a first sorting point cloud.
[0085] After the slice sorting of the data segment is completed, the merge sorting in the data segment is performed to synthesize the ordered data: after the above pipelining processing, the segment ordered data is formed, and the segment ordered data is merged and sorted two by two to form the ( segment ordered data. By analogy, when , continue to perform two-by-two merging until only one segment of ordered data is left. The data of different data segments is also merged, and the point cloud memory of the sorted point cloud is re-allocated, so that the points adjacent in space are also adjacent in memory, to obtain a first sorting point cloud .
[0086] As an optional implementation, Figure 4 is the flowchart of the background point segmentation method provided by the embodiment of the application, as shown in Figure 4 , each point in the first sorting point cloud is traversed, and adjacent points are searched in a second sorting point cloud according to a preset search radius, and the background points are determined according to the number of adjacent points, including:
[0087] S501, according to the difference of the last bit number of the index value, the first sorting point cloud and the second sorting point cloud are respectively divided into hierarchical grids.
[0088] The background point cloud and the current frame point cloud are sequentially arranged to obtain the second sorting point cloud and the first sorting point cloud . Before finding the adjacent points, the following definitions are made: first, the points with the same index value are in the same grid, i.e. in the 0th layer; the points with the same index value after the last 3 bits are different are in the 1st layer, and there are 8 grids; the points with the same index value after the last 6 bits are different are in the 2nd layer, and there are 64 grids; and so on. According to the definition, the total number of leaf grids in the nth layer is , and the number of leaf grids inside the layer (not on the boundary in X, Y and Z directions) is .
[0089] S502, for the current point in the first sorting point cloud, find the point in the second sorting point cloud with the second index value closest to the first index value of the current point, and take the point as the starting point of the search.
[0090] Traverse the points in the first sorting point cloud , and set the point currently traversed in the first sorting point cloud as the current point , and the first index value of the current point is . Since the indexes of the second sorting point cloud and the first sorting point cloud are ordered, as long as the search is performed in order in the second sorting point cloud , the point with the first index value closest to the current point can be found, and the point found in the second sorting point cloud is recorded as the starting point of the search , and the sequence number of the starting point in the second sorting point cloud is . The Morden index corresponding to each point in the second sorting point cloud is the second index value, and the sequence number of each point in the second sorting point cloud is obtained by numbering each point in the second sorting point cloud in the order after sorting.
[0091] S503, from low to high, layer by layer, determine whether the grid corresponding to the current point is the boundary grid of the current layer, if yes, perform the boundary grid judgment of the next layer; otherwise, record the current layer as the target layer.
[0092] Calculate the minimum number of layers in which the grid where the current point is not in the boundary. Specifically, from the 2nd layer, judge whether the current point whether the current point is a boundary point of the layer, if it is a boundary point, continue to search the third layer, if it is a non-boundary point, stop calculation, and record the current layer where the current point is as a target layer . .
[0093] S504, when the target layer is less than the preset number of layers, from the search starting point, sequentially search the number of adjacent points in the positive direction and the negative direction of the second sorted point cloud, if the number of adjacent points reaches the preset number threshold, it is determined that the current point is a background point, if the number of adjacent points does not reach the preset number threshold until the negative direction search is completed, it is determined that the current point is a foreground point; wherein when the grid where the search point and the current point are not in the same layer, any direction search is completed.
[0094] The target layer is greater, which means that the current point needs to traverse more grids to find all potential adjacent points, therefore, in order to make the search efficiency higher, when the target layer is less than the preset number of layers (previously set comparison threshold, preferably 6 or 7 layers), the following operations are performed:
[0095] from the sequence number of the search starting point, first search in the positive direction of the second sorted point cloud , the second index value of the current search point is recorded as , and the following conditions are judged , wherein represents right shift:
[0096]
[0097] a. if the condition is met, it means that the current point and the search point are in the same layer, continue to calculate the distance between the search point and the current point :
[0098] when , the current point finds an adjacent point in the second sorted point cloud , and one is added;
[0099] when , continue to search the next point ; wherein is the preset search radius.
[0100] b. If the condition is not satisfied, the search point is found It is impossible to be a neighboring point of the search point, and since the second index value of the second ordered point cloud is ordered, it is also impossible to be a neighboring point of the search point, and the search is terminated.
[0101] A preset number threshold is set If the search process satisfies , the current point is considered to satisfy the requirement of the background point, and if the forward search is completed, < , the search is performed in the negative direction of the sequence number of the search starting point, and the second index value of the found search point is recorded as , and it is determined whether the following condition is satisfied:
[0102]
[0103] When the condition is satisfied, step a is performed, and the accumulation of is continued; if the condition is not satisfied, step b is performed, and if the search process satisfies , the current point is considered to be a background point, and otherwise, if exceeds the same layer, is still less than , the current point is determined to be a foreground point.
[0104] S505, when the target layer is greater than or equal to the preset number of layers, in the eight surrounding grids of the search starting point corresponding to the grid, the search is performed in the positive and negative directions of the second ordered point cloud with the search starting point as the starting point, the total number of neighboring points is counted, and if the total number is greater than the preset number threshold, the current point is determined to be a background point.
[0105] When the target layer is greater than or equal to the preset number of layers , it is considered that it takes too much time to traverse all points in the same layer grid. According to the characteristics of the Morton index, there are 8 grids whose first three bits are different from the first index value of the current point and the remaining bits are the same. These grids may have neighboring points and are continuous in memory, which is convenient for searching, so only the 8 grids are checked to see if there are neighboring points. The judgment of such grids is as follows:
[0106]
[0107] the sequence number search in the positive and negative directions respectively, and calculate the distance d of these points to the current point , calculate the number of points whose distance d is less than a preset search radius . If , the current point is a background point.
[0108] S506, for the remaining points whose states have not been determined, KDTree is constructed for all points in the adjacent grids of the starting point corresponding grid, and radius search is performed on the remaining points. When the number of adjacent points searched is greater than or equal to a preset number threshold, the remaining point is determined as a background point, otherwise as a foreground point.
[0109] The proportion of the number of internal leaf grids in each layer to the total number of grids is , so when the preset number of layers is set to be large, most of the points searched are determined as background points or foreground points by the above step S504. A part of the remaining points are determined as background points in the above step S505. For the remaining points whose states have not been determined in the above steps S504 and S505, the states of these points need to be determined. These points are all boundary points of the layer, and the coordinates of the grids where these points are located satisfy any one of the following conditions, wherein is the remainder:
[0110] ;
[0111] Therefore, the possible adjacent points of the remaining points only exist in the adjacent grids of the grids satisfying the condition, that is, the grid coordinates satisfy In the second sorted point cloud, KDTree is constructed for the points in these grids, and radius search is performed on the remaining points. When the number of adjacent points in the search result is greater than or equal to , the remaining point is determined as a background point, otherwise as a foreground point.
[0112] Through the above steps, the states of all points in the first sorted point cloud can be determined, that is, the background difference is completed.
[0113] As an optional implementation, Figure 5 is a flowchart of a point cloud preprocessing method provided by an embodiment of the present application, as shown in Figure 5 , the current frame point cloud is preprocessed according to scene prior information to obtain a processed point cloud, including:
[0114] S101, straight-through filtering is performed on the current frame point cloud according to the range of the defense area;
[0115] S102, ground fitting is performed, and points below the ground in the current frame point cloud are removed according to the fitting result.
[0116] First, in combination with the preset defense space range, a straight-through filtering operation is performed on the current frame point cloud, the value range in each coordinate axis direction is limited, and the point cloud data located outside the defense area is removed, so that the data amount of subsequent processing is reduced and the operation efficiency is improved.
[0117] And the ground fitting processing is performed on the current frame point cloud, and an algorithm based on random sample consensus (RANSAC) can be used to construct a ground model conforming to the current scene. After fitting, according to the height reference of the ground model, the point cloud data below the ground is removed to eliminate the interference caused by ground undulation, low obstacles or environmental noise, and to ensure that the remaining point cloud data only includes effective target points within the defense area above the ground.
[0118] Further, to reduce the data processing amount, the current frame point cloud can also be down-sampled.
[0119] After the above pre-processing, the processed point cloud is obtained for subsequent ordering and background point judgment.
[0120] The embodiment of the application also provides a laser point cloud background difference system, Figure 6 is a structural schematic diagram of the laser point cloud background difference system provided by the embodiment of the application, as Figure 6 indicated, the system comprises:
[0121] The preprocessing module 100 is used for acquiring the current frame point cloud; and the current frame point cloud is preprocessed according to scene prior information to obtain a processed point cloud.
[0122] The current frame point cloud refers to the original three-dimensional space point cloud data collected at the current time through a laser radar or other three-dimensional sensing device, and the point cloud data usually includes a large number of three-dimensional coordinate points. These three-dimensional coordinate points include background points (static environmental structures) and foreground points (dynamic targets).
[0123] In order to improve the efficiency and accuracy of subsequent point cloud processing, the current frame point cloud needs to be preprocessed in combination with scene prior information to remove redundant data and obtain a processed point cloud . The scene prior information can include but is not limited to the installation height and angle of the laser radar, the spatial boundary of the monitoring area, the ground feature model, etc.
[0124] The grid division module 200 is used for dividing the processed point cloud according to a preset grid side length, and calculating the grid coordinates of each point in the processed point cloud corresponding to the grid; wherein the preset grid side length is a preset search radius.
[0125] The side length of the grid is the search radius of the adjacent point For each point in the point cloud with coordinates , , , , the grid coordinates of the grid in which it is located are calculated as follows:
[0126] ;
[0127] where denotes the floor function.
[0128] The index calculation module 300 is configured to calculate a first index value corresponding to each point according to the grid coordinates and according to a preset rule.
[0129] For each grid coordinate of each point obtained by dividing the grid , the three-dimensional grid coordinates are processed in one dimension according to a preset rule to obtain a first index value for sorting.
[0130] Specifically, the preset rule is that the integer values of the grid coordinates in the three directions are represented in binary respectively, and are combined by bit interleaving, so that the bits in the X, Y and Z directions are arranged in turn, thereby forming an encoding value corresponding to the three-dimensional grid position, i.e. the Morton index. In this way, the point cloud positions originally distributed in three-dimensional space can be mapped to monotonically increasing one-dimensional values, ensuring that indices that are close in value correspond to points that are adjacent in space.
[0131] The sorting module 400 is configured to sort all points in the point cloud according to the first index value to obtain a first sorted point cloud.
[0132] The first index value calculated for each point is used as the basis for sorting, and all points in the point cloud are subjected to a global sorting operation in ascending or descending order. The sorted point cloud has continuity in the data sequence that is consistent with the spatial position. Through this sorting process, points that are adjacent in space are also adjacent in storage structure, thereby reducing random access overhead in subsequent neighbor point searching and hierarchical division, and improving cache hit rate and overall processing efficiency of data access.
[0133] The sorting can be sequentially executed on a general-purpose processor, or can be accelerated by using a parallel sorting algorithm on a parallel computing device such as a GPU or NPU.
[0134] The difference module 500 is configured to traverse each point in the first ordered point cloud, search for neighboring points in a preset search radius in the second ordered point cloud, and determine a background point according to the number of the neighboring points; wherein the second ordered point cloud is an ordered point cloud obtained in advance according to a background point cloud, and the step of obtaining the second ordered point cloud according to the background point cloud is consistent with the step of obtaining the first ordered point cloud according to the current frame point cloud.
[0135] The background point cloud refers to a set of static points in a laser point cloud sequence, which are stably present in a scene after multi-frame statistics or scene modeling. These points usually correspond to fixed objects or structures in the scene, such as the ground, the wall, the building, the fixed facilities, etc., and the positions of these points in the multi-frame point cloud data collected at different times do not change substantially. The role of the background point cloud is to serve as reference data in subsequent background difference processing, and to be compared with the current frame point cloud, so as to distinguish newly appearing, moving or disappearing points (i.e. foreground points) for target detection, dynamic object segmentation, etc.
[0136] The background point cloud also needs to be preprocessed, rasterized, Morton coded and ordered in the same way as the current frame point cloud, so as to obtain a second ordered point cloud, which includes a second index value of each point corresponding to a grid.
[0137] Each point in the first ordered point cloud is traversed. For the current traversed point, a neighboring point search operation is performed in the second ordered point cloud. In the execution of the neighboring point search, a preset search radius is set with the corresponding point of the current traversed point in the second ordered point cloud as the center, and all points in the second ordered point cloud with a spatial distance not greater than the search radius from the point are searched, which are the neighboring points of the current point. The number of these neighboring points is counted, and compared with a preset number threshold When the number of neighboring points is greater than or equal to the preset number threshold , the current point is determined as a background point.
[0138] Through this neighboring point search based on the ordered point cloud, the consistency of the first ordered point cloud and the second ordered point cloud in spatial arrangement can be utilized to quickly locate and retrieve the potential neighboring point set, reduce unnecessary distance calculation, and improve the efficiency and accuracy of the background point determination.
[0139] As an optional implementation, Figure 7 the structure diagram of the index calculation module is shown in Figure 7 , the index calculation module 300 includes:
[0140] The first index value calculation submodule 3001 is configured to, for any point in the point cloud, shift the x coordinate of the grid coordinate to which the point belongs according to a preset rule, perform a bitwise OR operation on the shifted coordinate and the coordinate before the shift, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain an index value in the x direction.
[0141] The second index value calculation submodule 3002 is configured to, according to a preset rule, shift the y coordinate of the grid coordinate to which the point belongs, perform a bitwise OR operation on the shifted coordinate and the coordinate before the shift, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain an index value in the y direction.
[0142] The third index value calculation submodule 3003 is configured to, according to a preset rule, shift the z coordinate of the grid coordinate to which the point belongs, perform a bitwise OR operation on the shifted coordinate and the coordinate before the shift, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain an index value in the z direction.
[0143] According to the calculation result of the grid coordinate, the index is synthesized by fusing the information in the X, Y and Z directions for sorting. The traditional index formula is as follows, wherein and are the total number of grids in the X axis and the Y axis, respectively:
[0144]
[0145] The index calculated by the traditional method will make the points adjacent in space far apart in memory after sorting, which is not conducive to subsequent neighbor point retrieval. However, the fusion method in the embodiment can make the calculated index grow in a zigzag shape in three-dimensional space, so as to make the indices of adjacent points as close as possible.
[0146] For each point in the point cloud, the x coordinate, the y coordinate and the z coordinate of the grid in which the point is located are all operated according to a preset rule. The preset rule is described by taking the x coordinate as an example. First, the x coordinate is shifted to obtain a shifted coordinate, a bitwise OR operation is performed on the shifted coordinate and the coordinate before the shift, and a bitwise AND operation is performed on the calculation result and a mask to obtain a new coordinate value. The new coordinate value is still input into the next round of operation, and the x direction index value is obtained after multiple rounds of operation.
[0147] Specifically, it is assumed that the storage mode on the computer is 32 bits, and the grid x coordinate is taken as an example, the Morton coding rule of the embodiment is as follows:
[0148] (1) Shift left by 16 bits to record as , and then perform a bitwise AND operation on and Bitwise OR operation is performed on the result and 50331903, and the result is recorded as ;
[0149] (2) Shift left 8 bits of to record as , and perform bitwise OR operation on and , and perform bitwise AND operation on the result and 50393103, and the result is recorded as ;
[0150] (3) Shift left 4 bits of to record as , and perform bitwise OR operation on and , and perform bitwise AND operation on the result and 51130563, and the result is recorded as ;
[0151] (4) Shift left 2 bits of to record as , and perform bitwise OR operation on and , and perform bitwise AND operation on the result and 153391689, and the result is recorded as , which is the x-direction index value.
[0152] After the same encoding operation is performed on the y coordinate and the z coordinate of the grid, the y-direction index value and the z-direction index value are obtained respectively.
[0153] The index combination submodule 3004 is configured to perform shift and bitwise OR combination according to the x-direction index value, the y-direction index value and the z-direction index value, to obtain the first index value of the point.
[0154] The x-direction index value , the y-direction index value and the z-direction index value obtained above are fused, and the specific fusion manner is as follows:
[0155] ;
[0156] Among them, represents a bitwise OR operation, represents a bitwise left shift.
[0157] Through the above manner, the first index value corresponding to each point in the point cloud can be obtained.
[0158] As an optional implementation manner,Figure 8 This is a schematic diagram of the sorting module provided in an embodiment of the present invention, as shown below. Figure 8 As shown, the sorting module 400 includes:
[0159] The index pair calculation submodule 4001 is used to form an index pair with the first index value corresponding to each point and its original sequence number, and arrange them in ascending order according to the original sequence number to obtain sorted input data.
[0160] For the processed point cloud after index calculation, preprocessing is performed before sorting, that is, the first index value... and corresponding serial number As a pair, it is denoted as , and according to The sorted input data that constitutes the NPU is arranged from smallest to largest. Then input data Copying to the NPU device is denoted as Where, index i is the original index of each point in the point cloud of the current frame.
[0161] Parallel computing devices can be selected according to requirements, such as NVIDIA GPUs and Huawei Ascend NPUs. In this embodiment, the Ascend NPU device is selected to accelerate the point cloud sorting process.
[0162] The data allocation submodule 4002 is used to divide the sorted input data into multiple data segments and assign each data segment to a computing core for processing.
[0163] Assuming the NPU device has With one core element, the sorted input data can be divided into... There are several data segments, each containing... The last part of the data is padded with memory to make up any missing data.
[0164] The slice sorting submodule 4003 is used to divide each data segment into multiple slices and execute the import task, sorting task and import task in sequence for each slice; among them, different tasks between different slices are processed in parallel.
[0165] Slice the n data points in each data segment into slices. Assume the maximum amount of data that can be sorted in a single operation is... Then the total data n will be processed as a single data session. The data segment is divided into chunks. If the remaining data is insufficient for a single processing run, it is processed as a separate chunk, thus obtaining the total number of chunks for that data segment. .
[0166] Each slice needs to perform an import task sequentially (importing data from...). (Into the computing unit), sorting tasks, and outgoing tasks (moving the sorting results from the computing unit back to the computing unit). ). For the same slice, the tasks of moving in, sorting and moving out are processed in series, while for different slices, multiple tasks can be processed in parallel at the same time point.
[0167] The parallel processing flow among different slices is as follows:
[0168] At time point ①, slice a performs the moving-in task to move data from to the computing unit.
[0169] At time point ②, slice a performs the sorting task to perform the sorting operation; at the same time, slice b performs the moving-in task.
[0170] At time point ③, slice a performs the moving-out task to move the sorting result from the computing unit back to ; slice b performs the sorting task; and slice c performs the moving-in task.
[0171] At time point ④, slice b performs the moving-out task; slice c performs the sorting task; and slice d performs the moving-in task.
[0172] At time point ⑤, slice c performs the moving-out task; slice d performs the sorting task; and slice e performs the moving-in task.
[0173] At time point ⑥, and so on.
[0174] The merging submodule 4004 is configured to merge the sorting results of the slices to obtain data segment sorting results, and then merge the data segment sorting results to obtain the first sorted point cloud.
[0175] After the slice sorting of the data segment is completed, the merging sorting of the data segment is performed to synthesize the ordered data: after the above pipelining processing, the segment ordered data is formed, and the segment ordered data is merged in pairs to form the ( segment ordered data. In this way, when , the merging in pairs is continuously performed until only one segment ordered data is left. The data of different data segments is also merged, the point cloud memory of the sorted point cloud is re-allocated, the points adjacent in space are also adjacent in memory, and the first sorted point cloud is obtained.
[0176] As an optional implementation manner, Figure 9 is a structure diagram of the difference module provided by the embodiment of the application, as shown in Figure 9 , the difference module 500 includes:
[0177] The grid layering submodule 5001 is configured to perform hierarchical division on the grid corresponding to each point in the first sorted point cloud and the second sorted point cloud according to the difference in the last bit number of the index value.
[0178] Background point cloud and current frame point cloud After sorting, the second sorted point clouds are obtained respectively. and the first sorted point cloud Before searching for neighboring points, the following definitions are made: First, points with the same index value are defined as belonging to the same grid cell, i.e., layer 0; points with index values where the last 3 bits are different and the rest are the same are defined as belonging to layer 1, a total of 8 grid cells; points with index values where the last 6 bits are different and the rest are the same are defined as belonging to layer 2, a total of 64 grid cells; and so on. Based on this definition, the total number of leaf grid cells in layer n is... The number of leaf grids (not located at the layer boundary in the X, Y, and Z directions) within this layer is: .
[0179] The starting point determination submodule 5002 is used to find, for the current point in the first sorted point cloud, the point in the second sorted point cloud whose second index value is closest to the first index value of the current point, and use that point as the starting point for the search.
[0180] Traversing the first sorted point cloud Let the points in the cloud be sorted first. The point currently visited is the current point. Its corresponding first index value is Due to the second sorted point cloud and the first sorted point cloud The indexes are all ordered, so as long as the second sorted point cloud is used... By searching sequentially, we can find the first index value of the current point. The closest point will be used to sort the second point cloud. The point found is recorded as the search starting point. It is in the second sorted point cloud The serial number in is The Morton index corresponding to each point in the second sorted point cloud is the second index value. In the second sorted point cloud after sorting according to the second index value, each point is numbered according to the sorted order, thus obtaining the sequence number of each point in the second sorted point cloud.
[0181] The target layer determination submodule 5003 is used to determine whether the grid corresponding to the current point is a boundary grid of the current layer layer by layer from low to high. If it is, the boundary grid of the next higher layer is determined; otherwise, the current layer is recorded as the target layer.
[0182] Calculate the current point The minimum layer number at which the current point is not on the boundary. Specifically, the determination of the current point starts from layer 2. whether the current grid is a boundary grid, i.e., whether the current point is a boundary point of the layer, if it is a boundary point, continue to search the third layer, if it is a non-boundary point, stop calculation, and record the current layer of the point as a target layer . .
[0183] The first determination submodule 5004 is configured to, when the target layer is less than the preset number of layers, sequentially search for the number of adjacent points in the positive direction and the negative direction of the second sorted point cloud from the search starting point, if the number of adjacent points reaches the preset number threshold, determine that the current point is a background point, if the number of adjacent points does not reach the preset number threshold until the end of the search in the negative direction, determine that the current point is a foreground point; wherein when the grid of the search point and the current point is not in the same layer, the search in any direction ends.
[0184] The target layer is greater, it means that more grids need to be traversed to find all potential adjacent points, therefore, in order to make the search more efficient, when the target layer is less than the preset number of layers (previously set comparison threshold, preferably 6 or 7 layers), the following operations are performed:
[0185] From the sequence number of the search starting point , first search in the positive direction in the second sorted point cloud , the second index value of the current search point is recorded as , and the following conditions are determined: , wherein represents right bit shift:
[0186]
[0187] a. If the condition is met, it means that the current point is in the same layer as the search point , continue to calculate the distance between the search point and the current point :
[0188] When , the current point finds an adjacent point in the second sorted point cloud , and one is added;
[0189] When , continue to search for the next point ; wherein is the preset search radius.
[0190] b. If the condition is not met, the search point is found is not possible a neighboring point of , and since the second index value of the point in the second ordered point cloud is ordered, is not possible a neighboring point of
[0191] , the search is terminated. , it is considered that the current point meets the requirements of the background point, and if the positive direction search is completed, < , search in the negative direction of the sequence number of the search starting point, and record the second index value of the found search point as , and determine whether the following condition is met:
[0192]
[0193] When the condition is met, step a is executed, and the accumulation of is continued; if the condition is not met, step b is executed, and if is met during the search process, the current point is considered a background point, otherwise if exceeds the same layer, is still less than , the current point is determined to be a foreground point.
[0194] The second determination submodule 5005 is configured to, when the target layer is greater than or equal to the preset layer number, search for neighboring points in the eight surrounding grids of the grid corresponding to the search starting point, taking the search starting point as the starting point, in the positive direction and the negative direction of the second ordered point cloud, count the total number of neighboring points, and determine that the current point is a background point if the total number is greater than the preset number threshold.
[0195] When the target layer is greater than or equal to the preset layer number , it is considered that it takes too much time to traverse all the points in the same layer grid. According to the characteristics of the Morton index, there are 8 grids whose last 3 bits are different from the first index value of the current point and the remaining bits are the same. These grids may have neighboring points and are continuous in memory, which facilitates searching, so only the 8 grids are checked to see if there are neighboring points. The judgment of such grids is as follows:
[0196]
[0197] the sequence number searches the points in the 8 grids in positive and negative directions respectively, and calculates the distances d of the points to the current point , calculates the number of points with distances d less than a preset search radius If , the current point is a background point.
[0198] The third determination submodule 5006 is configured to, for the remaining points that have not been determined yet, construct a KDTree for all points in the adjacent grids of the starting point corresponding grid and perform a radius search on the remaining points, and when the number of adjacent points searched is greater than or equal to a preset number threshold, determine that the remaining point is a background point, otherwise, determine that the remaining point is a foreground point.
[0199] The proportion of the number of internal leaf grids in each layer to the total number of grids is , so when the preset number of layers is set to be large, most of the points searched are determined to be background points or foreground points by the first determination submodule. A part of the remaining points are determined to be background points by the second determination submodule. For the remaining points that have not been determined yet after the first determination submodule and the second determination submodule, these points are all boundary points of the layer, and the coordinates of the grids where the points are located satisfy any one of the following conditions, where is the remainder:
[0200] ;
[0201] Therefore, the possible adjacent points of the remaining points only exist in the adjacent grids of the grids that satisfy the condition, that is, the grid coordinates satisfy , and in the second sorted point cloud, the points in the grids are constructed into a KDTree, and a radius search is performed on the remaining points. When the number of adjacent points in the search result is greater than or equal to , the remaining point is determined to be a background point, otherwise, the remaining point is determined to be a foreground point.
[0202] Through the above steps, the states of all points in the first sorted point cloud can be determined, that is, the background difference is completed.
[0203] As an optional implementation, Figure 10 is a structural diagram of a preprocessing module provided by an embodiment of the present application, as shown in Figure 10 , the preprocessing module 100 includes:
[0204] A first redundant point removal submodule 1001 is configured to perform straight-through filtering on the current frame point cloud according to the range of the defense area.
[0205] The second redundancy point removal submodule 1002 is configured to perform ground fitting and remove points below the ground in the current frame point cloud according to the fitting result.
[0206] First, the current frame point cloud is subjected to a straight-through filtering operation in combination with the pre-set defense space range, and the point cloud data located outside the defense area is removed by limiting the value range in each coordinate axis direction, thereby reducing the data amount for subsequent processing and improving the operation efficiency.
[0207] The current frame point cloud is subjected to ground fitting processing, and a ground model conforming to the current scene can be constructed by using an algorithm based on random sample consensus (RANSAC). After the fitting is completed, the point cloud data below the ground is removed according to the height reference of the ground model, so as to eliminate the interference caused by ground undulations, low obstacles or environmental noise, and ensure that the remaining point cloud data only includes the effective target points above the ground within the defense area.
[0208] Furthermore, to reduce the data processing amount, the current frame point cloud can also be down-sampled.
[0209] After the above pre-processing, the processed point cloud is obtained for subsequent ordering and background point judgment.
[0210] The above technical solution has the following beneficial effects: the point cloud is subjected to grid division and Morton index calculation, and the memory of the point cloud is re-allocated and ordered according to the index, so that the spatially adjacent points in the point cloud are also adjacent in the ordering sequence, thereby improving the search efficiency of adjacent points; by introducing the judgment rule of the hierarchical grid, the search range can be quickly limited when the target point is at a lower level, and only a small number of adjacent grids are checked when the target point is at a higher level, and for a small number of points that cannot be determined, the search range can be reduced and a simplified KDTree can be constructed for radius search, thereby avoiding large-scale invalid search, reducing the operation complexity, and improving the data processing efficiency; the ordering process is segmented and sliced by using the flow processing, so that the data moving-in, calculation and moving-out tasks are executed in parallel between different slices, thereby fully utilizing the parallel processing capability of the hardware and further shortening the overall operation time.
[0211] The specific embodiments of the above invention further illustrate the purposes, technical solutions and beneficial effects of the invention, and it should be understood that the above content is only a specific embodiment of the invention and does not limit the protection scope of the invention, and any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the invention shall be included in the protection scope of the invention.
Claims
1. A method for background difference of a laser point cloud, characterized in that, The method comprises the following steps: obtaining a current frame point cloud; preprocessing the current frame point cloud according to scene prior information to obtain a processed point cloud; dividing the processed point cloud into grids according to a preset grid length, and calculating the grid coordinates of each point in the processed point cloud; wherein the preset grid length is a preset search radius; calculating a first index value corresponding to each point according to the grid coordinates and a preset rule; sorting all points in the processed point cloud according to the first index value to obtain a first sorted point cloud; traversing each point in the first sorted point cloud, searching for neighboring points in a second sorted point cloud according to the preset search radius, and determining background points according to the number of neighboring points; wherein the second sorted point cloud is a sorted point cloud obtained in advance according to a background point cloud, and the steps of obtaining the second sorted point cloud according to the background point cloud are consistent with the steps of obtaining the first sorted point cloud according to the current frame point cloud.
2. The laser point cloud background difference method of claim 1, wherein, The method of calculating a first index value corresponding to each point according to the grid coordinates and a preset rule comprises the following steps: for any point in the processed point cloud, shifting the x-coordinate of the grid coordinates to which the point belongs according to the preset rule, performing a bitwise OR operation on the shifted coordinate and the original coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain an x-direction index value; shifting the y-coordinate of the grid coordinates to which the point belongs according to the preset rule, performing a bitwise OR operation on the shifted coordinate and the original coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a y-direction index value; shifting the z-coordinate of the grid coordinates to which the point belongs according to the preset rule, performing a bitwise OR operation on the shifted coordinate and the original coordinate, and performing a bitwise AND operation on the coordinate after the bitwise OR operation and a mask to obtain a z-direction index value; performing a combination of shifting and bitwise OR operation on the x-direction index value, the y-direction index value and the z-direction index value to obtain the first index value of the point.
3. The laser point cloud background differencing method of claim 1, wherein, The method of sorting all points in the processed point cloud according to the first index value to obtain a first sorted point cloud comprises the following steps: composing an index pair of the first index value corresponding to each point and its original serial number, and arranging the index pair in ascending order of the original serial number to obtain sorting input data; dividing the sorting input data into multiple data segments, and assigning each data segment to a computing core for processing; dividing each data segment into multiple slices, and sequentially executing a move-in task, a sorting task and a move-out task for each slice; wherein different tasks in different slices are processed in parallel; merging the sorting results of each slice to obtain a data segment sorting result, and then merging the data segment sorting results to obtain the first sorted point cloud.
4. The laser point cloud background differencing method of claim 1, wherein, The method of traversing each point in the first sorted point cloud, searching for neighboring points in the second sorted point cloud according to the preset search radius, and determining background points according to the number of neighboring points comprises the following steps: dividing the grid corresponding to each point in the first sorted point cloud and the second sorted point cloud into levels according to the difference in the number of last bits of the index value; For a current point in the first ordered point cloud, a point to which a second index value closest to the first index value of the current point belongs in the second ordered point cloud is found, and the point is taken as a starting point of finding; From low to high, whether the current point corresponds to a boundary grid of the current layer is judged layer by layer, if yes, a boundary grid of a higher layer is judged, otherwise, the current layer is recorded as a target layer; When the target layer is less than a preset number of layers, from the starting point of finding, a number of adjacent points is sequentially found in a positive direction and a negative direction of the second ordered point cloud, if the number of adjacent points reaches a preset number threshold, the current point is determined as a background point, if the number of adjacent points does not reach the preset number threshold until the negative direction finding ends, the current point is determined as a foreground point; when the grid of the finding point and the grid of the current point are not in the same layer, the finding in any direction ends; When the target layer is greater than or equal to the preset number of layers, in the eight grids around the grid corresponding to the starting point of finding, adjacent points are found in the positive direction and the negative direction of the second ordered point cloud respectively, a total number of adjacent points is counted, if the total number is greater than the preset number threshold, the current point is determined as a background point; For the remaining points that still cannot be determined, a KDTree is constructed for all points in the adjacent grids of the grid corresponding to the starting point of finding, and a radius search is performed on the remaining points, when the number of adjacent points searched is greater than or equal to the preset number threshold, the remaining point is determined as a background point, otherwise, as a foreground point.
5. The laser point cloud background differencing method of claim 1, wherein, The preprocessing of the current frame point cloud according to the scene prior information comprises: straight-through filtering of the current frame point cloud according to a defense area range; ground fitting is performed, and points below the ground in the current frame point cloud are removed according to the fitting result.
6. A laser point cloud background differencing system, comprising: It comprises: a preprocessing module configured to acquire a current frame point cloud; preprocessing of the current frame point cloud according to scene prior information to obtain a processed point cloud; a grid division module configured to divide the processed point cloud into grids according to a preset grid side length, and calculate grid coordinates of a grid corresponding to each point in the processed point cloud; wherein the preset grid side length is a preset search radius; an index calculation module configured to calculate a first index value corresponding to each point according to the grid coordinates according to a preset rule; an ordering module configured to order all points in the processed point cloud according to the first index value to obtain a first ordered point cloud; a difference module configured to traverse each point in the first ordered point cloud, search for adjacent points in a second ordered point cloud according to the preset search radius, and determine a background point according to the number of adjacent points; wherein the second ordered point cloud is an ordered point cloud obtained in advance according to a background point cloud, and the steps of obtaining the second ordered point cloud according to the background point cloud are consistent with the steps of obtaining the first ordered point cloud according to the current frame point cloud.
7. The laser point cloud background subtraction system of claim 6, wherein, The index calculation comprises: The first index value calculation submodule is configured to, for any point in the point cloud, shift the x coordinate of the grid coordinate to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain an x direction index value. The second index value calculation submodule is configured to, for any point in the point cloud, shift the y coordinate of the grid coordinate to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain a y direction index value. The third index value calculation submodule is configured to, for any point in the point cloud, shift the z coordinate of the grid coordinate to which the point belongs according to the preset rule, perform a bitwise OR operation on the shifted coordinate and the original coordinate, and perform a bitwise AND operation on the coordinate after the bitwise OR operation and a mask, to obtain a z direction index value. The index combination submodule is configured to combine the x direction index value, the y direction index value and the z direction index value by shifting and performing a bitwise OR operation, to obtain the first index value of the point.
8. The laser point cloud background subtraction system of claim 6, wherein, The sorting module comprises: The index pair calculation submodule is configured to form an index pair by combining the first index value corresponding to each point and the original serial number of the point, and arrange the index pairs in ascending order of the original serial number, to obtain sorting input data. The data distribution submodule is configured to divide the sorting input data into a plurality of data segments, and distribute each data segment to a computing core for processing. The slice sorting submodule is configured to divide each data segment into a plurality of slices, and sequentially execute a moving-in task, a sorting task and a moving-out task for each slice; wherein different tasks of different slices are processed in parallel. The merging submodule is configured to merge the sorting results of the slices to obtain a data segment sorting result, and then merge the data segment sorting results to obtain a first sorted point cloud.
9. The laser point cloud background subtraction system of claim 6, wherein, The difference module comprises: The grid layering submodule is configured to layer the grid corresponding to each point in the first sorted point cloud and the second sorted point cloud, respectively, according to the difference in the number of last bits of the index values. The starting point determination submodule is configured to, for a current point in the first sorted point cloud, find a point in the second sorted point cloud whose second index value is closest to the first index value of the current point, and take the point as a starting point of searching. The target layer determination submodule is configured to determine, from low to high, whether the grid corresponding to the current point is a boundary grid of a current layer, and if so, determine a boundary grid of a higher layer; otherwise, record the current layer as a target layer. The first determination submodule is configured to, when the target layer is smaller than a preset number of layers, sequentially search for a number of adjacent points in a positive direction and a negative direction of the second sorted point cloud from the starting point of searching, and if the number of adjacent points reaches a preset number threshold, determine that the current point is a background point, and if the number of adjacent points does not reach the preset number threshold until the end of searching in the negative direction, determine that the current point is a foreground point; wherein when the grid of the searching point and the grid of the current point are not in the same layer, the searching in either direction ends. A second determination submodule is configured to, when the target layer is greater than or equal to a preset layer number, find, in the eight surrounding grids of the starting grid, neighboring points in the positive direction and the negative direction of the second sorting point cloud respectively, starting from the starting grid, count the total number of the neighboring points, and determine that the current point is a background point if the total number is greater than a preset number threshold. A third determination submodule is configured to, for the remaining points that have not been determined, construct a KDTree for all points in the adjacent grid of the starting grid and perform a radius search on the remaining points, determine that the remaining point is a background point if the number of the searched neighboring points is greater than or equal to the preset number threshold, and determine that the remaining point is a foreground point otherwise.
10. The laser point cloud background subtraction system of claim 6, wherein, The preprocessing module comprises: A first redundant point removal submodule is configured to perform straight-through filtering on the current frame point cloud according to the range of the defense area. A second redundant point removal submodule is configured to perform ground fitting and remove points below the ground in the current frame point cloud according to the fitting result.
Citation Information
Patent Citations
Laser radar identification method and device, electronic equipment and storage medium
CN114495026A
Morton code construction method, encoder, decoder and storage medium
CN114868153A