pcl voxelgrid filter number of points dont tally
[reposted this from pcl mailing list]
have a laz file which I use PCL (1.8)'s voxelgrid filter to turn downsample and group points into 1 point per cell. I only want a 2D grid, so I set z resolution to be really large.
loadCloud(cloud, 1);
pcl::VoxelGrid<pcl::PointXYZRGB> sor;
sor.setInputCloud(cloud);
sor.setLeafSize(resolution, resolution, 500);
sor.filter(*cloud_projected);
pcl::PointXYZRGB minpoint;
pcl::PointXYZRGB maxpoint;
pcl::getMinMax3D(*cloud, minpoint, maxpoint);
cout << "min " << minpoint.x << " max x " << maxpoint.x<<endl;
cout << "min " << minpoint.y << " max x " << maxpoint.y<<endl;
pcl::io::savePCDFileASCII("ground_0.1.pcd", *cloud_projected);
Separately, I have another program in python which I use pandas to check the points. The problem is, when I bin the xy centroid points into their grid cells, there are >1 points per cell, resulting in the assertion failure below. The difference is in the number of points is large: 27841173 points read from the pcd file but when I convert into their grids and drop the duplicates there are only 25779908.
Any idea?
mapdf = pd.read_csv(map_file, names=['x', 'y', 'z', 'intensity'], header=None, sep=" ", skiprows=11)
mapdf.drop(['z'], axis = 1)
mapdf, ngrids = self.init_map(mapdf)
def init_map(self, df):
df['x'] = df.x #- 23527.262795251976
df['y'] = df.y #- 30751.407782477283
self.min_x = df.x.min()
self.max_x = df.x.max()
self.min_y = df.y.min()
self.max_y = df.y.max()
ngrids = (20419, 12902)
df['x'] = np.floor((df.x - df.x.min())/self.resolution)
df['y'] = np.floor((df.y - df.y.min())/self.resolution)
assert df.shape == df.drop_duplicates().shape