79 const size_t pointsCount(cloud.
features.cols());
86 throw InvalidField(
"SphericalityDataPointsFilter: Error, no eigValues found in descriptors.");
91 for(
unsigned int i = 0; i < labelDim ; ++i)
93 if (insertDim != descDim)
94 throw InvalidField(
"SurfaceNormalDataPointsFilter: Error, descriptor labels do not match descriptor data");
97 const size_t unidimensionalDescriptorDimension(1);
100 boost::optional<View> sphericality;
101 boost::optional<View> unstructureness;
102 boost::optional<View> structureness;
105 cloudLabels.push_back(
Label(
"sphericality", unidimensionalDescriptorDimension));
107 cloudLabels.push_back(
Label(
"unstructureness", unidimensionalDescriptorDimension));
109 cloudLabels.push_back(
Label(
"structureness", unidimensionalDescriptorDimension));
116 if (eigValues.rows() != 3)
118 throw InvalidField(
"SphericalityDataPointsFilter: Error, the number of eigValues is not 3.");
128 for (
size_t i = 0; i < pointsCount; ++i)
131 Vector eig_vals_col = eigValues.col(i);
133 std::sort(eig_vals_col.data(),eig_vals_col.data()+eig_vals_col.size());
137 T unstructurenessVal;
142 if (eig_vals_col(2) < std::numeric_limits<T>::min() ||
143 eig_vals_col(1) < 0.0 ||
144 eig_vals_col(0) < 0.0)
148 sphericalityVal = std::numeric_limits<T>::quiet_NaN();
149 unstructurenessVal = std::numeric_limits<T>::quiet_NaN();
150 structurenessVal = std::numeric_limits<T>::quiet_NaN();
152 }
else if (eig_vals_col(1) < std::numeric_limits<T>::min()) {
154 sphericalityVal = 0.0;
155 unstructurenessVal = 0.0;
156 structurenessVal = 0.0;
161 unstructurenessVal = eig_vals_col(0) / eig_vals_col(2);
162 structurenessVal = (eig_vals_col(1) / eig_vals_col(2)) *
163 ((eig_vals_col(1) - eig_vals_col(0)) / sqrt(eig_vals_col(0)*eig_vals_col(0) + eig_vals_col(1)*eig_vals_col(1)));
164 sphericalityVal = unstructurenessVal - structurenessVal;
169 (sphericality.get())(0,i) = sphericalityVal;
172 (unstructureness.get())(0,i) = unstructurenessVal;
174 (structureness.get())(0,i) = structurenessVal;
virtual void inPlaceFilter(DataPoints &cloud)
Apply these filters to a point cloud without copying.
Parametrizable::Parameters Parameters
Matrix descriptors
descriptors of points in the cloud, might be empty
ConstView getDescriptorViewByName(const std::string &name) const
Get a const view on a descriptor by name, throw an exception if it does not exist.
PointMatcher< T >::Vector Vector
The name for a certain number of dim.
PointMatcher< T >::DataPoints::InvalidField InvalidField
const bool keepStructureness
DataPoints::Labels Labels
Functions and classes that are dependant on scalar type are defined in this templatized class...
bool descriptorExists(const std::string &name) const
Look if a descriptor with a given name exist.
const M::mapped_type & get(const M &m, const typename M::key_type &k)
virtual DataPoints filter(const DataPoints &input)
Apply filters to input point cloud. This is the non-destructive version and returns a copy...
const bool keepUnstructureness
The superclass of classes that are constructed using generic parameters. This class provides the para...
Eigen::Block< Matrix > View
A view on a feature or descriptor.
Matrix features
features of points in the cloud
PM::DataPointsFilter DataPointsFilter
void allocateDescriptors(const Labels &newLabels)
Make sure a vector of descriptors of given names exist.
SphericalityDataPointsFilter(const Parameters ¶ms=Parameters())
Labels descriptorLabels
labels of descriptors