作者:Evan-ZWU_680 | 来源:互联网 | 2023-09-09 19:34
autoware点云聚类三一级目录differenceNormalsSegmentationDoN参数KD-TREE求解法线向量信息DoN估计条件滤波一级目录difference
autoware 点云聚类 三 一级目录 differenceNormalsSegmentation DoN参数 KD-TREE 求解法线向量信息 DoN估计 条件滤波
一级目录 differenceNormalsSegmentation void differenceNormalsSegmentation ( const pcl:: PointCloud< pcl:: PointXYZ> :: Ptr in_cloud_ptr, pcl:: PointCloud< pcl:: PointXYZ> :: Ptr out_cloud_ptr)
DoN参数 事先定义两个不同范围的支持半径用于向量计算
float small_scale &#61; 0.5 ; float large_scale &#61; 2.0 ; float angle_threshold &#61; 0.5 ;
KD-TREE 根据点云类型&#xff08;无序点云、有序点云&#xff09;建立搜索树
pcl:: search:: Search< pcl:: PointXYZ> :: Ptr tree; if ( in_cloud_ptr-> isOrganized ( ) ) { tree. reset ( new pcl:: search:: OrganizedNeighbor < pcl:: PointXYZ> ( ) ) ; } else { tree. reset ( new pcl:: search:: KdTree < pcl:: PointXYZ> ( false ) ) ; } tree-> setInputCloud ( in_cloud_ptr) ;
求解法线向量信息 开始法向量求解器。OpenMP标准并行估计每个3D点的局部表面属性。加入搜索树。关于NormalEstimationOMP 使用&#xff0c;
pcl:: NormalEstimationOMP< pcl:: PointXYZ, pcl:: PointNormal> normal_estimation; normal_estimation. setInputCloud ( in_cloud_ptr) ; normal_estimation. setSearchMethod ( tree) ; normal_estimation. setViewPoint ( std:: numeric_limits < float > :: max ( ) , std:: numeric_limits < float > :: max ( ) , std:: numeric_limits < float > :: max ( ) ) ;
计算法线数据 normals_small_scale/ normals_large_scale
pcl:: PointCloud< pcl:: PointNormal> :: Ptr normals_small_scale ( new pcl:: PointCloud< pcl:: PointNormal> ) ; pcl:: PointCloud< pcl:: PointNormal> :: Ptr normals_large_scale ( new pcl:: PointCloud< pcl:: PointNormal> ) ; normal_estimation. setRadiusSearch ( small_scale) ; normal_estimation. compute ( * normals_small_scale) ; normal_estimation. setRadiusSearch ( large_scale) ; normal_estimation. compute ( * normals_large_scale) ;
DoN估计 定义法向量并绑定点云 法线信息 创建DoN估计器。得到DoN特征向量diffnormals_cloud
pcl:: PointCloud< pcl:: PointNormal> :: Ptr diffnormals_cloud ( new pcl:: PointCloud< pcl:: PointNormal> ) ; pcl:: copyPointCloud < pcl:: PointXYZ, pcl:: PointNormal> ( * in_cloud_ptr, * diffnormals_cloud) ; pcl:: DifferenceOfNormalsEstimation< pcl:: PointXYZ, pcl:: PointNormal, pcl:: PointNormal> diffnormals_estimator; diffnormals_estimator. setInputCloud ( in_cloud_ptr) ; diffnormals_estimator. setNormalScaleLarge ( normals_large_scale) ; diffnormals_estimator. setNormalScaleSmall ( normals_small_scale) ; diffnormals_estimator. initCompute ( ) ; diffnormals_estimator. computeFeature ( * diffnormals_cloud) ;
条件滤波 对于 pcl::ConditionOr
解释为
/** \brief Determine if a point meets this condition. * \return whether the point meets this condition. * The ConditionOr evaluates to true when ANY * comparisons or nested conditions evaluate to true */
曲率curvature 大于阀值angle_threshold 即认为满足条件。博客 最后加入ConditionalRemoval
中。这里应该是保留满足上述条件的法向量。得到过滤结果diffnormals_cloud_filtered
注意这里得到的数据类型&#xff0c;需要转点云
pcl:: ConditionOr< pcl:: PointNormal> :: Ptr range_cond ( new pcl:: ConditionOr < pcl:: PointNormal> ( ) ) ; range_cond-> addComparison ( pcl:: FieldComparison < pcl:: PointNormal> :: ConstPtr ( new pcl:: FieldComparison < pcl:: PointNormal> ( "curvature" , pcl:: ComparisonOps:: GT, angle_threshold) ) ) ; pcl:: ConditionalRemoval< pcl:: PointNormal> cond_removal; cond_removal. setCondition ( range_cond) ; cond_removal. setInputCloud ( diffnormals_cloud) ; pcl:: PointCloud< pcl:: PointNormal> :: Ptr diffnormals_cloud_filtered ( new pcl:: PointCloud< pcl:: PointNormal> ) ; cond_removal. filter ( * diffnormals_cloud_filtered) ;
转换点云结构…out_cloud_ptr
传出
pcl:: copyPointCloud < pcl:: PointNormal, pcl:: PointXYZ> ( * diffnormals_cloud, * out_cloud_ptr) ;
对于上述条件滤波做了几组实验&#xff1a;可以看出阀值越小保留的点月多。可以推断出条件滤波保留了满足条件的点。
angle_threshold&#61;0.9 angle_threshold&#61;0.5 angle_threshold&#61;0.1 angle_threshold&#61;0.05 其他相关博客 https://blog.csdn.net/zhan_zhan1/article/details/104755582