I try to rasterize a X-0-Z pointcloud via PCL::OctreePointCloudVoxelCentroid in order to use some image processing algorithms on the pointcloud afterwards. But the output is not what I expect. I want the centroid for each box in an axis aligned octree, if at least one point is in a box. The octree's bounding box should be well defined. For testing I use 4 points: (-1.8000000 1 -1.8000000) (-1.4000000 1 -1.4000000) (-0.5000000 1 0.4000000) (0.4000000 1 1.8000000)
The code I use:
pcl::octree::OctreePointCloudVoxelCentroid<pcl::PointXYZ> octree (1.0f);
octree.defineBoundingBox(-2.0,-1.5,-2.0,2.0,2.5,2.0);
octree.setInputCloud (fourpoints);
octree.addPointsFromInputCloud ();
Black: original points; red: algorithm output; green: desired points. Algorithm Output: coordinates(-1.6 1 -1.6)(-0.5 1 0.4)(0.4 1 1.8)