To extract the data from the voxels after the application of the voxel grid on the point cloud, we needed to use combination of methods already offered by the PCL VoxelGrid class. Here are the steps to getting the correct points:
1. Apply the Voxel Grid to the cloud
2. Get the grid coordinates of each point in the cloud (this will return the coordinates of a centroid for that point)
3. Using the centroid's coordinates, get the index of centroid in the filtered cloud
4. Using the centroid, we are able to determine which points are in each voxel
To save the information from created by the voxel grid, I created another data structure called voxel, which saves the centroid of that particular voxel, the points located in that centroid, and the corresponding planes of each point in that voxel.
*** Update: I was able to accomplish this, but it did not turn out like I hoped.
Here's the situation:
Files:
- Registration.h - voxel function is in this header file; also computes normals for each plane
- Segmentation - header file where planes are being extracted from point clouds
- trans.cpp - main file where the point clouds are being loaded from files, planes are being divided into planes, and points in the planes are being divided into voxels
Commands:
cmake . && make && cd bin && ./transform
Output:
PointCloud (no filtering): 242540 data points.
PointCloud representing the planar component: 149589 data points.
Planar id: 1
PointCloud representing the planar component: 56901 data points.
Planar id: 2
PointCloud representing the planar component: 20883 data points.
Planar id: 3
PointCloud representing the planar component: 7365 data points.
Planar id: 4
PointCloud representing the planar component: 4875 data points.
Planar id: 5
PointCloud representing the planar component: 1755 data points.
Planar id: 6
PointCloud (no filtering): 241031 data points.
PointCloud representing the planar component: 112620 data points.
Planar id: 7
PointCloud representing the planar component: 93356 data points.
Planar id: 8
PointCloud representing the planar component: 21105 data points.
Planar id: 9
PointCloud representing the planar component: 7954 data points.
Planar id: 10
PointCloud representing the planar component: 3748 data points.
Planar id: 11
PointCloud (no filtering): 240900 data points.
PointCloud representing the planar component: 171566 data points.
Planar id: 12
PointCloud representing the planar component: 34734 data points.
Planar id: 13
PointCloud representing the planar component: 19348 data points.
Planar id: 14
PointCloud representing the planar component: 9069 data points.
Planar id: 15
PointCloud representing the planar component: 3957 data points.
Planar id: 16
PointCloud (no filtering): 242560 data points.
PointCloud representing the planar component: 213759 data points.
Planar id: 17
PointCloud representing the planar component: 17257 data points.
Planar id: 18
PointCloud representing the planar component: 7237 data points.
Planar id: 19
PointCloud representing the planar component: 3570 data points.
Planar id: 20
PointCloud (no filtering): 238562 data points.
PointCloud representing the planar component: 192368 data points.
Planar id: 21
PointCloud representing the planar component: 45577 data points.
Planar id: 22
PointCloud (no filtering): 216241 data points.
PointCloud representing the planar component: 147356 data points.
Planar id: 23
PointCloud representing the planar component: 68600 data points.
Planar id: 24
PointCloud (no filtering): 219348 data points.
PointCloud representing the planar component: 143190 data points.
Planar id: 25
PointCloud representing the planar component: 76039 data points.
Planar id: 26
Computing normals of planes...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
...Done.
Combining Point Clouds...
...Done.
Cloud: 1641182
Creating Voxels...
...Done.
Assigning Points to Voxels...
...Done.
Voxel Size:550008 voxels.
Voxel Size:100359 voxels.
224
1 : 1 7 12
2 : 2 3 4 5 6 8 12 17 21
3 : 2 3 4 5 6 7 8 12 17 21
4 : 2 3 4 5 6 8 12 17 21
5 : 2 3 4 5 6 8 12 17 21
6 : 2 3 4 5 6 12 17 21
7 : 1 3 7 9 10 11 12 13 17 21 23
8 : 2 3 4 5 8 17
9 : 7 9 10 11 12 13 17 21 23
10 : 7 9 10 11 12 13 17 21 23
11 : 7 9 10 11 12 13 17 21 23
12 : 1 2 3 4 5 6 7 9 10 11 12 13 14 15 17 21 23
13 : 7 9 10 11 12 13 14 15 17 21 23
14 : 12 13 14 17 21 23
15 : 12 13 15 17 21 23
16 : 16
17 : 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 21 23 25
18 : 17 18 19 21 23 25
19 : 17 18 19 21 23 25
20 : 20
21 : 2 3 4 5 6 7 9 10 11 12 13 14 15 17 18 19 21 22 23 25
22 : 21 22 23 24 25
23 : 7 9 10 11 12 13 14 15 17 18 19 21 22 23 24 25
24 : 22 23 24 25 26
25 : 17 18 19 21 22 23 24 25 26
26 : 24 25 26
Elapsed time: 12456.968750 milliseconds
Problem:
Problem:
- The results are inconclusive since the resulting pictures and table showed that ALL of the planes and in the same plane, which makes no sense.
***