Point Cloud Library (PCL)  1.14.1-dev
List of all members | Public Member Functions | Protected Types
pcl::ConditionalEuclideanClustering< PointT > Class Template Reference

ConditionalEuclideanClustering performs segmentation based on Euclidean distance and a user-defined clustering condition. More...

#include <pcl/segmentation/conditional_euclidean_clustering.h>

+ Inheritance diagram for pcl::ConditionalEuclideanClustering< PointT >:
+ Collaboration diagram for pcl::ConditionalEuclideanClustering< PointT >:

Public Member Functions

 ConditionalEuclideanClustering (bool extract_removed_clusters=false)
 Constructor. More...
 
void setSearchMethod (const SearcherPtr &tree)
 Provide a pointer to the search object. More...
 
const SearcherPtrgetSearchMethod () const
 Get a pointer to the search method used. More...
 
void setConditionFunction (bool(*condition_function)(const PointT &, const PointT &, float))
 Set the condition that needs to hold for neighboring points to be considered part of the same cluster. More...
 
void setConditionFunction (std::function< bool(const PointT &, const PointT &, float)> condition_function)
 Set the condition that needs to hold for neighboring points to be considered part of the same cluster. More...
 
void setClusterTolerance (float cluster_tolerance)
 Set the spatial tolerance for new cluster candidates. More...
 
float getClusterTolerance ()
 Get the spatial tolerance for new cluster candidates. More...
 
void setMinClusterSize (int min_cluster_size)
 Set the minimum number of points that a cluster needs to contain in order to be considered valid. More...
 
int getMinClusterSize ()
 Get the minimum number of points that a cluster needs to contain in order to be considered valid. More...
 
void setMaxClusterSize (int max_cluster_size)
 Set the maximum number of points that a cluster needs to contain in order to be considered valid. More...
 
int getMaxClusterSize ()
 Get the maximum number of points that a cluster needs to contain in order to be considered valid. More...
 
void segment (IndicesClusters &clusters)
 Segment the input into separate clusters. More...
 
void getRemovedClusters (IndicesClustersPtr &small_clusters, IndicesClustersPtr &large_clusters)
 Get the clusters that are invalidated due to size constraints. More...
 
- Public Member Functions inherited from pcl::PCLBase< PointT >
 PCLBase ()
 Empty constructor. More...
 
 PCLBase (const PCLBase &base)
 Copy constructor. More...
 
virtual ~PCLBase ()=default
 Destructor. More...
 
virtual void setInputCloud (const PointCloudConstPtr &cloud)
 Provide a pointer to the input dataset. More...
 
PointCloudConstPtr const getInputCloud () const
 Get a pointer to the input point cloud dataset. More...
 
virtual void setIndices (const IndicesPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (const IndicesConstPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (const PointIndicesConstPtr &indices)
 Provide a pointer to the vector of indices that represents the input data. More...
 
virtual void setIndices (std::size_t row_start, std::size_t col_start, std::size_t nb_rows, std::size_t nb_cols)
 Set the indices for the points laying within an interest region of the point cloud. More...
 
IndicesPtr getIndices ()
 Get a pointer to the vector of indices used. More...
 
IndicesConstPtr const getIndices () const
 Get a pointer to the vector of indices used. More...
 
const PointToperator[] (std::size_t pos) const
 Override PointCloud operator[] to shorten code. More...
 

Protected Types

using SearcherPtr = typename pcl::search::Search< PointT >::Ptr
 

Additional Inherited Members

- Public Types inherited from pcl::PCLBase< PointT >
using PointCloud = pcl::PointCloud< PointT >
 
using PointCloudPtr = typename PointCloud::Ptr
 
using PointCloudConstPtr = typename PointCloud::ConstPtr
 
using PointIndicesPtr = PointIndices::Ptr
 
using PointIndicesConstPtr = PointIndices::ConstPtr
 
- Protected Member Functions inherited from pcl::PCLBase< PointT >
bool initCompute ()
 This method should get called before starting the actual computation. More...
 
bool deinitCompute ()
 This method should get called after finishing the actual computation. More...
 
- Protected Attributes inherited from pcl::PCLBase< PointT >
PointCloudConstPtr input_
 The input point cloud dataset. More...
 
IndicesPtr indices_
 A pointer to the vector of point indices to use. More...
 
bool use_indices_
 Set to true if point indices are used. More...
 
bool fake_indices_
 If no set of indices are given, we construct a set of fake indices that mimic the input PointCloud. More...
 

Detailed Description

template<typename PointT>
class pcl::ConditionalEuclideanClustering< PointT >

ConditionalEuclideanClustering performs segmentation based on Euclidean distance and a user-defined clustering condition.

The condition that need to hold is currently passed using a function pointer. For more information check the documentation of setConditionFunction() or the usage example below:

bool
enforceIntensitySimilarity (const pcl::PointXYZI& point_a, const pcl::PointXYZI& point_b, float squared_distance)
{
if (std::abs (point_a.intensity - point_b.intensity) < 0.1f)
return (true);
else
return (false);
}
// ...
// Somewhere down to the main code
// ...
cec.setInputCloud (cloud_in);
cec.setConditionFunction (&enforceIntensitySimilarity);
// Points within this distance from one another are going to need to validate the enforceIntensitySimilarity function to be part of the same cluster:
cec.setClusterTolerance (0.09f);
// Size constraints for the clusters:
cec.setMinClusterSize (5);
cec.setMaxClusterSize (30);
// The resulting clusters (an array of pointindices):
cec.segment (*clusters);
// The clusters that are too small or too large in size can also be extracted separately:
cec.getRemovedClusters (small_clusters, large_clusters);
ConditionalEuclideanClustering performs segmentation based on Euclidean distance and a user-defined c...
Author
Frits Florentinus

Definition at line 85 of file conditional_euclidean_clustering.h.

Member Typedef Documentation

◆ SearcherPtr

template<typename PointT >
using pcl::ConditionalEuclideanClustering< PointT >::SearcherPtr = typename pcl::search::Search<PointT>::Ptr
protected

Definition at line 88 of file conditional_euclidean_clustering.h.

Constructor & Destructor Documentation

◆ ConditionalEuclideanClustering()

template<typename PointT >
pcl::ConditionalEuclideanClustering< PointT >::ConditionalEuclideanClustering ( bool  extract_removed_clusters = false)
inline

Constructor.

Parameters
[in]extract_removed_clustersSet to true if you want to be able to extract the clusters that are too large or too small (default = false)

Definition at line 99 of file conditional_euclidean_clustering.h.

Member Function Documentation

◆ getClusterTolerance()

template<typename PointT >
float pcl::ConditionalEuclideanClustering< PointT >::getClusterTolerance ( )
inline

Get the spatial tolerance for new cluster candidates.

Definition at line 169 of file conditional_euclidean_clustering.h.

◆ getMaxClusterSize()

template<typename PointT >
int pcl::ConditionalEuclideanClustering< PointT >::getMaxClusterSize ( )
inline

Get the maximum number of points that a cluster needs to contain in order to be considered valid.

Definition at line 201 of file conditional_euclidean_clustering.h.

◆ getMinClusterSize()

template<typename PointT >
int pcl::ConditionalEuclideanClustering< PointT >::getMinClusterSize ( )
inline

Get the minimum number of points that a cluster needs to contain in order to be considered valid.

Definition at line 185 of file conditional_euclidean_clustering.h.

◆ getRemovedClusters()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::getRemovedClusters ( IndicesClustersPtr small_clusters,
IndicesClustersPtr large_clusters 
)
inline

Get the clusters that are invalidated due to size constraints.

Note
The constructor of this class needs to be initialized with true, and the segment method needs to have been called prior to using this method.
Parameters
[out]small_clustersThe resultant clusters that contain less than min_cluster_size points
[out]large_clustersThe resultant clusters that contain more than max_cluster_size points

Definition at line 224 of file conditional_euclidean_clustering.h.

◆ getSearchMethod()

template<typename PointT >
const SearcherPtr& pcl::ConditionalEuclideanClustering< PointT >::getSearchMethod ( ) const
inline

Get a pointer to the search method used.

Definition at line 120 of file conditional_euclidean_clustering.h.

◆ segment()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::segment ( pcl::IndicesClusters clusters)

Segment the input into separate clusters.

The input can be set using setInputCloud() and setIndices().
The size constraints for the resulting clusters can be set using setMinClusterSize() and setMaxClusterSize().
The region growing parameters can be set using setConditionFunction() and setClusterTolerance().

Parameters
[out]clustersThe resultant set of indices, indexing the points of the input cloud that correspond to the clusters

Definition at line 45 of file conditional_euclidean_clustering.hpp.

References pcl::PointIndices::header, and pcl::PointIndices::indices.

◆ setClusterTolerance()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setClusterTolerance ( float  cluster_tolerance)
inline

Set the spatial tolerance for new cluster candidates.

Any two points within this distance from one another will need to evaluate a certain condition in order to be made part of the same cluster. The condition can be set using setConditionFunction().

Parameters
[in]cluster_toleranceThe distance to scan for cluster candidates (default = 0.0)

Definition at line 162 of file conditional_euclidean_clustering.h.

◆ setConditionFunction() [1/2]

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setConditionFunction ( bool(*)(const PointT &, const PointT &, float)  condition_function)
inline

Set the condition that needs to hold for neighboring points to be considered part of the same cluster.

Any two points within a certain distance from one another will need to evaluate this condition in order to be made part of the same cluster. The distance can be set using setClusterTolerance().
Note that for a point to be part of a cluster, the condition only needs to hold for at least 1 point pair. To clarify, the following statement is false: Any two points within a cluster always evaluate this condition function to true.

The input arguments of the condition function are:

  • PointT The first point of the point pair
  • PointT The second point of the point pair
  • float The squared distance between the points

The output argument is a boolean, returning true will merge the second point into the cluster of the first point.

Parameters
[in]condition_functionThe condition function that needs to hold for clustering

Definition at line 143 of file conditional_euclidean_clustering.h.

◆ setConditionFunction() [2/2]

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setConditionFunction ( std::function< bool(const PointT &, const PointT &, float)>  condition_function)
inline

Set the condition that needs to hold for neighboring points to be considered part of the same cluster.

This is an overloaded function provided for convenience. See the documentation for setConditionFunction().

Definition at line 151 of file conditional_euclidean_clustering.h.

◆ setMaxClusterSize()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setMaxClusterSize ( int  max_cluster_size)
inline

Set the maximum number of points that a cluster needs to contain in order to be considered valid.

Parameters
[in]max_cluster_sizeThe maximum cluster size (default = unlimited)

Definition at line 194 of file conditional_euclidean_clustering.h.

◆ setMinClusterSize()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setMinClusterSize ( int  min_cluster_size)
inline

Set the minimum number of points that a cluster needs to contain in order to be considered valid.

Parameters
[in]min_cluster_sizeThe minimum cluster size (default = 1)

Definition at line 178 of file conditional_euclidean_clustering.h.

◆ setSearchMethod()

template<typename PointT >
void pcl::ConditionalEuclideanClustering< PointT >::setSearchMethod ( const SearcherPtr tree)
inline

Provide a pointer to the search object.

Parameters
[in]treea pointer to the spatial search object.

Definition at line 112 of file conditional_euclidean_clustering.h.


The documentation for this class was generated from the following files: