Point cloud data sampling method, device, equipment, storage medium and program product
Through the methods of octree division and average weight position filtering, point cloud data is streamlined, solving the problem that data characteristics cannot be effectively retained in the existing technology, and achieving the effect of retaining point cloud data characteristics better in the process of streamlining.
Patent Information
- Application Number
- CN202411748340.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-01
AI Technical Summary
When prior art simplifies point cloud data, data characteristics cannot be effectively retained, resulting in loss of details.
The octree division method is used to divide the point cloud data into multiple grid blocks, calculate the average weight position of each leaf grid block, filter out the target sampling points, and generate the sampled point cloud data.
While solving the problems of data storage, transmission, processing speed and memory consumption, the data characteristics of the point cloud are better preserved and the loss of details is reduced.
Smart Images

Figure CN119741448A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image data processing technology, and in particular to a point cloud data sampling method, device, electronic equipment, computer storage medium and computer program product. Background Art
[0002] Point cloud is a data set composed of a large number of discrete points in three-dimensional space. These points usually contain rich information, such as position, color, normal, intensity, etc. In addition, point cloud data is widely used in computer vision, robot navigation, 3D reconstruction, reverse engineering, autonomous driving and other fields.
[0003] In the prior art, in order to generate high-precision raw point cloud data, point clouds are generally acquired through scanning devices, but this acquisition method generates a large amount of data. The raw point cloud data of a scene may contain millions or even billions of points. As a result, various processing devices, especially mobile devices with limited computing power, have certain difficulties in processing such large point clouds. Therefore, there is an urgent need for a sampling method for point cloud data that can preserve the features of point cloud data while streamlining its processing, and can better preserve the data features of point clouds and reduce the loss of details while solving various problems such as data storage, transmission, processing speed, and memory consumption. Summary of the invention
[0004] The main purpose of the present invention is to solve the technical problem in the prior art that when point cloud data is simplified to reduce the space resources occupied by it, data features cannot be well preserved, resulting in loss of details.
[0005] A first aspect of the present invention provides a method for sampling point cloud data, comprising:
[0006] Acquire and divide the first point cloud data to obtain a spatial file, wherein the number of the spatial files is multiple;
[0007] Dividing each of the spatial files into a plurality of grid blocks based on an octree partitioning method;
[0008] Reading the position information of the spatial points contained in each of the spatial files, calculating the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filtering the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks;
[0009] Generate sampled second point cloud data based on the target sampling point.
[0010] Optionally, in a first implementation of the first aspect of the present invention, acquiring and dividing the first point cloud data to obtain a spatial file includes:
[0011] Read multiple original scan files of the target scene to obtain first point cloud data;
[0012] Generate a spatial bounding box based on the position information of each spatial point in the first point cloud data;
[0013] The spatial bounding box is divided into a plurality of spatial ranges, and a plurality of spatial files are generated based on the spatial point information contained in each of the spatial ranges.
[0014] Optionally, in a second implementation of the first aspect of the present invention,
[0015] The step of reading the position information of the spatial points contained in each of the spatial files, calculating the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filtering the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks comprises:
[0016] Get the grid space range of the leaf grid block corresponding to the leaf node of the octree; initialize the vertex count, position weight and candidate sampling point information of each leaf node;
[0017] Reading the position information of the spatial point in the spatial file, and for each leaf grid block, determining whether the spatial point belongs to the grid space range of the leaf grid block;
[0018] If yes, then the vertex count of the leaf node is increased by 1, and the position weight sum of the leaf node is added to the position information of the spatial point to update the position weight sum of the leaf node;
[0019] Get the vertex count of the leaf node;
[0020] If the vertex count of the leaf node is equal to 1, the spatial point is used as a candidate sampling point, and then the position information of the next spatial point in the spatial file is read;
[0021] If the vertex count of the leaf node is greater than 1, the average weight position of the leaf grid block is calculated based on the position weight sum of the leaf node and the vertex count of the leaf node, and a first distance from the spatial point to the average weight position is compared with a second distance from the candidate sampling point to the average weight position;
[0022] If the first distance is smaller than the second distance, the spatial point is used as a new candidate sampling point, and then the position information of the next spatial point in the spatial file is read;
[0023] When all the spatial points contained in the leaf grid blocks are read, the candidate sampling points are used as target sampling points of the leaf grid blocks.
[0024] Optionally, in a third implementation of the first aspect of the present invention,
[0025] After obtaining the vertex count of the leaf node, if the vertex count of the leaf node is equal to 1, further comprising:
[0026] Add 1 to the vertex counts of all non-leaf nodes in the upper layer of the leaf node, and add the sum of the position weights of the non-leaf nodes in the upper layer of the leaf node to the position information of the spatial point to update the sum of the position weights of the non-leaf nodes in the upper layer of the leaf node;
[0027] If the vertex count of the leaf node is greater than 1, and the first distance is less than the second distance, the method further includes:
[0028] The position weight sum of all non-leaf nodes in the upper layer of the leaf node is subtracted from the position information of the candidate sampling point and added to the position information of the spatial point to update the position weight sum of each non-leaf node in the upper layer of the leaf node.
[0029] Optionally, in a fourth implementation of the first aspect of the present invention, after acquiring and dividing the first point cloud data to obtain a spatial file, the method further includes:
[0030] Calculating the number of first spatial points included in each spatial file, and determining a counting threshold based on the number of first spatial points;
[0031] After reading the position information of the spatial point in the spatial file, the method further includes:
[0032] Recording the number of second spatial points of the spatial points that have been read in each leaf grid block;
[0033] When the sum of the numbers of the second spatial points in each of the leaf grid blocks meets the counting threshold, it is considered that all the spatial points contained in each of the leaf grid blocks have been read.
[0034] Optionally, in a fifth implementation of the first aspect of the present invention, generating sampled second point cloud data based on the target sampling point includes:
[0035] Get the number of target sampling points contained in the grid block corresponding to each node in the octree;
[0036] According to the number of target sampling points contained in the grid blocks corresponding to each node and the preset thinning ratio, starting from the root node of the octree, the number of target extraction points in the grid blocks corresponding to each node in the octree is calculated layer by layer until a grid block with a target extraction point of 1 is selected as the target grid block;
[0037] Taking the non-leaf node corresponding to the target grid block as the target node;
[0038] Traversing all leaf nodes in the lower layer of the target node, and filtering out the spatial point closest to the average weight position of the target grid block according to the sum of the position weights corresponding to each node in the octree, and updating the target sampling point corresponding to the target grid block;
[0039] Generate second point cloud data after sparse sampling based on the updated target sampling points.
[0040] A second aspect of the present invention provides a point cloud data sampling device, comprising:
[0041] An acquisition module, used for acquiring and dividing the first point cloud data to obtain a spatial file, wherein the number of the spatial files is multiple;
[0042] A partitioning module, used for partitioning each of the spatial files into a plurality of grid blocks based on an octree partitioning method;
[0043] A sampling module, used to read the position information of the spatial points contained in each of the spatial files, calculate the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filter the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks;
[0044] A generating module is used to generate sampled second point cloud data based on the target sampling point.
[0045] The third aspect of the present invention provides a point cloud data sampling device, comprising: a memory and at least one processor, wherein the memory stores instructions; the at least one processor calls the instructions in the memory so that the point cloud data sampling device executes the steps of the above-mentioned point cloud data sampling method.
[0046] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the above-mentioned point cloud data sampling method.
[0047] A fifth aspect of the present invention provides a computer program product, comprising a computer program / instruction, characterized in that when the computer program / instruction is executed by a processor, the steps of the point cloud data sampling method as described above are implemented.
[0048] In the technical solution provided by the present invention, the first point cloud data is obtained and divided to obtain a spatial file, wherein the number of spatial files is multiple; each spatial file is divided into multiple grid blocks based on the octree partitioning method; the position information of the spatial points contained in each spatial file is read, the average weight position of the spatial points in the leaf grid block corresponding to the leaf node of the octree is calculated, the spatial points in the leaf grid block are screened based on the average weight position, and the target sampling points of the leaf grid block are obtained; the sampled second point cloud data is generated based on the target sampling points. This method can better retain the data features of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption. At the same time, a device, an electronic device, a computer-readable storage medium and a computer program product provided by the present invention also solve corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0050] Figure 1 It is a flowchart of a first embodiment of a method for sampling point cloud data in an embodiment of the present invention;
[0051] Figure 2 A schematic diagram of an octree structure of a first embodiment of a method for sampling point cloud data in an embodiment of the present invention;
[0052] Figure 3 It is a flow chart of a second embodiment of the method for sampling point cloud data in an embodiment of the present invention;
[0053] Figure 4 A schematic diagram of a flow chart of a part of determining candidate sampling points in a second embodiment of a method for sampling point cloud data in an embodiment of the present invention;
[0054] Figure 5 1 is a flow chart of a third embodiment of a method for sampling point cloud data according to an embodiment of the present invention;
[0055] Figure 6 A schematic diagram of generating a spatial bounding box in a third embodiment of the method for sampling point cloud data in an embodiment of the present invention;
[0056] Figure 7 A schematic diagram of generating a spatial file in a third embodiment of a method for sampling point cloud data in an embodiment of the present invention;
[0057] Figure 8 It is a schematic diagram of a specific implementation method of extracting target sampling points and updating an octree according to a thinning ratio in a third embodiment of a sampling method for point cloud data in an embodiment of the present invention;
[0058] Fig. 9 A schematic diagram of an embodiment of sampling of point cloud data in an embodiment of the present invention;
[0059] Fig.10 A schematic diagram of an embodiment of a point cloud data sampling device in an embodiment of the present invention;
[0060] Fig.11 The figure is a schematic diagram of a computer-readable medium in an embodiment of the present invention. DETAILED DESCRIPTION
[0061] Exemplary embodiments of the present invention will now be described more fully with reference to the accompanying drawings. However, exemplary embodiments can be implemented in a variety of forms, and should not be construed as limiting the present invention to the embodiments set forth herein. On the contrary, providing these exemplary embodiments enables the present invention to be more comprehensive and complete, and is more convenient for fully conveying the inventive concept to those skilled in the art. The same reference numerals in the figures represent the same or similar elements, components or parts, and thus their repeated description will be omitted.
[0062] Under the premise of being consistent with the technical concept of the present invention, the features, structures, characteristics or other details described in a specific embodiment do not exclude that they can be combined in one or more other embodiments in a suitable manner.
[0063] In the description of specific embodiments, the features, structures, characteristics or other details described in the present invention are intended to enable those skilled in the art to fully understand the embodiments. However, it does not exclude that those skilled in the art can practice the technical solutions of the present invention without one or more of the specific features, structures, characteristics or other details.
[0064] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0065] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0066] The term "and / or" or "and / or" includes all combinations of any one or more of the associated listed items.
[0067] See also Figure 1-Figure 2, a first embodiment of a method for sampling point cloud data in an embodiment of the present invention includes:
[0068] S101, acquiring and dividing first point cloud data to obtain a spatial file;
[0069] It is understandable that the execution subject of the present invention may be a sampling device for point cloud data, or a terminal or a server, which is not limited here. The embodiment of the present invention is described by taking a server as the execution subject as an example.
[0070] In this embodiment, in order to distinguish the point cloud data from the sampled point cloud data, the point cloud data that needs to be sampled is called the first point cloud data, and the point cloud data obtained after sampling is called the second point cloud data; "first" and "second" are only used as expressions to indicate the difference and should not be regarded as order or other restrictions.
[0071] When receiving the sampling request, the server obtains the file of the point cloud data to be sampled, wherein the file may be the original point cloud data file. After obtaining the first point cloud data, the first point cloud data is first divided into multiple copies, and the first point cloud data in the spatial range corresponding to each copy is used as a spatial file, that is, the number of spatial files generated by the first point cloud data division may be multiple. After the first point cloud file is divided into multiple spatial files, multiple specific sampling threads may be called to process each spatial file independently.
[0072] In a specific implementation, when performing the division, a preset division space size may be obtained, and the number of spatial files obtained by the division is determined according to the spatial range of the first point cloud data and the division space size. Further, when generating the spatial file, each generated spatial file contains the spatial points of the first point cloud data, and if there is no data point within the preset division space size range, no spatial file is generated.
[0073] S102, dividing each spatial file into a plurality of grid blocks based on an octree partitioning method;
[0074] For each spatial file, its range is divided into multiple grid blocks by the octree partitioning method, where see Figure 2 Octree is a tree-shaped data structure, each internal node has exactly eight child nodes, which is often used to divide three-dimensional space and recursively subdivide the three-dimensional space into eight quadrants. In a specific implementation, when dividing each space file according to the octree, the preset thinning space size is obtained as the space size when the octree is divided into the smallest grid block, and the octree structure is divided into the smallest grid block, and the smallest grid block is the grid block corresponding to the leaf node of the octree.
[0075] S103, reading the position information of the spatial points contained in each spatial file, calculating the average weighted position of the spatial points in the leaf grid block corresponding to the leaf node of the octree, and filtering the spatial points in the leaf grid block based on the average weighted position to obtain the target sampling point of the leaf grid block;
[0076] After the grid blocks are divided in the above steps, a specific sampling step is performed on each smallest grid block, that is, a point is screened or calculated in the leaf grid block corresponding to each leaf node of the octree to describe the position information of the leaf grid block.
[0077] In one embodiment, spatial points can be selected as target sampling points based on the average weighted positions of the spatial points contained in the leaf grid blocks to describe the position information of the spatial points in the leaf grid blocks. Specifically, the position information of the spatial points contained in each spatial file is first read, and the spatial point information contained in each leaf grid block is determined according to the range information of each leaf grid block corresponding to the leaf node of the octree, and then the average weighted position of the spatial points in each leaf grid block is calculated according to the spatial point information contained in each leaf grid block, and the closest spatial point in the leaf grid block is selected as the target sampling point of the leaf grid block based on the average weighted position.
[0078] S104: Generate sampled second point cloud data based on the target sampling point.
[0079] After all the spatial points in each leaf grid block are traversed and the target sampling points of each leaf grid block are obtained, the sampled second point cloud data are generated according to the target sampling points as the point cloud data to be saved.
[0080] Based on the above scheme, the method provided in the embodiment of the present invention can sample and process the point cloud data to simplify it, and can better retain the data characteristics of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption.
[0081] Please see Figure 3-Figure 4 , a second embodiment of the method for sampling point cloud data in an embodiment of the present invention includes:
[0082] S201, acquiring and dividing first point cloud data to obtain a spatial file;
[0083] In this embodiment, there are multiple space files; the specific division method is basically the same as the content in step S101 in the above embodiment, so it will not be repeated here.
[0084] S202, dividing each spatial file into a plurality of grid blocks based on an octree partitioning method;
[0085] Based on the octree partitioning method, firstly, a preset thinning space size is obtained, and each space file is divided into multiple grid blocks based on the thinning space size, wherein the grid block corresponding to the leaf node of the octree is called a leaf grid block; the preset thinning space size refers to the size range that the smallest grid block needs to meet when the octree is used to divide the grid block, that is, the octree is used to divide into the smallest grid block, so that the smallest grid block is not larger than the thinning space size, and the grid space range of the leaf grid block corresponding to the leaf node of the octree is obtained.
[0086] In a specific implementation, after obtaining the smallest grid block of the octree based on a preset thinning space size, the division of the grid block can also be adjusted according to a specific sampling file storage scheme; that is, although the grid block can be divided and determined according to the thinning space size, it is not limited by the thinning space size, so as to improve sampling efficiency; and the specific division scheme will not be repeated here.
[0087] S203, for each leaf grid block corresponding to a leaf node, read the position information of the spatial points contained in each spatial file, calculate the average weight position of the spatial points in the leaf grid block corresponding to the leaf node of the octree, and filter the spatial points in the leaf grid block based on the average weight position to obtain candidate sampling points of the leaf grid block;
[0088] S204, when all the spatial points contained in each leaf grid block are read, each candidate sampling point is used as the target sampling point of each leaf grid block;
[0089] After the grid blocks are divided, a specific sampling step is performed on each smallest grid block, that is, a point is screened or calculated in the leaf grid block corresponding to each leaf node of the octree to describe the position information of the leaf grid block.
[0090] In a specific implementation, the specific sampling step is performed for each leaf grid block, so it is first necessary to obtain the grid space range of the leaf grid block corresponding to the leaf node of the octree.
[0091] See also Figure 4 Next, a specific execution example is used to illustrate how to obtain the target sampling points in each leaf grid block:
[0092] First, the vertex count n, position weight and w of each octree node and the corresponding candidate sampling point information p of each leaf node are initialized. In a specific implementation, n=0, w=0, and p is empty during initialization. Then, the leaf grid block corresponding to the leaf node currently to be processed is selected, and the grid space range of the leaf grid block is obtained.
[0093] Traverse and read the position information of the spatial points in the spatial file to which the current octree belongs. For each leaf grid block, determine whether the currently selected spatial point belongs to the grid space range of the current leaf grid block. If the currently selected spatial point does not belong to the grid space range of the current leaf grid block, discard the current spatial point position information q and continue to read the next spatial point; if the currently selected spatial point belongs to the grid space range of the current leaf grid block, add 1 to the vertex count of the leaf node, that is, set the current leaf node's n = n + 1; and add the leaf node's position weight sum to the spatial point's position information to update the leaf node's position weight sum, that is, set the current leaf node's position weight sum w = w + q.
[0094] Get the vertex count n of the leaf node, and determine whether the vertex count n of the current leaf grid block is 1; if the vertex count n of the current leaf node is equal to 1, use the current spatial point as an alternative sampling point, that is, let p = q. Then return to the step of traversing and reading the position information of the spatial point in the spatial file to which the current octree belongs, and read the next spatial point. In a specific embodiment, this step also includes adding 1 to the vertex count of all non-leaf nodes above the current leaf node, and making the sum of the position weights w of all non-leaf nodes above the current leaf node = w + q.
[0095] After obtaining the next spatial point in sequence, it is also determined whether the spatial point belongs to the grid space range of the current leaf grid block. If it does not belong to the grid space range of the current leaf grid block, it is discarded; if it does, the vertex count n of the current leaf node is set to n+1, and the position weight sum w of the current leaf node is set to w+q. And continue to determine whether the vertex count n of the current leaf grid block is greater than 1. If the vertex count of the current leaf node is greater than 1, the average weight position c of the leaf grid block is calculated based on the position weight sum w of the leaf node and the vertex count n of the leaf node, and the expression is c=w / n; and compare the first distance from the current spatial point q to the average weight position c with the second distance from the alternative sampling point p to the average weight position c.
[0096] If the first distance is not less than the second distance, the position information q of the current spatial point is discarded, and the next spatial point is read. If the first distance is less than the second distance, the spatial point is used as a new candidate sampling point; then the position information of the next spatial point in the spatial file is read. In a specific embodiment, if the first distance is less than the second distance, before the spatial point is used as a new candidate sampling point, the position weights of all non-leaf nodes above the current leaf node are subtracted from the position information of the candidate sampling point and added to the position information of the spatial point, that is, the position weights of the non-leaf nodes are set to w = w-p + q, and the vertex counts n of the non-leaf nodes above the current leaf node are kept unchanged.
[0097] Next, it is determined whether all the spatial points in the leaf grid block corresponding to the current leaf node have been read. In a specific implementation, after obtaining the spatial range of the current leaf grid block, it also includes obtaining the number of spatial points contained in the spatial range of the current leaf grid block. When the vertex count n of the leaf node has not reached the number of spatial points contained in the spatial range of the current leaf grid block, the spatial points in the spatial file continue to be read; when the vertex count n of the leaf node reaches the number of spatial points contained in the spatial range of the current leaf grid block, it is considered that the spatial points in the current leaf grid block have been read, and the next leaf grid block is replaced to continue processing as described above. Specifically, after the spatial points in the current leaf grid block have been read, it is also determined whether the spatial points contained in the current spatial file have been read. If not, the next leaf grid block is replaced to continue processing as described above. If all the spatial points contained in the spatial file have been read, it ends.
[0098] If all the spatial points contained in the leaf grid blocks in the current spatial file have been read, the candidate sampling points stored in each leaf grid block are used as the target sampling points of each leaf grid block.
[0099] In one embodiment, after the spatial files are divided, the method further includes calculating the number of first spatial points contained in each spatial file and determining a counting threshold based on the number of first spatial points; in the step of judging whether the spatial points contained in the current spatial file have been read, after reading the position information of the spatial points in the spatial file, the method further includes: recording the number of second spatial points of the spatial points that have been read in each leaf grid block; when the sum of the number of second spatial points in each leaf grid block meets the counting threshold, it is considered that the spatial points contained in each leaf grid block have been read.
[0100] Specifically, the vertex count n of the root node corresponding to the spatial file may be obtained, and it may be determined whether the vertex count n of the root node satisfies the counting threshold. If the counting threshold is satisfied, it is considered that all spatial points contained in each leaf grid block have been read.
[0101] S205: Generate sampled second point cloud data based on the target sampling point.
[0102] After all the spatial points in each leaf grid block or in the spatial file have been traversed and the target sampling points of each leaf grid block have been obtained, the sampled second point cloud data is generated according to the target sampling points as the point cloud data to be saved. In this way, the method of recording the dynamic weight center in each leaf grid block can remove noise points while retaining the feature details of the point cloud. Compared with the technical solution of directly using the centroid point of the leaf grid block as the sampling point, it can avoid the situation where the centroid point is the noise point, and improve the accuracy of the streamlined point cloud file.
[0103] Based on the above scheme, the method provided in the embodiment of the present invention can sample and process the point cloud data to simplify it, and can better retain the data characteristics of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption.
[0104] Please see Figure 5-Figure 8 , a second embodiment of the method for sampling point cloud data in an embodiment of the present invention includes:
[0105] S301, acquiring and dividing first point cloud data to obtain a spatial file;
[0106] In this embodiment, the first point cloud data may be point cloud data of a large target scene, and a large target scene is usually grouped in space and scanned multiple times. During the grouped scanning process, point cloud data of adjacent scanning areas will be repeated in multiple files. Therefore, it is necessary to pre-process the point cloud data in these files and then perform sampling to filter out repeated sampling in overlapping areas.
[0107] See also Figure 4 as well as Figure 5 , the first point cloud data can be obtained by reading multiple original scan files of the target scene, and a spatial bounding box can be generated based on the position information of each spatial point in the first point cloud data. After obtaining the spatial bounding box, the preset division space size is obtained, and multiple spatial files are generated according to the spatial range of the first point cloud data and the division space size. In this step, the method of reading files in batches multiple times instead of reading all file data into the memory at one time and then dividing them can reduce the memory usage in the multi-file space merging and division stage.
[0108] In a specific implementation, when reading multiple original scan files of a target scene, the point data of each spatial point in the original scan file is only used to calculate the spatial bounding box and is discarded after reading to reduce resource usage.
[0109] The specific division method is substantially the same as that in step S101 in the aforementioned embodiment, and thus will not be described in detail here.
[0110] Furthermore, in this embodiment, after the divided spatial file is obtained, the point information of all point cloud files will be traversed again. If this point belongs to a certain spatial file, the point count of this point cloud file in the corresponding spatial file will be increased. After recording the data, the point information will be discarded only to obtain the number of spatial points in each spatial file. This is done so that when the subsequent processing traversal is performed, if the number of points processed in the current spatial file has reached the total number of points contained in the spatial file, it can be quickly exited without traversing the entire file.
[0111] S302, dividing each space file into a plurality of grid blocks based on an octree partitioning method;
[0112] S303, reading the position information of the spatial points contained in each spatial file, calculating the average weighted position of the spatial points in the leaf grid block corresponding to the leaf node of the octree, and filtering the spatial points in the leaf grid block based on the average weighted position to obtain the target sampling point of the leaf grid block;
[0113] The contents of step S302 and step S303 in this embodiment are substantially the same as the contents of steps S202 to S204 in the aforementioned embodiment, and thus will not be described in detail herein.
[0114] S304, obtaining a preset thinning ratio, and updating the grid blocks and target sampling points in each spatial file according to the preset thinning ratio;
[0115] S305: Generate second point cloud data after thinning sampling based on the updated target sampling points and the preset thinning ratio.
[0116] In this embodiment, when generating the sampled second point cloud data, a sampling scheme based on LOD (Level of Details) technology is also included, which can generate multiple different second point cloud data in proportion according to different observation requirements, and the sum of these second point cloud data can still show the scene details of the first point cloud data. In this way, it can be realized that when observing data from far to near, it can be loaded step by step, instead of waiting for the complete data block to be downloaded before displaying all the point cloud data. In a specific implementation, multiple second point cloud data can be generated according to different thinning ratios, for example, three second point cloud data files are generated at ratios of 20%, 30%, and 50% respectively; when displayed from far to near, the second point cloud data file corresponding to the thinning ratio of 20% can be first obtained for display with lower accuracy. If more detailed observation is required, the second point cloud data file corresponding to the thinning ratio of 30% can be continuously obtained, and further display can be performed according to the second point cloud data file corresponding to the thinning ratio of 30% or the second point cloud data file corresponding to the thinning ratio of 20% and the second point cloud data file corresponding to the thinning ratio of 30%, thereby increasing the display accuracy. When generating, spatial points are extracted according to the ratio of the second point cloud data to be generated, and specific sampling operations are performed.
[0117] After obtaining the target sampling points of the leaf grid blocks in the above steps, the number of target sampling points contained in the grid blocks corresponding to each node in the octree is obtained; wherein the number of target sampling points can be obtained according to the vertex count recorded in the octree node. Subsequently, a preset thinning ratio is obtained, and according to the number of target sampling points contained in the grid blocks corresponding to each node and the preset thinning ratio, the number of target extraction points in the grid blocks corresponding to each node in the octree is calculated layer by layer starting from the root node of the octree, until a grid block with a target extraction point of 1 is selected as the target grid block.
[0118] See also Figure 8 In a specific implementation, for each spatial file, according to the characteristics of the octree, the number of points contained in each non-leaf node in the octree is the sum of the number of points contained in the nodes of the next layer. Therefore, according to the number of target sampling points contained in the spatial file and the thinning ratio, the number of target sampling points that need to be extracted in the initial grid block corresponding to each node in the octree is calculated layer by layer starting from the root node of the octree, that is, the target number of extracted points. Specifically, by taking the number of points contained in the nodes of the next layer of this node as the proportion in the parent node as the weight, the target number of extracted points that should be extracted from each subordinate node can be calculated.
[0119] Please continue reading Figure 8 , when the number of target sampling points contained in the spatial file is 1000 and the thinning ratio is 20%, it can be known that when the second point cloud file corresponding to the thinning ratio of 20% needs to be generated, 200 target sampling points need to be extracted from the spatial grid corresponding to the root node of the octree; in the case of uniform extraction, in the child nodes of the next layer of the root node of the octree, the non-leaf nodes that originally contained 300 target sampling points need to extract 50 target sampling points; in this way, each layer is thinned downward according to the weight until a grid block with at least one target sampling point to be extracted is found as the target grid block, and the non-leaf nodes corresponding to the target grid block are used as target nodes. For example, in Figure 8 In a specific example represented in , those non-leaf nodes with n=6 are obtained; the grid blocks with the number of points to be extracted being 1 are obtained, and the nodes corresponding to these grid blocks are modified to leaf nodes, and these grid blocks are used as leaf grid blocks corresponding to new leaf nodes; that is, Figure 8 The original leaf node shown by the dotted line is discarded, and the parent node of the original leaf node shown by the dotted line is used as the new leaf node.
[0120] Then, the node information of the target node is updated, and the octree and each grid block are updated based on the leaf grid blocks corresponding to these new leaf nodes; in a specific implementation, when updating the node information of the target node, if the number of nodes to be extracted is calculated to be 1, all leaf nodes below this node are traversed, and the point with the average weight position closest to the target node is selected; at the same time, the selected child node is deleted, and all parent nodes of the upper layer of the deleted child node are recursively updated, so that the vertex count of all parent nodes of the upper layer of the child node is increased by 1, that is, the vertex count n=n+1. Among them, when traversing all leaf nodes under the deleted child node and selecting the point with the average weight position closest to the target node, the position weight and vertex count of the current target node record are obtained, so as to calculate the average weight position; when screening the point with the average weight position closest to the target node, the screening can be based on steps similar to steps S202-S204 in the aforementioned embodiment, which will not be repeated here.
[0121] Based on the same method as above, multiple second point cloud data corresponding to various preset thinning ratios are calculated; that is, when dividing the data for the thinning minimum space of each block, only one vertex is retained at the same time to reduce memory occupancy; subsequently, the multiple second point cloud data can be obtained according to display requirements to display the point cloud scene.
[0122] Based on the above scheme, the method provided in the embodiment of the present invention can sample and process the point cloud data to streamline it and reduce the required computer memory resources. It can better retain the original data characteristics of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption. Moreover, in this embodiment, before performing specific sampling, the original scan files of multiple point clouds will be read and the bounding boxes will be calculated to reduce the waste of resources caused by repeatedly reading overlapping information in the original scan files. At the same time, in this embodiment, it is also possible to generate second point cloud data corresponding to multiple ratios based on a preset thinning ratio, and further sample and process the point cloud data according to different display requirements to streamline it, thereby reducing the resource usage under different display requirements and improving the display effect under different display requirements.
[0123] The above describes the sampling method of point cloud data in the embodiment of the present invention. The following describes the sampling device of point cloud data in the embodiment of the present invention. Fig. 9 , an embodiment of a sampling device for point cloud data in an embodiment of the present invention includes:
[0124] An acquisition module 901 is used to acquire and divide the first point cloud data to obtain a spatial file, wherein the number of the spatial files is multiple;
[0125] A partitioning module 902, configured to partition each of the spatial files into a plurality of grid blocks based on an octree partitioning method;
[0126] The sampling module 903 is used to read the position information of the spatial points contained in each of the spatial files, calculate the average weight position of the spatial points in the leaf grid block corresponding to the leaf node of the octree, and filter the spatial points in the leaf grid block based on the average weight position to obtain the target sampling point of the leaf grid block;
[0127] The generating module 904 is used to generate the sampled second point cloud data based on the target sampling point.
[0128] A device provided in an embodiment of the present invention can sample and process point cloud data to simplify it, and can better retain the data features of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption.
[0129] In another embodiment of the present application, the acquisition module 901 is specifically used for:
[0130] Read multiple original scan files of the target scene to obtain first point cloud data;
[0131] Generate a spatial bounding box based on the position information of each spatial point in the first point cloud data;
[0132] The spatial bounding box is divided into a plurality of spatial ranges, and a plurality of spatial files are generated based on the spatial point information contained in each of the spatial ranges.
[0133] In another embodiment of the present application, the sampling module 903 is further configured to:
[0134] Get the grid space range of the leaf grid block corresponding to the leaf node of the octree; initialize the vertex count, position weight and candidate sampling point information of each leaf node;
[0135] Reading the position information of the spatial point in the spatial file, and for each leaf grid block, determining whether the spatial point belongs to the grid space range of the leaf grid block;
[0136] If yes, then the vertex count of the leaf node is increased by 1, and the position weight sum of the leaf node is added to the position information of the spatial point to update the position weight sum of the leaf node;
[0137] Get the vertex count of the leaf node;
[0138] If the vertex count of the leaf node is equal to 1, the spatial point is used as a candidate sampling point, and then the position information of the next spatial point in the spatial file is read;
[0139] If the vertex count of the leaf node is greater than 1, the average weight position of the leaf grid block is calculated based on the position weight sum of the leaf node and the vertex count of the leaf node, and a first distance from the spatial point to the average weight position is compared with a second distance from the candidate sampling point to the average weight position;
[0140] If the first distance is smaller than the second distance, the spatial point is used as a new candidate sampling point, and then the position information of the next spatial point in the spatial file is read;
[0141] When all the spatial points contained in the leaf grid blocks are read, the candidate sampling points are used as target sampling points of the leaf grid blocks.
[0142] In another embodiment of the present application, the sampling module 903 is further configured to:
[0143] After obtaining the vertex count of the leaf node, if the vertex count of the leaf node is equal to 1, add 1 to the vertex count of all non-leaf nodes in the upper layer of the leaf node, and add the position weight sum of the non-leaf nodes in the upper layer of the leaf node to the position information of the spatial point to update the position weight sum of each non-leaf node in the upper layer of the leaf node;
[0144] If the vertex count of the leaf node is greater than 1 and the first distance is less than the second distance, the position weight sum of all non-leaf nodes above the leaf node is subtracted from the position information of the alternative sampling point and added to the position information of the spatial point to update the position weight sum of all non-leaf nodes above the leaf node.
[0145] In another embodiment of the present application, the acquisition module 901 is further used for:
[0146] Calculating the number of first spatial points included in each spatial file, and determining a counting threshold based on the number of first spatial points;
[0147] The sampling module 903 is also specifically used for:
[0148] Recording the number of second spatial points of the spatial points that have been read in each leaf grid block;
[0149] When the sum of the numbers of the second spatial points in each of the leaf grid blocks meets the counting threshold, it is considered that all the spatial points contained in each of the leaf grid blocks have been read.
[0150] In another embodiment of the present application, the generating module 904 is further configured to:
[0151] Get the number of target sampling points contained in the grid block corresponding to each node in the octree;
[0152] According to the number of target sampling points contained in the grid blocks corresponding to each node and the preset thinning ratio, starting from the root node of the octree, the number of target extraction points in the grid blocks corresponding to each node in the octree is calculated layer by layer until a grid block with a target extraction point of 1 is selected as the target grid block;
[0153] Taking the non-leaf node corresponding to the target grid block as the target node;
[0154] Traversing all leaf nodes in the lower layer of the target node, and filtering out the spatial point closest to the average weight position of the target grid block according to the sum of the position weights corresponding to each node in the octree, and updating the target sampling point corresponding to the target grid block;
[0155] Generate second point cloud data after sparse sampling based on the updated target sampling points.
[0156] The embodiment of the present invention can perform sampling processing on the point cloud data to simplify it, and can better retain the data characteristics of the point cloud and reduce the loss of details while solving various problems such as data storage, transmission, processing speed and memory consumption; and, in this embodiment, before performing specific sampling, the original scan files of multiple point clouds are read and the bounding boxes are calculated, so as to reduce the waste of resources caused by repeated reading of overlapping information in the original scan files; at the same time, in this embodiment, it is also possible to generate second point cloud data corresponding to multiple ratios based on a preset thinning ratio, and further perform sampling processing on the point cloud data according to different display requirements to simplify it, thereby reducing the resource usage under different display requirements and improving the display effect under different display requirements.
[0157] Based on the same inventive concept, an embodiment of the present specification also provides an electronic device for sampling point cloud data. The electronic device for sampling point cloud data in an embodiment of the present invention is described in detail below from the perspective of hardware processing.
[0158] Fig.10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. Fig.10 The electronic device 1000 according to this embodiment of the present invention is described. Fig.10 The electronic device 1000 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0159] like Fig.10As shown, the electronic device 1000 is in the form of a general computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), a display unit 1040, etc.
[0160] The storage unit stores a program code, which can be executed by the processing unit 1010, so that the processing unit 1010 performs the steps of various exemplary embodiments of the present invention described in the above processing method section of this specification. For example, the processing unit 1010 can perform the following steps: Figure 1 or Figure 3-5 Steps shown.
[0161] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 10201 and / or a cache memory unit 10202 , and may further include a read-only memory unit (ROM) 10203 .
[0162] The storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.
[0163] Bus 1030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0164] The electronic device 1000 may also communicate with one or more external devices 100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), one or more devices that enable a user to interact with the electronic device 1000, and / or any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed through an input / output (I / O) interface 1050. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 1060. The network adapter 1060 may communicate with other modules of the electronic device 1000 through the bus 1030. It should be understood that although Fig.10Not shown, other hardware and / or software modules may be used in conjunction with electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0165] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the exemplary embodiments described in the present invention can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation method of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.) or on a network, including a number of instructions to enable a computing device (which can be a personal computer, server, or network device, etc.) to execute the above method according to the present invention. When the computer program is executed by a data processing device, the computer-readable medium can implement the above method of the present invention, that is: Figure 1 or Figure 3-5 The method shown.
[0166] Fig.11 A schematic diagram of a computer-readable medium provided for an embodiment of this specification.
[0167] accomplish Figure 1 or Figure 3-5 The computer program of the method shown can be stored on one or more computer readable media. The computer readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0168] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0169] In addition, the present invention also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the point cloud data sampling method described in any of the above embodiments.
[0170] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0171] In summary, the present invention can be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that general data processing devices such as microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0172] The specific embodiments described above further describe the purpose, technical solutions and beneficial effects of the present invention in detail. It should be understood that the present invention is not inherently related to any specific computer, virtual device or electronic device, and various general devices can also implement the present invention. The above description is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0173] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0174] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for sampling point cloud data, characterized in that: include: Acquire and divide the first point cloud data to obtain a spatial file, wherein the number of the spatial files is multiple; Dividing each of the spatial files into a plurality of grid blocks based on an octree partitioning method; Reading the position information of the spatial points contained in each of the spatial files, calculating the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filtering the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks; Generate sampled second point cloud data based on the target sampling point.
2. The point cloud data sampling method according to claim 1, characterized in that: The obtaining and dividing the first point cloud data to obtain a spatial file includes: Read multiple original scan files of the target scene to obtain first point cloud data; Generate a spatial bounding box based on the position information of each spatial point in the first point cloud data; The spatial bounding box is divided into a plurality of spatial ranges, and a plurality of spatial files are generated based on the spatial point information contained in each of the spatial ranges.
3. The point cloud data sampling method according to claim 2, characterized in that: The step of reading the position information of the spatial points contained in each of the spatial files, calculating the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filtering the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks comprises: Get the grid space range of the leaf grid block corresponding to the leaf node of the octree; Initialize the vertex count, position weight and candidate sampling point information of each leaf node; Reading the position information of the spatial point in the spatial file, and for each leaf grid block, determining whether the spatial point belongs to the grid space range of the leaf grid block; If yes, then the vertex count of the leaf node is increased by 1, and the position weight sum of the leaf node is added to the position information of the spatial point to update the position weight sum of the leaf node; Get the vertex count of the leaf node; If the vertex count of the leaf node is equal to 1, the spatial point is used as a candidate sampling point, and then the position information of the next spatial point in the spatial file is read; If the vertex count of the leaf node is greater than 1, the average weight position of the leaf grid block is calculated based on the position weight sum of the leaf node and the vertex count of the leaf node, and a first distance from the spatial point to the average weight position is compared with a second distance from the candidate sampling point to the average weight position; If the first distance is smaller than the second distance, the spatial point is used as a new candidate sampling point, and then the position information of the next spatial point in the spatial file is read; When all the spatial points contained in the leaf grid blocks are read, the candidate sampling points are used as target sampling points of the leaf grid blocks.
4. The point cloud data sampling method according to claim 3, characterized in that: After obtaining the vertex count of the leaf node, if the vertex count of the leaf node is equal to 1, further comprising: Add 1 to the vertex counts of all non-leaf nodes in the upper layer of the leaf node, and add the sum of the position weights of the non-leaf nodes in the upper layer of the leaf node to the position information of the spatial point to update the sum of the position weights of the non-leaf nodes in the upper layer of the leaf node; If the vertex count of the leaf node is greater than 1, and the first distance is less than the second distance, the method further includes: The position weight sum of all non-leaf nodes in the upper layer of the leaf node is subtracted from the position information of the candidate sampling point and added to the position information of the spatial point to update the position weight sum of each non-leaf node in the upper layer of the leaf node.
5. The point cloud data sampling method according to claim 3 or 4, characterized in that: After acquiring and dividing the first point cloud data to obtain a spatial file, the method further includes: Calculating the number of first spatial points included in each spatial file, and determining a counting threshold based on the number of first spatial points; After reading the position information of the spatial point in the spatial file, the method further includes: Recording the number of second spatial points of the spatial points that have been read in each leaf grid block; When the sum of the numbers of the second spatial points in each of the leaf grid blocks meets the counting threshold, it is considered that all the spatial points contained in each of the leaf grid blocks have been read.
6. The point cloud data sampling method according to claim 5, characterized in that: The generating of the sampled second point cloud data based on the target sampling point comprises: Get the number of target sampling points contained in the grid block corresponding to each node in the octree; According to the number of target sampling points contained in the grid blocks corresponding to each node and the preset thinning ratio, starting from the root node of the octree, the number of target extraction points in the grid blocks corresponding to each node in the octree is calculated layer by layer until a grid block with a target extraction point of 1 is selected as the target grid block; Taking the non-leaf node corresponding to the target grid block as the target node; Traversing all leaf nodes in the lower layer of the target node, and filtering out the spatial point closest to the average weight position of the target grid block according to the sum of the position weights corresponding to each node in the octree, and updating the target sampling point corresponding to the target grid block; Generate second point cloud data after sparse sampling based on the updated target sampling points.
7. A point cloud data sampling device, characterized in that: include: An acquisition module, used for acquiring and dividing the first point cloud data to obtain a spatial file, wherein the number of the spatial files is multiple; A partitioning module, used for partitioning each of the spatial files into a plurality of grid blocks based on an octree partitioning method; A sampling module, used to read the position information of the spatial points contained in each of the spatial files, calculate the average weighted position of the spatial points in the leaf grid blocks corresponding to the leaf nodes of the octree, and filter the spatial points in the leaf grid blocks based on the average weighted position to obtain the target sampling points of the leaf grid blocks; A generating module is used to generate sampled second point cloud data based on the target sampling point.
8. A point cloud data sampling device, characterized in that: The point cloud data sampling device comprises: a memory and at least one processor, wherein instructions are stored in the memory; The at least one processor calls the instructions in the memory to enable the point cloud data sampling device to perform the steps of the point cloud data sampling method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the program / instructions are executed by a processor, the steps of the point cloud data sampling method according to any one of claims 1 to 6 are implemented.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the point cloud data sampling method according to any one of claims 1 to 6 are implemented.