Point cloud data sampling method, device, computer equipment and readable storage medium
By dividing grid space and parallel computing technology in point cloud data sampling, selecting the point with the smallest Euclidean distance for sampling, the problem of unevenness and large calculation volume in point cloud data sampling in the existing technology is solved, and efficient Uniform point cloud data sampling.
Patent Information
- Application Number
- CN202111517744.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-12-24
- Estimated Expiration
- 2041-12-10
AI Technical Summary
The existing point cloud data sampling algorithm cannot guarantee the uniformity of the distribution of data in the space after sampling, and due to the huge amount of calculation, the sampling process time is long, especially when the number of point clouds increases, which makes it difficult to achieve practical application.
By dividing the grid space, initially sampling the point cloud data, and cyclically sampling if necessary, combined with parallel computing technology, the point with the smallest Euclidean distance is selected as the target sampling point until the preset point threshold is reached.
Improve sampling effect and speed, reduce calculation complexity, and change the relationship between sampling time and the number of point clouds to O(N), alleviate the time loss caused by point cloud data growth, and achieve a more uniform and efficient point cloud. sampling.
Smart Images

Figure CN114170401B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a point cloud data sampling method, device, computer equipment and readable storage medium. Background Art
[0002] In the existing grid sampling algorithm and random sampling algorithm, there is no constraint relationship between the points in the point cloud data. In terms of sampling effect, the above methods cannot guarantee the uniformity of the spatial distribution of the sampled data and cannot meet the needs of most point cloud applications.
[0003] The uniform sampling algorithm and geometric sampling algorithm in the prior art use the geometric relationship between point cloud data to realize the spatial constraint of point cloud data to achieve the purpose of uniform sampling. However, the above methods cannot be effectively parallelized, and the single-step calculation amount is huge, and the total calculation amount is in an O(N3) relationship with the complexity of the number of point clouds. Therefore, it takes a long time to implement the above sampling process, and as the number of point clouds increases, the calculation time explodes, which is not conducive to the practical application of the algorithm. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application provide a point cloud data sampling method, device, computer equipment and readable storage medium. The specific scheme is as follows:
[0005] In a first aspect, an embodiment of the present application provides a point cloud data sampling method, the method comprising:
[0006] Obtain initial point cloud data from the data set to be sampled;
[0007] Acquire an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data;
[0008] Performing preliminary sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the preliminary sampling into a sampling data set;
[0009] Determine whether the number of points of the target point cloud data in the sampling data set is greater than or equal to a preset point threshold;
[0010] If the number of points of the target point cloud data in the sampling data set is greater than or equal to the preset point number threshold, outputting the sampling data set;
[0011] If the number of points of the target point cloud data in the sampled data set is less than the preset point threshold, a loop sampling step is performed until the number of points of the target point cloud data in the sampled data set is equal to the preset point threshold.
[0012] According to a specific implementation of the embodiment of the present application, the step of obtaining the initial grid space according to the preset initial grid width and the initial boundary range value of the three-dimensional distribution space of the initial point cloud data includes:
[0013] Calculating the number of grids corresponding to three dimensions in the three-dimensional distribution space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data;
[0014] Update the initial boundary range value of each dimension according to the number of grids in each dimension to obtain a first target boundary range value, wherein the boundary range value includes a minimum boundary value and a maximum boundary value of each dimension;
[0015] The initial grid space is divided according to the first target boundary range value of each dimension, the initial grid width, and the number of grids in each dimension, so that the initial grid space covers all the initial point cloud data.
[0016] According to a specific implementation of the embodiment of the present application, the initial point cloud data is composed of a plurality of discrete points, and the step of performing preliminary sampling on the initial point cloud data according to the initial grid space and storing the target point cloud data obtained by the preliminary sampling into the sampling data set includes:
[0017] Taking each corner point of the initial grid space as the center, bidirectionally expand the first target boundary range values of the three dimensions of the initial grid space by preset values to obtain a second target boundary range value, wherein the preset value is half of the initial grid width;
[0018] updating the initial grid space according to the second target boundary range value and the initial grid width to obtain a target grid space;
[0019] Parallel calculation of the Euclidean distances from discrete points in each grid in the target grid space to the center point of the grid to which it belongs;
[0020] The discrete point with the smallest Euclidean distance is selected as the target sampling point of the grid to which it belongs, and the target sampling point corresponding to each grid is stored in the sampling data set.
[0021] According to a specific implementation of an embodiment of the present application, if the number of points of the target point cloud data in the sampling data set is less than a preset point threshold, the step of executing a loop sampling step until the number of points of the target point cloud data in the sampling data set is equal to the preset point threshold includes:
[0022] Parallel calculation of the Euclidean distances from discrete points in each grid in the initial grid space to the center point of the grid to which it belongs;
[0023] Select the discrete point with the smallest Euclidean distance as the target sampling point of the corresponding grid, and store the target sampling point corresponding to each grid into the sampling data set;
[0024] Determine whether the number of points in the sample data set is greater than or equal to a preset point threshold;
[0025] If the number of points in the sample data set is greater than or equal to a preset point threshold, output the sample data set;
[0026] If the number of points in the sampled data set is less than a preset point threshold, the initial grid width in the initial sampling step is replaced by the target grid width to obtain the next iterative sampling step of the cycle, wherein the target grid width is half of the initial grid width;
[0027] The iterative sampling step is performed until the number of points in the sampled data set is equal to a preset point number threshold.
[0028] According to a specific implementation of the present application, the step of parallelly calculating the Euclidean distances of discrete points in each grid in the target grid space to the center point of the grid to which they belong includes:
[0029] Determine a grid to be calculated in the target grid space, wherein the grid to be calculated is a grid having discrete points in the grid and the center point of the grid has not participated in the Euclidean distance calculation;
[0030] The Euclidean distances from all discrete points in the grid to be calculated to the center point of the grid to which they belong are calculated in parallel.
[0031] According to a specific implementation of an embodiment of the present application, the three dimensions of the three-dimensional distribution space are respectively an x-axis, a y-axis and a z-axis, and the step of calculating the number of grids corresponding to the three dimensions in the three-dimensional distribution space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data includes:
[0032] According to the formula Calculate the average spatial occupancy of point cloud data;
[0033] According to the formula Calculate the base grid width;
[0034] According to the formula and Calculate the number of grids in the three dimensions of x-axis, y-axis and z-axis respectively;
[0035] Where M is the number of points in the initial point cloud data, vol is the average space occupancy, xmax is the maximum value of the boundary of the x-axis, ymax is the maximum value of the boundary of the y-axis, zmax is the maximum value of the boundary of the z-axis, xmin is the minimum value of the boundary of the x-axis, ymin is the minimum value of the boundary of the y-axis, zmin is the minimum value of the boundary of the z-axis, w is the reference grid width, grid x is the number of grids corresponding to the x-axis dimension, grid y is the number of grids corresponding to the y-axis dimension, grid z is the number of grid cells corresponding to the z-axis dimension, and ceil(*) represents the rounding function.
[0036] According to a specific implementation of the embodiment of the present application, the step of updating the initial boundary range value of each dimension according to the number of grids in each dimension includes:
[0037] According to the formula xmax=xmin+grid x *w updates the maximum boundary value of the x-axis dimension;
[0038] According to the formula ymax=ymin+grid y *w updates the maximum boundary value of the y-axis dimension;
[0039] According to the formula zmax=zmin+grid z *w updates the maximum bounds of the z-axis dimension.
[0040] In a second aspect, an embodiment of the present application provides a point cloud data sampling device, the device comprising:
[0041] A first acquisition module is used to acquire initial point cloud data from the data set to be sampled;
[0042] A second acquisition module is used to acquire an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data;
[0043] A sampling module, used for performing preliminary sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the preliminary sampling into a sampling data set;
[0044] A judging module, used to judge whether the number of points of the target point cloud data in the sampled data set is greater than or equal to a preset point number threshold;
[0045] A first execution module, configured to output the sampling data set if the number of points of the target point cloud data in the sampling data set is greater than or equal to the preset point number threshold;
[0046] The second execution module is used to execute a loop sampling step if the number of points of the target point cloud data in the sampling data set is less than a preset point threshold, until the number of points of the target point cloud data in the sampling data set is equal to the preset point threshold.
[0047] In a third aspect, an embodiment of the present application provides a computer device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, the point cloud data sampling method described in the first aspect is executed.
[0048] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run on a processor, the point cloud data sampling method described in the first aspect is executed.
[0049] The embodiment of the present application provides a point cloud data sampling method, device, computer equipment and readable storage medium, the method comprising: obtaining initial point cloud data from a data set to be sampled; obtaining an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, performing initial sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the initial sampling into the sampling data set, if the target point cloud data obtained by the initial sampling step does not fully store the sampling data set, then performing cyclic sampling on the remaining point cloud data in a cyclic sampling step. The present application samples point cloud data by dividing the grid, and uses a cyclic sampling step in the sampling process, which can use a parallel sampling algorithm while improving the sampling effect, effectively improving the sampling speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope of protection of the present invention. In each of the drawings, similar components are numbered similarly.
[0051] Figure 1 A schematic diagram of a method flow of a point cloud data sampling method provided in an embodiment of the present application is shown;
[0052] Figure 2 A schematic diagram showing a first effect of a point cloud data sampling method provided by an embodiment of the present application is shown;
[0053] Figure 3 A schematic diagram showing a second effect of a point cloud data sampling method provided by an embodiment of the present application is shown;
[0054] Figure 4A third effect schematic diagram of a point cloud data sampling method provided in an embodiment of the present application is shown;
[0055] Figure 5 A fourth effect schematic diagram of a point cloud data sampling method provided by an embodiment of the present application is shown;
[0056] Figure 6 A schematic diagram of a device module of a point cloud data sampling device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments.
[0058] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0059] Hereinafter, the terms "including", "having" and their cognates, which may be used in various embodiments of the present invention, are intended only to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or adding the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0060] Furthermore, the terms “first”, “second”, “third”, etc. are merely used for distinguishing descriptions and are not to be understood as indicating or implying relative importance.
[0061] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present invention belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present invention.
[0062] refer to Figure 1 , is a schematic diagram of a method flow of a point cloud data sampling method provided in an embodiment of the present application. The present application embodiment provides a point cloud data sampling method, such as Figure 1 As shown, the point cloud data sampling method includes:
[0063] Step S101, obtaining initial point cloud data from the data set to be sampled;
[0064] In a specific embodiment, the data set to be sampled may be a point cloud data set obtained by scanning any three-dimensional object.
[0065] The initial point cloud data obtained in this embodiment is composed of multiple discrete points, and the initial point cloud data is discretely distributed in a three-dimensional distribution space, which can be a point cloud coordinate system or other types of three-dimensional space, which is not limited here. The embodiment of this application is described by taking the point cloud coordinate system as an example of the three-dimensional distribution space.
[0066] Step S102, obtaining an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data;
[0067] In a specific embodiment, the initial point cloud data is discretely distributed in a point cloud coordinate system, and the discrete points have boundary values corresponding to the x-axis dimension, y-axis dimension, and z-axis dimension in the point cloud coordinate system, that is, the initial boundary range values of the three-dimensional distribution space of the initial point cloud data.
[0068] The user sets a preset initial grid width in advance according to the discreteness of the point cloud data, so that the computer program can divide the three-dimensional space where the initial point cloud data is located according to the initial grid width and the initial boundary range value to obtain an initial grid space.
[0069] According to a specific implementation of the embodiment of the present application, the step of obtaining the initial grid space according to the preset initial grid width and the initial boundary range value of the three-dimensional distribution space of the initial point cloud data includes:
[0070] Calculating the number of grids corresponding to three dimensions in the three-dimensional distribution space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data;
[0071] Specifically, according to the formula Calculate the average spatial occupancy of point cloud data;
[0072] According to the formula Calculate the base grid width;
[0073] According to the formula and Calculate the number of grids in the three dimensions of x-axis, y-axis and z-axis respectively;
[0074] Where M is the number of points in the initial point cloud data, vol is the average space occupancy, xmax is the maximum value of the boundary of the x-axis, ymax is the maximum value of the boundary of the y-axis, zmax is the maximum value of the boundary of the z-axis, xmin is the minimum value of the boundary of the x-axis, ymin is the minimum value of the boundary of the y-axis, zmin is the minimum value of the boundary of the z-axis, w is the reference grid width, grid x is the number of grids corresponding to the x-axis dimension, grid y is the number of grids corresponding to the y-axis dimension, grid z is the number of grid cells corresponding to the z-axis dimension, and ceil(*) represents the rounding function.
[0075] Update the initial boundary range value of each dimension according to the number of grids in each dimension to obtain a first target boundary range value, wherein the boundary range value includes a minimum boundary value and a maximum boundary value of each dimension;
[0076] In a specific embodiment, after the computer device divides the number of grids of each dimension corresponding to the three-dimensional space of the initial point cloud data, since the reference width of each grid is a fixed value, the boundary value corresponding to each dimension may change due to the number of grids. After the computer calculates the number of grids of each dimension, the boundary range value of each dimension is updated according to the number of grids of the corresponding dimension to obtain the first target boundary range value.
[0077] Specifically, the step of updating the initial boundary range value of each dimension according to the number of grids in each dimension includes:
[0078] According to the formula xmax=xmin+grid x *w updates the maximum boundary value of the x-axis dimension;
[0079] According to the formula ymax=ymin+grid y *w updates the maximum boundary value of the y-axis dimension;
[0080] According to the formula zmax=zmin+grid z *w updates the maximum bounds of the z-axis dimension.
[0081] In a specific embodiment, the updated maximum value of the boundary of each dimension is the reference grid width multiplied by the number of grids, and the minimum value of the boundary of each dimension is 0.
[0082] The initial grid space is divided according to the first target boundary range value of each dimension, the initial grid width, and the number of grids in each dimension, so that the initial grid space covers all the initial point cloud data.
[0083] In a specific embodiment, Figure 2As shown, the three-dimensional space where the initial point cloud data is located is divided according to the above calculation results, so that a preset number of standard space grids can be obtained, so that the standard space grids can be calculated through a unified algorithm, which is conducive to the subsequent execution of parallel calculation steps.
[0084] Step S103, performing preliminary sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the preliminary sampling into a sampling data set;
[0085] In a specific embodiment, the number of points of the point cloud data stored in the sampled data set is always less than or equal to the number of points of the point cloud data in the to-be-sampled data set.
[0086] After the computer divides the initial grid space, it samples the target point cloud data according to the initial sampling step to obtain the number of target point cloud data points.
[0087] According to a specific implementation of the embodiment of the present application, the initial point cloud data is composed of a plurality of discrete points, and the step of performing preliminary sampling on the initial point cloud data according to the initial grid space and storing the target point cloud data obtained by the preliminary sampling into the sampling data set includes:
[0088] Taking each corner point of the initial grid space as the center, bidirectionally expand the first target boundary range values of the three dimensions of the initial grid space by preset values to obtain a second target boundary range value, wherein the preset value is half of the initial grid width;
[0089] updating the initial grid space according to the second target boundary range value and the initial grid width to obtain a target grid space;
[0090] Parallel calculation of the Euclidean distances from discrete points in each grid in the target grid space to the center point of the grid to which it belongs;
[0091] The discrete point with the smallest Euclidean distance is selected as the target sampling point of the grid to which it belongs, and the target sampling point corresponding to each grid is stored in the sampling data set.
[0092] In a specific embodiment, the corner points are the corner points of each spatial grid, that is, Figure 3 In the middle circle, taking the corner points of each spatial grid as the center, bidirectionally expanding the preset values along the three directions of the point cloud coordinate system, we can get the following Figure 3 The dashed bounding box is shown.
[0093] like Figure 3 As shown, Figure 3It is a grid diagram of the xoy plane. If the initial grid width is w, then the minimum boundary value of the second target boundary range is obtained by subtracting w / 2 from the minimum boundary value xmin of the initial grid space x-axis dimension, and the maximum boundary value xmax of the initial grid space x-axis dimension is increased by w / 2 to obtain the maximum boundary value of the second target boundary range.
[0094] The same operation as that of the x-axis dimension is performed on the y-axis dimension and the z-axis dimension, that is, the second target boundary range values corresponding to the three dimensions are obtained.
[0095] According to the second target boundary range value and the initial grid width w, the grid is divided, and the following can be obtained: Figure 3 The target grid space is shown by the dashed line.
[0096] For each grid in the target grid space, a corresponding Euclidean distance calculation thread is established. The calculation algorithm used for each grid is the same. The Euclidean distance calculation threads of all grids are run simultaneously to realize parallel calculation of the Euclidean distance from discrete points in each grid in the target grid space to the center point of the grid to which it belongs.
[0097] Specifically, the number of discrete points in each grid is different, but only one target sampling point is derived from each grid to ensure a more uniform sampling effect of point cloud sampling. When the Euclidean distances of multiple discrete points from the center point of the grid to which they belong are calculated, the point with the smallest Euclidean distance is selected as the target sampling point.
[0098] After the target sampling point is imported into the sampling data set, the corresponding discrete point in the to-be-sampled data set is deleted to ensure that the same point is not sampled repeatedly.
[0099] According to a specific implementation of the present application, the step of parallelly calculating the Euclidean distances of discrete points in each grid in the target grid space to the center point of the grid to which they belong includes:
[0100] Determine a grid to be calculated in the target grid space, wherein the grid to be calculated is a grid having discrete points in the grid and the center point of the grid has not participated in the Euclidean distance calculation;
[0101] The Euclidean distances from all discrete points in the grid to be calculated to the center point of the grid to which they belong are calculated in parallel.
[0102] In a specific embodiment, when establishing the calculation thread of each grid in the target grid space, two preset conditions need to be considered. The first preset condition is that there are discrete points in the grid, and the second preset condition is that the grid center point of the grid has never participated in the calculation of the Euclidean distance, that is, the grid has never executed the calculation thread.
[0103] In the initial sampling step, when establishing a calculation thread, only the first preset condition needs to be considered whether it is met. When the first preset condition is met, the grid is determined as a grid to be calculated. When the first preset condition is not met, no operation is performed on the grid without discrete points.
[0104] Through the above steps, the computing resources of the computer can be effectively saved, and by the technical means of parallel calculation of the Euclidean distances of all the grids to be calculated, the calculation processes between the grids can be made non-interfering with each other, effectively reducing the complexity of the calculation process.
[0105] Step S104, determining whether the number of points of the target point cloud data in the sampled data set is greater than or equal to a preset point threshold;
[0106] In a specific embodiment, the number of points in the sampled data set is always less than or equal to the number of points in the data set to be sampled. When the number of points in the sampled data set is equal to the number of points in the data set to be sampled, the sampling of the point cloud data in the data set to be sampled has been completed.
[0107] Before performing the sampling step, the user can set a sampling point number threshold of the sampling data set in advance to ensure that the effect of the sampling step can be adaptively adjusted according to actual usage, thereby enriching the scope of use of the point cloud data sampling method, wherein the sampling point number threshold is less than or equal to the number of points in the point cloud data in the data set to be sampled.
[0108] Therefore, after executing the initial sampling step, it is necessary to further determine whether the number of points of the target point cloud data in the sampling data set is greater than or equal to a preset point number threshold.
[0109] Step S105, if the number of points of the target point cloud data in the sampled data set is greater than or equal to the preset point number threshold, output the sampled data set;
[0110] In a specific embodiment, if during the initial sampling process, the number of points of the target point cloud data in the sampled data set is greater than or equal to the preset point number threshold, the computer immediately stops the sampling step and outputs the sampled data set.
[0111] Step S106, if the number of points of the target point cloud data in the sampled data set is less than the preset point threshold, a loop sampling step is performed until the number of points of the target point cloud data in the sampled data set is equal to the preset point threshold.
[0112] In a specific embodiment, the number of points in the initial point cloud data is usually large, and a single sampling process often cannot achieve the sampling target, that is, the number of points in the target point cloud data in the sampling data set is always less than a preset point threshold.
[0113] When the result of the judging step is that the number of points of the target point cloud data is less than a preset point number threshold, the cyclic sampling step is performed.
[0114] According to a specific implementation of an embodiment of the present application, if the number of points of the target point cloud data in the sampling data set is less than a preset point threshold, the step of executing a loop sampling step until the number of points of the target point cloud data in the sampling data set is equal to the preset point threshold includes:
[0115] Parallel calculation of the Euclidean distances from discrete points in each grid in the initial grid space to the center point of the grid to which it belongs;
[0116] Select the discrete point with the smallest Euclidean distance as the target sampling point of the corresponding grid, and store the target sampling point corresponding to each grid into the sampling data set;
[0117] Determine whether the number of points in the sample data set is greater than or equal to a preset point threshold;
[0118] If the number of points in the sample data set is greater than or equal to a preset point threshold, output the sample data set;
[0119] If the number of points in the sampled data set is less than a preset point threshold, the initial grid width in the initial sampling step is replaced by the target grid width to obtain the next iterative sampling step of the cycle, wherein the target grid width is half of the initial grid width;
[0120] The iterative sampling step is performed until the number of points in the sampled data set is equal to a preset point number threshold.
[0121] In a specific embodiment, Figure 4 and Figure 5 As shown in FIG. , it is a schematic diagram of the effect of the cyclic sampling step. Figure 4 As shown, the Euclidean distance calculation thread is performed according to the divided initial grid space, that is, the Euclidean distance from the discrete point in each grid in the initial grid space to the center point of the corresponding grid is calculated in parallel. After the Euclidean distance corresponding to each grid in the initial grid space is calculated in parallel, the target sampling point selection step similar to the above-mentioned initial sampling step is adopted to store the target sampling points corresponding to each grid into the sampling data set.
[0122] After the sampling process of the initial grid space is completed, a sampling point threshold is also determined to adjust the sampling process in real time according to the preset point threshold to avoid the computer executing too many sampling steps.
[0123] If the judgment result is that the number of points in the sample data set is less than the preset point threshold, Figure 5As shown, based on the initial sampling step, the initial grid width is replaced by the target grid width, and the target grid width is half of the initial grid width.
[0124] For example, in the initial sampling step, the minimum boundary value ymin of the y-axis dimension of the initial grid space is subtracted by w / 2 to obtain the minimum boundary value of the second target boundary range, and the maximum boundary value ymax of the y-axis dimension of the initial grid space is increased by w / 2 to obtain the maximum boundary value of the second target boundary range.
[0125] Then, in the new iterative sampling step, it is necessary to subtract w / 4 from the minimum boundary value ymin of the y-axis dimension of the initial grid space to obtain the minimum boundary value of the second target boundary range, and increase the maximum boundary value ymax of the x-axis dimension of the initial grid space by w / 4 to obtain the maximum boundary value of the second target boundary range. After executing the two-way expansion step of the three dimensions, the iterative sampling step obtains the second target boundary range values corresponding to the three dimensions as follows: Figure 5 shown.
[0126] In the new iterative sampling step, Figure 5 The second target boundary range value and the target grid width w / 2 are used for grid division, and the following can be obtained: Figure 5 The target grid space is shown by the dashed line.
[0127] At the same time, in the iterative sampling step, the step of parallelly calculating the Euclidean distances from all discrete points in the grid to be calculated to the center point of the grid to which they belong needs to take into account both the first preset condition and the second preset condition when establishing the calculation thread. The second preset condition is that the grid center point of the grid has never participated in the calculation of the Euclidean distance, that is, the grid has not executed the calculation thread.
[0128] That is to say, Figure 5 In the iterative sampling step shown, only the + part of the grid can execute the establishment and execution of the calculation thread.
[0129] Through the above-mentioned limitation, repeated sampling of the same sampling point can be avoided during the iterative sampling process, and the spatial binding relationship between points can be strengthened to achieve more standardized and uniform point cloud sampling.
[0130] In addition, if the number of points in the sampled data set is still lower than the preset point threshold after executing one iterative sampling process, the iterative sampling process in the above-mentioned cyclic sampling step is repeated, and the target grid width is further halved to refine the sampling space. When the number of points in the sampled data set is greater than or equal to the preset point threshold, the sampling process is stopped.
[0131] Specifically, the point cloud sampling process in this embodiment can make full use of the multi-threading of hardware resources and adopt a cyclic iterative sampling method to ensure the uniformity of the spatial distribution of the results as much as possible.
[0132] The multi-threaded parallel sampling process of this embodiment is reflected in the target sampling point extraction process within a single loop, and the processes between loop bodies are implemented in a serial manner.
[0133] The loop process in the above embodiment may be, in the target point parallel extraction calculation inside the i-th loop body, let the current set of points to be sampled be P i , the number of points in the current set of points to be sampled is m i The resulting data set is Q i , the number of points in the result data set is n i , let the starting position of the current three dimensions be xmin i , ymin i , zmin i , the grid width is w i , the number of grids is grid xi , grid yi , grid zi , where xyz represents three different coordinate axes, and i represents that i parallel samplings are performed during the entire sampling process.
[0134] First, P i The point cloud data in is divided according to the spatial distribution in a parallel way. According to the number of grids, the number of all grids in the current space is calculated:
[0135] Number of spatial grids grid sumi =grid xi *grid yi *grid zi
[0136] Create a corresponding grid sumi A data pool is used to store the divided data.
[0137] For m i points to be processed, and m i Each thread processes a point cloud data and calculates the grid where the current point is located according to the following formula:
[0138] g x =floor((x-xmin i ) / w i )
[0139] g y =floor((y-ymin i ) / wi )
[0140] g z =floor((z-zmin i ) / w i )
[0141] Among them, g x , g y , g z Indicates the grid index of the current point in three dimensions, floor(*) indicates the rounding function. When the point cloud data falls within a valid distribution grid, the point is added to the data pool where the grid is located. sumi Each data pool stores the point cloud data of the grid to which it belongs.
[0142] Parallel processing of data within each grid. sumi Data pool, open grid sumi Each thread processes the data corresponding to a grid, and the calculations between threads do not interfere with each other.
[0143] Inside each grid, if there is point cloud data inside the grid, the Euclidean distance of each point from the grid center is calculated in turn, and then the point with the smallest distance to the center is selected as the point selected for this sampling of the grid.
[0144] For grid sumi data pools, which can generate at most grid sumi The data obtained by sampling each grid is sequentially placed into Q i For the Q i The point in P i When Q i When the number of points in meets the final threshold N, the sampling process is stopped immediately. Otherwise, after completing this parallel sampling process, the sampling data set is updated, and the starting position, grid width, and number of grids are updated according to the rules to perform the next sampling.
[0145] The point cloud data sampling method provided in the embodiment of the present application effectively improves the sampling speed through iterative and progressive grid division and parallel calculation of sampling point parameters in each grid, while alleviating the time loss caused by the growth of point cloud data and stably improving the sampling effect of point cloud sampling.
[0146] refer to Figure 6 , is a schematic diagram of a device module of a point cloud data sampling device 600 provided in an embodiment of the present application. The present application provides a point cloud data sampling device 600, and the point cloud data sampling device 600 includes:
[0147] A first acquisition module 601 is used to acquire initial point cloud data from a data set to be sampled;
[0148] A second acquisition module 602 is used to acquire an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data;
[0149] A sampling module 603 is used to perform preliminary sampling on the initial point cloud data according to the initial grid space, and store the target point cloud data obtained by the preliminary sampling into a sampling data set;
[0150] A judgment module 604 is used to judge whether the number of points of the target point cloud data in the sample data set is greater than or equal to a preset point number threshold;
[0151] A first execution module 605 is configured to output the sampled data set if the number of points of the target point cloud data in the sampled data set is greater than or equal to the preset point number threshold;
[0152] The second execution module 606 is used to execute a loop sampling step if the number of points of the target point cloud data in the sampling data set is less than a preset point threshold, until the number of points of the target point cloud data in the sampling data set is equal to the preset point threshold.
[0153] In addition, an embodiment of the present application further provides a computer device, including a processor and a memory, wherein the memory stores a computer program, and when the computer program runs on the processor, the point cloud data sampling method in the above embodiment is executed.
[0154] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is run on a processor, the point cloud data sampling method in the above embodiment is executed.
[0155] In summary, the embodiments of the present application provide a point cloud data sampling method, device, computer equipment and readable storage medium. The present invention gradually implements the sampling process of point cloud data in an iterative and progressive grid division manner, enhances the spatial constraint relationship between points in the sampling results, and improves the sampling effect. After dividing the grids, the present invention uses a parallel computing strategy to count the data distribution inside each grid and extract the sampling points. The data between grids do not interfere with each other, and the sampling time complexity is limited to O(N), which effectively improves the sampling speed and alleviates the time loss caused by the growth of point cloud data. The specific implementation methods of the point cloud data sampling device, computer equipment and computer-readable storage medium provided in the embodiments of the present application can refer to the specific implementation methods in the above-mentioned method embodiments, and will not be repeated here one by one.
[0156] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow chart, and the combination of boxes in the structure diagram and / or the flow chart, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0157] In addition, the functional modules or units in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0158] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0159] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A point cloud data sampling method, characterized in that: The method comprises: Obtain initial point cloud data from the data set to be sampled; Acquire an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data; Performing preliminary sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the preliminary sampling into a sampling data set; Determine whether the number of points of the target point cloud data in the sampling data set is greater than or equal to a preset point threshold; If the number of points of the target point cloud data in the sampled data set is greater than or equal to the preset point number threshold, outputting the sampled data set; If the number of points of the target point cloud data in the sampling data set is less than the preset point threshold, a loop sampling step is performed until the number of points of the target point cloud data in the sampling data set is equal to the preset point threshold; wherein The step of obtaining the initial grid space according to the preset initial grid width and the initial boundary range value of the three-dimensional distribution space of the initial point cloud data includes: Calculating the number of grids corresponding to three dimensions in the three-dimensional distribution space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data; Update the initial boundary range value of each dimension according to the number of grids in each dimension to obtain a first target boundary range value, wherein the boundary range value includes a minimum boundary value and a maximum boundary value of each dimension; The initial grid space is divided according to the first target boundary range value of each dimension, the initial grid width and the number of grids in each dimension, so that the initial grid space covers all the initial point cloud data; wherein The initial point cloud data is composed of a plurality of discrete points, and the steps of performing preliminary sampling on the initial point cloud data according to the initial grid space and storing the target point cloud data obtained by the preliminary sampling into the sampling data set include: Taking each corner point of the initial grid space as the center, bidirectionally expand the first target boundary range value of the three dimensions of the initial grid space by a preset value to obtain a second target boundary range value, wherein the preset value is half of the initial grid width; updating the initial grid space according to the second target boundary range value and the initial grid width to obtain a target grid space; Parallel calculation of the Euclidean distances from discrete points in each grid in the target grid space to the center point of the grid to which it belongs; The discrete point with the smallest Euclidean distance is selected as the target sampling point of the grid to which it belongs, and the target sampling point corresponding to each grid is stored in the sampling data set; If the number of points of the target point cloud data in the sampled data set is less than the preset point number threshold, the step of executing the cyclic sampling step until the number of points of the target point cloud data in the sampled data set is equal to the preset point number threshold comprises: Parallel calculation of the Euclidean distances from discrete points in each grid in the initial grid space to the center point of the grid to which it belongs; Select the discrete point with the smallest Euclidean distance as the target sampling point of the corresponding grid, and store the target sampling point corresponding to each grid into the sampling data set; Determine whether the number of points in the sample data set is greater than or equal to a preset point threshold; If the number of points in the sample data set is greater than or equal to a preset point threshold, output the sample data set; If the number of points in the sampled data set is less than a preset point threshold, the initial grid width in the initial sampling step is replaced by the target grid width to obtain the next iterative sampling step of the cycle, wherein the target grid width is half of the initial grid width; The iterative sampling step is performed until the number of points in the sampled data set is equal to a preset point number threshold.
2. The method according to claim 1, characterized in that The step of parallelly calculating the Euclidean distances from discrete points in each grid in the target grid space to the center point of the grid to which it belongs comprises: Determine a grid to be calculated in the target grid space, wherein the grid to be calculated is a grid having discrete points in the grid and the center point of the grid has not participated in the Euclidean distance calculation; The Euclidean distances from all discrete points in the grid to be calculated to the center point of the grid to which they belong are calculated in parallel.
3. The method according to claim 1, characterized in that The three dimensions of the three-dimensional distribution space are respectively an x-axis, a y-axis and a z-axis, and the step of calculating the number of grids corresponding to the three dimensions in the three-dimensional distribution space according to the preset initial grid width and the initial boundary range value of the three-dimensional distribution space of the initial point cloud data comprises: According to the formula Calculate the average spatial occupancy of point cloud data; According to the formula Calculate the base grid width; According to the formula and Calculate the number of grids in the three dimensions of x-axis, y-axis and z-axis respectively; Where M is the number of points in the initial point cloud data, vol is the average space occupancy, xmax is the maximum value of the boundary of the x-axis, ymax is the maximum value of the boundary of the y-axis, zmax is the maximum value of the boundary of the z-axis, xmin is the minimum value of the boundary of the x-axis, ymin is the minimum value of the boundary of the y-axis, zmin is the minimum value of the boundary of the z-axis, w is the reference grid width, grid x is the number of grids corresponding to the x-axis dimension, grid y is the number of grids corresponding to the y-axis dimension, grid z is the number of grid cells corresponding to the z-axis dimension, and ceil(*) represents the rounding function.
4. The method according to claim 3, characterized in that The step of updating the initial boundary range value of each dimension according to the number of grids in each dimension includes: According to the formula xmax=xmin+grid x *w updates the maximum boundary value of the x-axis dimension; According to the formula ymax=ymin+grid y *w updates the maximum boundary value of the y-axis dimension; According to the formula zmax=zmin+grid z *w updates the maximum bounds of the z-axis dimension.
5. A point cloud data sampling device, characterized in that: The device comprises: A first acquisition module is used to acquire initial point cloud data from the data set to be sampled; A second acquisition module is used to acquire an initial grid space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data, wherein the initial grid space covers all the initial point cloud data; A sampling module, used for performing preliminary sampling on the initial point cloud data according to the initial grid space, and storing the target point cloud data obtained by the preliminary sampling into a sampling data set; A judging module, used to judge whether the number of points of the target point cloud data in the sampled data set is greater than or equal to a preset point number threshold; A first execution module, configured to output the sampling data set if the number of points of the target point cloud data in the sampling data set is greater than or equal to the preset point number threshold; The second execution module is used to execute a loop sampling step if the number of points of the target point cloud data in the sampling data set is less than a preset point number threshold, until the number of points of the target point cloud data in the sampling data set is equal to the preset point number threshold; wherein The step of obtaining the initial grid space according to the preset initial grid width and the initial boundary range value of the three-dimensional distribution space of the initial point cloud data includes: Calculating the number of grids corresponding to three dimensions in the three-dimensional distribution space according to a preset initial grid width and an initial boundary range value of the three-dimensional distribution space of the initial point cloud data; Update the initial boundary range value of each dimension according to the number of grids in each dimension to obtain a first target boundary range value, wherein the boundary range value includes a minimum boundary value and a maximum boundary value of each dimension; The initial grid space is divided according to the first target boundary range value of each dimension, the initial grid width and the number of grids in each dimension, so that the initial grid space covers all the initial point cloud data; wherein The initial point cloud data is composed of a plurality of discrete points, and the steps of performing preliminary sampling on the initial point cloud data according to the initial grid space and storing the target point cloud data obtained by the preliminary sampling into the sampling data set include: Taking each corner point of the initial grid space as the center, bidirectionally expand the first target boundary range value of the three dimensions of the initial grid space by a preset value to obtain a second target boundary range value, wherein the preset value is half of the initial grid width; updating the initial grid space according to the second target boundary range value and the initial grid width to obtain a target grid space; Parallel calculation of the Euclidean distances from discrete points in each grid in the target grid space to the center point of the grid to which it belongs; The discrete point with the smallest Euclidean distance is selected as the target sampling point of the grid to which it belongs, and the target sampling point corresponding to each grid is stored in the sampling data set; If the number of points of the target point cloud data in the sampled data set is less than the preset point number threshold, the step of executing the cyclic sampling step until the number of points of the target point cloud data in the sampled data set is equal to the preset point number threshold comprises: Parallel calculation of the Euclidean distances from discrete points in each grid in the initial grid space to the center point of the grid to which it belongs; Select the discrete point with the smallest Euclidean distance as the target sampling point of the corresponding grid, and store the target sampling point corresponding to each grid into the sampling data set; Determine whether the number of points in the sample data set is greater than or equal to a preset point threshold; If the number of points in the sample data set is greater than or equal to a preset point threshold, output the sample data set; If the number of points in the sampled data set is less than a preset point threshold, the initial grid width in the initial sampling step is replaced by the target grid width to obtain the next iterative sampling step of the cycle, wherein the target grid width is half of the initial grid width; The iterative sampling step is performed until the number of points in the sampled data set is equal to a preset point number threshold.
6. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is run on the processor, the point cloud data sampling method according to any one of claims 1 to 4 is executed.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is run on a processor, the point cloud data sampling method according to any one of claims 1 to 4 is executed.
