【问题标题】:How to downsample a point cloud while maintaining its order? (PCL C++)如何在保持其顺序的同时对点云进行下采样? (PCL C++)
【发布时间】:2021-02-10 22:51:15
【问题描述】:

我想使用 pcl 库提供的直通过滤器对传入的点云进行下采样,并保持给定云的顺序。 我目前的解决方案如下:

using point_type_colored = pcl::PointXYZRGB;
using point_cloud_colored = pcl::PointCloud<point_type_colored>;

point_cloud_colored::Ptr registration_util::pass_through_filter(
     const point_cloud_colored::Ptr& cloud_in, double p_t_x_min, double p_t_x_max,
     double p_t_y_min, double p_t_y_max, double p_t_z_min, double p_t_z_max)
{
     point_cloud_colored::Ptr filtered_cloud(new point_cloud_colored);
     *filtered_cloud = *cloud_in;
     pcl::PassThrough<point_type_colored> pass_filter;

     //filter x boundaries
     if (p_t_x_min != p_t_x_max)
     {
         pass_filter.setInputCloud(filtered_cloud);
         pass_filter.setFilterFieldName("x");
         pass_filter.setFilterLimits(p_t_x_min, p_t_x_max);
         pass_filter.filter(*filtered_cloud);
     }

     //filter y boundaries
     if (p_t_y_min != p_t_y_max)
     {
         pass_filter.setInputCloud(filtered_cloud);
         pass_filter.setFilterFieldName("y");
         pass_filter.setFilterLimits(p_t_y_min, p_t_y_max);
         pass_filter.filter(*filtered_cloud);
     }

     //filter z boundaries
     if (p_t_z_min != p_t_z_max)
     {
         pass_filter.setInputCloud(filtered_cloud);
         pass_filter.setFilterFieldName("z");
         pass_filter.setFilterLimits(p_t_z_min, p_t_z_max);
         pass_filter.filter(*filtered_cloud);
     }

     return std::move(filtered_cloud);
}

输入云具有定义的宽度(= 1280)和高度(= 720),这意味着点云是有序的。但是输出的云只有 1 的高度和 92160 的宽度,这意味着云由于下采样而失去了顺序。

如何保持输入云的原始顺序? 如果可能的话,对于随机过滤等其他下采样方法是否有类似的解决方案?

【问题讨论】:

  • 嗨 MichaelN,欢迎您。我不确定我是否理解您的问题。代码看起来不错,你说只有一个点(像素?)从你的原始点云中过滤出来?也许您的最小-最大限制设置得太窄了?你能告诉更多关于你试图通过“保持原始高度”实现的目标吗?您正在过滤..如果它是图像,您可以例如制作一个相同大小的空图像,只需将(过滤的)像素放在正确的位置,但是..图像不是点云..图像是输出..
  • @Goodies 您好,谢谢您的回复。抱歉我的发音不好(我对 PCL 有点陌生)。我的意思是输入点云的顺序被过滤器破坏了,因为输出云的高度在处理之后只有 1。但是如果你忽略顺序,点云就好了。这只是关于订单。

标签: c++ point-cloud-library point-clouds


【解决方案1】:

您正在寻找函数setKeepOrganized。提供true 会将每个过滤点设置为NaN,而不是删除该点。

您也可以使用setUserFilterValue 更改值以将其设置为,但保留NaN 的好处是其他PC​​L 算法不会将这些点用于其算法。

【讨论】:

  • 我完全忽略了这一点。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-20
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 2019-01-28
  • 1970-01-01
相关资源
最近更新 更多