void Cvisualization::ShowCloud5()
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PCDReader reader;
// Replace the path below with the path where you saved your file
reader.read<pcl::PointXYZ>("E:/ai/pcltest/table_scene_lms400.pcd", *cloud);
// Create a set of planar coefficients with X=Y=0,Z=1 创建一组平面系数
pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
coefficients->values.resize(4);//values是一个定义的实数型vector 作用???
coefficients->values[0] = coefficients->values[1] = 0;
coefficients->values[2] = 1;
coefficients->values[3] = 0;
// Create the filtering object
pcl::ProjectInliers<pcl::PointXYZ> proj;//创建 参数模型投影对象
proj.setModelType(pcl::SACMODEL_CYLINDER);//SAC 应该是Sampling Consensus 采样一致性 选择SAC中的平面模型
proj.setInputCloud(cloud);//同时初始化input_和indices_
proj.setModelCoefficients(coefficients);//设置模型参数
proj.filter(*cloud_projected);
pcl::PLYWriter write;
write.write<pcl::PointXYZ>("E:/ai/pcltest/pm_map_table_plane.ply", *cloud_projected);
}