Remove points outside defined 3D box inside PCL visualizer

后端 未结 2 2056
情歌与酒
情歌与酒 2021-01-06 03:04

In a given point cloud, I want to remove all the points which are less than min and greater than max for all x, y and

相关标签:
2条回答
  • 2021-01-06 03:29

    You have found what the documentation makes clear.

    PassThrough passes points in a cloud based on constraints for one particular field of the point type.

    For multiple fields a different filter should be used, such as ConditionalRemoval

    The following is untested, but it'll be something like this.

    pcl::ConditionOr<PointT>::Ptr range_cond (new pcl::ConditionOr<PointT> ()); 
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("x", pcl::ComparisonOps::GT, minX)));
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("x", pcl::ComparisonOps::LT, maxX)));
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("y", pcl::ComparisonOps::GT, minY)));
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("y", pcl::ComparisonOps::LT, maxY)));
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("z", pcl::ComparisonOps::GT, minZ)));
    range_cond->addComparison (pcl::FieldComparison<PointT>::Ptr (new pcl::FieldComparison<PointT>("z", pcl::ComparisonOps::LT, maxZ)));
    
    pcl::ConditionalRemoval<PointT> range_filt;
    range_filt.setInputCloud(body);
    range_filt.setCondition (range_cond);
    range_filt.filter(*bodyFiltered);
    
    0 讨论(0)
  • 2021-01-06 03:43

    What about using pcl::CropBox? (documentation)

    pcl::CropBox<pcl::PointXYZRGBA> boxFilter;
    boxFilter.setMin(Eigen::Vector4f(minX, minY, minZ, 1.0));
    boxFilter.setMax(Eigen::Vector4f(maxX, maxY, maxZ, 1.0));
    boxFilter.setInputCloud(body);
    boxFilter.filter(*bodyFiltered);
    

    To know why this filter takes Vector4f (and not Vector3f) see the comments below and this question.

    0 讨论(0)
提交回复
热议问题