简体   繁体   English

如何在保持其顺序的同时对点云进行下采样? (PCL C++)

[英]How to downsample a point cloud while maintaining its order? (PCL C++)

I want to downsample incoming pointclouds by using the passthrough filter provided by the pcl library and also maintain the order of the given clouds.我想通过使用 pcl 库提供的直通过滤器对传入的点云进行下采样,并保持给定云的顺序。 My current solution is as follows:我目前的解决方案如下:

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);
}

The input cloud has a defined width (= 1280) and height (=720) which means the point cloud is ordered.输入云具有定义的宽度(= 1280)和高度(= 720),这意味着点云是有序的。 But the output cloud has only the height of one and a width of 92160 which means the cloud has lost its order due to downsampling.但是 output 云只有 1 的高度和 92160 的宽度,这意味着云由于下采样而失去了顺序。

How do I keep the original order of the input cloud?如何保持输入云的原始顺序? If it is possible are there similar solutions for other downsampling methods like random filtering?如果可能的话,对于随机过滤等其他下采样方法是否有类似的解决方案?

You are looking for the function setKeepOrganized .您正在寻找 function setKeepOrganized Providing true will set each filtered point to NaN instead of removing the point.提供true会将每个过滤点设置为NaN而不是删除该点。

You can also change the value to set it to with setUserFilterValue , but keeping it NaN has the benefit that other PCL algorithms won't consider these points for their algorithm.您还可以使用setUserFilterValue更改值以将其设置为,但保持NaN的好处是其他 PCL 算法不会将这些点用于其算法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM