0

I need to partition my data into voxels using octree data structure of PCL. I think I managed to create the octree and voxels. However, I have two questions about octree structure of PCL.

  1. My first question is about resolution of the octree. I defined the resolution as shown below: float resolution = 0.009f; pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution);

As far as I understood, this resolution parameter defines the dimension of side length of the voxel at lowest level of the octree. In this case the side length of voxels at lowest level are equal to 0.009m, is it correct?

  1. How can I get point indices for each voxel? Let's say there are five points in the first voxel and I need indices of these points. I am looking forward to hearing from you Regards
mozendi
  • 85
  • 1
  • 11

1 Answers1

0
  1. The resolution really depends on your data, if your point cloud is in meters, then it will be correct. Assume you have an x,y,z point with coordinates A=(1,0,0) and another point in B=(0,0,0). If the point A is far from point B along x axis by 1m, then you're correct. The convention of PCL is that the point cloud should be in meters.

But just to illustrate:

pcl::PointCloud<pcl::PointXYZ> cloud_in_meters;
resolution = 1.0f; 
pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution);

and

pcl::PointCloud<pcl::PointXYZ> cloud_in_meters;
cloud_in_millimeters = cloud_in_meters*1000;
resolution = 1.0f/1000.f; 
pcl::octree::OctreePointCloudSearch<pcl::PointXYZ> octree(resolution);

Will be essentially the same for the program.

  1. You can get indexes of the points in the intersected voxels by getIntersectedVoxelIndices. I know that the docs are misleading, but it's actually what you need.

For example:

std::vector< int > k_indices;
octree.getIntersectedVoxelIndices(origin, direction, k_indices, 1);

k_indices is the vector with point indexes in the volume intersected by the ray.

You can examine what this function is doing: https://github.com/PointCloudLibrary/pcl/blob/46cb8fe5589e88e36d79f9b8b8e5f4ff4fceb5de/octree/include/pcl/octree/impl/octree_search.hpp#L613

Jun Murakami
  • 815
  • 1
  • 9
  • 17