這是我的input
目標是去除掉圈起來這些渣渣
程式碼來源:
pcl - Removing outliers using a StatisticalOutlierRemoval filter
---
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/point_types.h> #include <pcl/filters/statistical_outlier_removal.h> int main(int argc, char** argv) { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>); // Fill in the cloud data pcl::PCDReader reader; // Replace the path below with the path where you saved your file reader.read<pcl::PointXYZ>("input_hand.pcd", *cloud); std::cerr << "Cloud before filtering: " << std::endl; std::cerr << *cloud << std::endl; // Create the filtering object pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor; sor.setInputCloud(cloud); sor.setMeanK(100); sor.setStddevMulThresh(0.5); sor.filter(*cloud_filtered); std::cerr << "Cloud after filtering: " << std::endl; std::cerr << *cloud_filtered << std::endl; pcl::PCDWriter writer; writer.write<pcl::PointXYZ>("hand_inliers.pcd", *cloud_filtered, false); sor.setNegative(true); sor.filter(*cloud_filtered); writer.write<pcl::PointXYZ>("hand_outliers.pcd", *cloud_filtered, false); return (0); }
---
結果:
有把渣渣分離出來