0
votes

I would like to know the number of points in a point cloud using PCL. The point cloud is created using pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_z(new pcl::PointCloud<pcl::PointXYZ>);. This is then populated using a filter which basically creates a subset from a larger point cloud. The point cloud is unorganised.

I am guessing I need to return the width, but can't figure out how to do this. Sure this is an easy answer but I am new to c++ and PCL.

1

1 Answers

3
votes

The number of points in a PCL point cloud is equal to the product of its width and height. By definition, an unorganized point cloud has height equal to 1. Therefore width is indeed equal to the number of points.

However, I would recommend using the size() function. It returns the number of points regardless of the type (organized/unorganized) and has clear semantics.

size_t num_points = cloud_z->size();