ฉันต้องการสุ่มตัวอย่าง pointcloud ขาเข้าโดยใช้ตัวกรอง passthrough ที่ไลบรารี 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 ซึ่งหมายความว่าคลาวด์สูญเสียลำดับเนื่องจากการสุ่มตัวอย่างต่ำ
ฉันจะรักษาลำดับดั้งเดิมของอินพุตคลาวด์ได้อย่างไร หากเป็นไปได้ มีวิธีแก้ไขปัญหาที่คล้ายกันสำหรับวิธีการสุ่มตัวอย่างอื่นๆ เช่น การกรองแบบสุ่ม หรือไม่