user6709725
user6709725

Reputation:

How to create pcl::PointIndices from std::vector<int> with `pcl`(Point Cloud Library) in c++?

I'm using pcl in c++, apologizing for not being able to create a pcl tag.

I'm realizing a pipe line of point cloud segmentation with pcl. I want to know how to create pcl::PointIndices from a extracted indices of type std::vector<int>, so I can input it into another filter.

First filter can generate indices of type std::vector

// Create statistical filtering object
pcl::StatisticalOutlierRemoval<PointXYZ> sor;
CloudXYZPtr sor_filtered (new CloudXYZ);
std::vector<int> sor_inliers;

sor.setInputCloud (input);
sor.setMeanK (10);
sor.setStddevMulThresh (0.5);
sor.filter (sor_inliers);

Then, I want input this filtered incides into another filter like:

pcl::RadiusOutlierRemoval<PointXYZ> ror;
pcl::PointIndices::Ptr ror_indices (new pcl::PointIndices);
ror_indices->data = sor_inliers;  // #### How to do this line?
std::vector<int> ror_inliers;

//I can set it like
ror.setInputCloud(input);
ror.setIndices(ror_indices);

How to make it work? Thanks.

Upvotes: 2

Views: 2029

Answers (1)

John Zwinck
John Zwinck

Reputation: 249143

This:

ror_indices->data = sor_inliers;  // #### How to do this line?

Should be:

ror_indices->indices = sor_inliers;

Upvotes: 2

Related Questions