PointCloudLibrary / PointCloudLibrary/pcl

[Octree/Question] Accessing point indices/other contents of leaf/branch nodes at a specific depth

Open
#3,706 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind: question module: octree needs: feedback
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Your Environment

  • Operating System and version: Mac OS Xcode IDE
  • Compiler: GCC
  • PCL Version:1.9.0

Context

I'm trying to build an octree to manage my point cloud data loaded from pcd file. I want to get the correspondent point indices in each voxel at a given depth of the octree...But I don't seem to find any method or example in the official documents.
I've tried to use FixedDepthIterator to traverse the tree and use "tree it.getLeafContainer().getPointIndices(vector)"something like this to get them.
But I don't know if I comprehend the usage properly and it's been a problem hard to solve before I can get the result and perform further study on region growth algorithms based on Octree.

Expected Behavior

Current Behavior

Code to Reproduce

This is the relevant codes I used after referring to the source codes of Class octreeViewer in Octree_viewer.cpp
void traverseOctree::getLeafNodesAtDepth(int depth){
//voxelCentercloud->clear();
pcl::PointXYZ pt_voxel_center;
vector point_idx_data;

for (pcl::octree::OctreePointCloudSearch<pcl::PointXYZ>::FixedDepthIterator tree_it = octree.fixed_depth_begin (depth);
     tree_it != octree.fixed_depth_end ();
     ++tree_it)
{

    // Compute the point at the center of the voxel which represents the current OctreeNode
    Eigen::Vector3f voxel_min, voxel_max;
    octree.getVoxelBounds (tree_it, voxel_min, voxel_max);
    
    pt_voxel_center.x = (voxel_min.x () + voxel_max.x ()) / 2.0f;
    pt_voxel_center.y = (voxel_min.y () + voxel_max.y ()) / 2.0f;
    pt_voxel_center.z = (voxel_min.z () + voxel_max.z ()) / 2.0f;
    voxelCentercloud->points.push_back (pt_voxel_center);
    voxelCenters.push_back(pt_voxel_center);
    cloud->points.push_back(pt_voxel_center);
   
    // If the asked depth is the depth of the octree, retrieve the centroid at this LeafNode
    if (octree.getTreeDepth () == (unsigned int) depth)
    {
      pcl::octree::OctreePointCloudVoxelCentroid<pcl::PointXYZ>::LeafNode* container = static_cast<pcl::octree::OctreePointCloudVoxelCentroid<pcl::PointXYZ>::LeafNode*> (tree_it.getCurrentOctreeNode ());
        tree_it.getLeafContainer().getPointIndices(point_idx_data);
    }
    // Else, compute the centroid of the LeafNode under the current BranchNode
    else
    {
      // Retrieve every centroid under the current BranchNode
      tree_it.getBranchContainer().getPointIndices(point_idx_data);
      pcl::octree::OctreeKey dummy_key;
      pcl::PointCloud<pcl::PointXYZ>::VectorType voxelCentroids;
    for(size_t i=0;i<point_idx_data.size();++i){
               cout<<" "<<point_idx_data[i]<<" "<<endl;
           }
}

}

Possible Solution

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Octree_viewer.cpp and the FixedDepthIterator usage shown in the issue. Read the iterator, leaf-container, and branch-container APIs to determine which contents can be retrieved at a requested depth. Done means the supported approach or limitation is documented with a minimal usage example.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-vision
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.