114°

PCL1.8.1 分割 - cylinder model

圆柱模型

http://pointclouds.org/documentation/tutorials/cylinder_segmentation.php#cylinder-segmentation

#include <pcl/ModelCoefficients.h>
#include <pcl/point_types.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/features/normal_3d.h>

typedef pcl::PointXYZ PointT;

pcl::SACSegmentationFromNormals<PointT, pcl::Normal> seg; pcl::PointCloud<PointT>::Ptr cloud_filtered2 (new pcl::PointCloud<PointT>); pcl::PointCloud<pcl::Normal>::Ptr cloud_normals2 (new pcl::PointCloud<pcl::Normal>);

// Create the segmentation object for cylinder segmentation and set all the parameters seg.setOptimizeCoefficients (true); //设置对估计的模型系数进行优化 seg.setModelType (pcl::SACMODEL_CYLINDER); //设置分割模型为圆柱形 seg.setMethodType (pcl::SAC_RANSAC); seg.setNormalDistanceWeight (0.1); //设置表面法线权重系数 seg.setMaxIterations (10000); seg.setDistanceThreshold (0.05); seg.setRadiusLimits (0, 0.1); //设置估计出的圆柱模型的半径范围 seg.setInputCloud (cloud_filtered2); seg.setInputNormals (cloud_normals2);

// Obtain the cylinder inliers and coefficients

pcl::ModelCoefficients::Ptr coefficients_cylinder (new pcl::ModelCoefficients); pcl::PointIndices::Ptr inliers_cylinder (new pcl::PointIndices);

seg.segment (*inliers_cylinder, *coefficients_cylinder); std::cerr << "Cylinder coefficients: " << *coefficients_cylinder << std::endl;

 

本文由【J】发布于开源中国,原文链接:https://my.oschina.net/u/4228078/blog/3135243

全部评论: 0

    我有话说: