Point Cloud Library (PCL)
1.7.2
|
A generic class that computes the centroid of points fed to it. More...
#include <pcl/common/centroid.h>
Public Member Functions | |
CentroidPoint () | |
void | add (const PointT &point) |
Add a new point to the centroid computation. More... | |
template<typename PointOutT > | |
void | get (PointOutT &point) const |
Retrieve the current centroid. More... | |
size_t | getSize () const |
Get the total number of points that were added. More... | |
A generic class that computes the centroid of points fed to it.
Here by "centroid" we denote not just the mean of 3D point coordinates, but also mean of values in the other data fields. The general-purpose computeNDCentroid() function also implements this sort of functionality, however it does it in a "dumb" way, i.e. regardless of the semantics of the data inside a field it simply averages the values. In certain cases (e.g. for x
, y
, z
, intensity
fields) this behavior is reasonable, however in other cases (e.g. rgb
, rgba
, label
fields) this does not lead to meaningful results.
This class is capable of computing the centroid in a "smart" way, i.e. taking into account the meaning of the data inside fields. Currently the following fields are supported:
XYZ (x
, y
, z
)
Separate average for each field.
Normal (normal_x
, normal_y
, normal_z
)
Separate average for each field, and the resulting vector is normalized.
Curvature (curvature
)
Average.
RGB/RGBA (rgb
or rgba
)
Separate average for R, G, B, and alpha channels.
Intensity (intensity
)
Average.
Label (label
)
Majority vote. If several labels have the same largest support then the smaller label wins.
The template parameter defines the type of points that may be accumulated with this class. This may be an arbitrary PCL point type, and centroid computation will happen only for the fields that are present in it and are supported.
Current centroid may be retrieved at any time using get(). Note that the function is templated on point type, so it is possible to fetch the centroid into a point type that differs from the type of points that are being accumulated. All the "extra" fields for which the centroid is not being calculated will be left untouched.
Example usage:
Definition at line 1037 of file centroid.h.
|
inline |
Definition at line 1042 of file centroid.h.
|
inline |
Add a new point to the centroid computation.
In this function only the accumulators and point counter are updated, actual centroid computation does not happen until get() is called.
Definition at line 1052 of file centroid.h.
Referenced by pcl::computeCentroid().
|
inline |
Retrieve the current centroid.
Computation (division of accumulated values by the number of points and normalization where applicable) happens here. The result is not cached, so any subsequent call to this function will trigger re-computation.
If the number of accumulated points is zero, then the point will be left untouched.
Definition at line 1069 of file centroid.h.
Referenced by pcl::computeCentroid().
|
inline |
Get the total number of points that were added.
Definition at line 1083 of file centroid.h.
References pcl::computeCentroid().
Referenced by pcl::computeCentroid().