Search code examples
c++point-cloud-librarypoint-clouds

How do I index into a point cloud's points


I was working on a project and stumbled upon an issue with the indexing in three dimensions.

How do I index into the z value of a point?


Solution

  • PCL most commonly stores its point cloud information in an un-ordered form. The point itself carries the information you might need.

    For example the type PointXYZ has the following structure:

    pcl::PointXYZ::PointXYZ (   
        float   _x,
        float   _y,
        float   _z 
    )
    

    Find out more about the point types here.

    So in order to get the z information, you would do the following:

    cloud->points[i]._z; // Depth information from a point in your point cloud.