将Unit8传递到PCL :: PassTrough

发布于 2025-02-13 11:50:26 字数 1277 浏览 2 评论 0原文

我有一个自定义的pointxyzb带有字段xyzbeampcl中。 xyz是float,beam是unit8,其值等于0或1。注册了我自定义的pointxyzb到PCL,我正在尝试使用setFilterFieldName用字段beam来过滤我的点云。以下是我的代码。代码成功编译,但无法根据beam过滤出正确的结果。我知道我们可以将setEnsngative作为解决方法,但我想知道为什么我的代码失败。我想从c ++ API中的UINT8铸造到两倍时,有问题。

#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
    
pcl::PointCloud<PointXYZB> filter (double lower, double upper)
    {
      pcl::PointCloud<PointXYZB>::Ptr cloud (new pcl::PointCloud<PointXYZB>);
      pcl::PointCloud<PointXYZB>::Ptr cloud_filtered (new pcl::PointCloud<PointXYZB>);
    

      // Create the filtering object
      pcl::PassThrough<PointXYZB> pass;
      pass.setInputCloud (cloud);
      pass.setFilterFieldName ("beam");
      pass.setFilterLimits (lower, double);
      pass.filter (*cloud_filtered);
      return *cloud_filtered;

    }

int main() {
  pcl::PointCloud<PointXYZB> f = filter(0.0, 0.0);
  pcl::PointCloud<PointXYZB> b = filter(1.0, 1.0);
}

I have a customized PointXYZB with fields x, y, z, and beam in pcl. x, y, z are float and beam is unit8 with either value equals to 0 or 1. I have registered my customized PointXYZB to pcl, and I'm trying to use setFilterFieldName to filter my point cloud in terms of field beam. The following is my code. The code compiles successfully but fails to filter out the correct result based on beam. I know we can use setNegative as a workaround but I want to know why my code fails. I guess there is something wrong when casting from uint8 to double in c++ API.

#include <iostream>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
    
pcl::PointCloud<PointXYZB> filter (double lower, double upper)
    {
      pcl::PointCloud<PointXYZB>::Ptr cloud (new pcl::PointCloud<PointXYZB>);
      pcl::PointCloud<PointXYZB>::Ptr cloud_filtered (new pcl::PointCloud<PointXYZB>);
    

      // Create the filtering object
      pcl::PassThrough<PointXYZB> pass;
      pass.setInputCloud (cloud);
      pass.setFilterFieldName ("beam");
      pass.setFilterLimits (lower, double);
      pass.filter (*cloud_filtered);
      return *cloud_filtered;

    }

int main() {
  pcl::PointCloud<PointXYZB> f = filter(0.0, 0.0);
  pcl::PointCloud<PointXYZB> b = filter(1.0, 1.0);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终难愈 2025-02-20 11:50:26

I just checked, PassThrough only works for fields of type float: https://github.com/PointCloudLibrary/pcl/blob/master/filters/include/pcl/filters/impl/passthrough.hpp#L101

You can try ConditionalRemoval or, if your PCL version is sufficiently recent, FunctorFilter/FunctionFilter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文