Bootstrap

条件欧几里得聚类

本教程介绍如何使用pcl::ConditionalEuclideanClustering类:一种基于欧几里得距离和用户可自定义条件对点进行聚类的分割算法。

此类使用与欧几里得聚类提取区域增长分割基于颜色的区域增长分割相同的贪婪/区域增长/洪水填充方法。与其他类相比,使用此类的优势在于用户现在可以自定义聚类约束(纯欧几里德、平滑度、RGB)。一些缺点包括:没有初始播种系统,没有过度和不足分割控制,以及从主计算循环内部调用条件函数的时间效率较低。

源码:
创建:conditional_euclidean_clustering.cpp 文件

  1#include <pcl/point_types.h>
  2#include <pcl/io/pcd_io.h>
  3#include <pcl/console/time.h>
  4
  5#include <pcl/filters/voxel_grid.h>
  6#include <pcl/features/normal_3d.h>
  7#include <pcl/segmentation/conditional_euclidean_clustering.h>
  8
  9typedef pcl::PointXYZI PointTypeIO;
 10typedef pcl::PointXYZINormal PointTypeFull;
 11
 12bool
 13enforceIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float /*squared_distance*/)
 14{
 15  if (std::abs (point_a.intensity - point_b.intensity) < 5.0f)
 16    return (true);
 17  else
 18    return (false);
 19}
 20
 21bool
 22enforceNormalOrIntensitySimilarity (const PointTypeFull& point_a, const PointTypeFull& point_b, float /*squared_distance*/)
 23{
 24  Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.getNormalVector3fMap (), point_b_normal = point_b.getNormalVector3fMap ();
 25  if (std::abs (point_a.intensity - point_b.intensity) < 5.0f)
 26    return (true);
 27  if (std::abs (point_a_normal.dot (point_b_normal)) > std::cos (30.0f / 180.0f * static_cast<float> (M_PI)))
 28    return (true);
 29  return (false);
 30}
 31
 32bool
 33customRegionGrowing (const PointTypeFull& point_a, const PointTypeFull& point_b, float squared_distance)
 34{
 35  Eigen::Map<const Eigen::Vector3f> point_a_normal = point_a.getNormalVector3fMap (), point_b_normal = point_b.getNormalVector3fMap ();
 36  if (squared_distance < 10000)
 37  {
 38    if (std::abs (point_a.intensity - point_b.intensity) < 8.0f)
 39      return (true);
 40    if (std::abs (point_a_normal.dot (point_b_normal)) < 0.06)
 41      return (true);
 42  }
 43  else
 44  {
 45    if (std::abs 
;