I would like to find out what I am doing wrong.
Steps
- Load .pcd inout file
Limit that input file as follow
typename pcl::PointCloud<PointT>::Ptr cloudROI (new pcl::PointCloud<PointT>); pcl::CropBox<PointT> region(true); region.setMin(Eigen::Vector4f (-10, -5, -2, 1)); region.setMax(Eigen::Vector4f (30, 6.5, 1, 1)); region.setInputCloud(cloud_filtered); region.filter(*cloudROI);
Works fine for me.
But know the next step doesn't work
- Now I want to filter some points around my Lidar source
- Therefore I create a second cropbox with the InputCloud from my first segmentation
std::vector<int> indices;
pcl::CropBox<PointT> roof(true);
roof.setMin(Eigen::Vector4f (-1.5, -1.7, -1, 1));
roof.setMax(Eigen::Vector4f (2.6, 1.7, -0.4, 1));
roof.setInputCloud(cloudROI);
region.filter(indices);
pcl::PointIndices::Ptr inliers {new pcl::PointIndices};
for (int point : indices)
{
inliers->indices.push_back(point);
std::cout << "Found inliers" << std::endl;
}
pcl::ExtractIndices<PointT> extract;
extract.setInputCloud(cloudROI);
extract.setIndices(inliers);
extract.setNegative(true);
extract.filter(*cloudROI);
If I simulate my code I get the following result.
As you can see, the filter cropped points from the plane on the right side, although my box is never that big. Also keeps the one in the middle.