40 #include "Eigen/Eigenvalues" 59 averageExistingDescriptors(
Parametrizable::
get<bool>(
"averageExistingDescriptors")),
87 const int pointsCount(cloud.
features.cols());
88 const int featDim(cloud.
features.rows());
97 for(
unsigned int i = 0; i < labelDim ; ++i)
99 if (insertDim != descDim)
100 throw InvalidField(
"SamplingSurfaceNormalDataPointsFilter: Error, descriptor labels do not match descriptor data");
104 const int dimNormals(featDim-1);
105 const int dimDensities(1);
106 const int dimEigValues(featDim-1);
107 const int dimEigVectors((featDim-1)*(featDim-1));
112 cloudLabels.push_back(
Label(
"normals", dimNormals));
114 cloudLabels.push_back(
Label(
"densities", dimDensities));
116 cloudLabels.push_back(
Label(
"eigValues", dimEigValues));
118 cloudLabels.push_back(
Label(
"eigVectors", dimEigVectors));
139 cloud.
features.rowwise().minCoeff(),
147 for (
int i = 0; i < ptsOut; ++i)
154 if (cloud.
times.rows() != 0)
178 const int count(last - first);
179 if (count <=
int(
knn))
190 const int cutDim = argMax<T>(maxValues - minValues);
193 const int rightCount(count/2);
194 const int leftCount(count - rightCount);
195 assert(last - rightCount == first + leftCount);
200 data.
indices.begin() + first + leftCount,
206 const int cutIndex(data.
indices[first+leftCount]);
207 const T cutVal(data.
features(cutDim, cutIndex));
210 Vector leftMaxValues(maxValues);
211 leftMaxValues[cutDim] = cutVal;
213 Vector rightMinValues(minValues);
214 rightMinValues[cutDim] = cutVal;
217 buildNew(data, first, first + leftCount,
218 std::forward<Vector>(minValues), std::move(leftMaxValues));
219 buildNew(data, first + leftCount, last,
220 std::move(rightMinValues), std::forward<Vector>(maxValues));
229 const int colCount(last-first);
230 const int featDim(data.
features.rows());
233 Matrix d(featDim-1, colCount);
234 for (
int i = 0; i < colCount; ++i)
236 const Vector box = d.rowwise().maxCoeff() - d.rowwise().minCoeff();
237 const T boxDim(box.maxCoeff());
244 const Vector mean = d.rowwise().sum() /
T(colCount);
245 const Matrix NN = (d.colwise() - mean);
248 const Matrix C((NN * NN.transpose()) /
T(colCount));
249 Vector eigenVa = Vector::Identity(featDim-1, 1);
250 Matrix eigenVe = Matrix::Identity(featDim-1, featDim-1);
254 if(C.fullPivHouseholderQr().rank()+1 >= featDim-1)
256 const Eigen::EigenSolver<Matrix> solver(C);
257 eigenVa = solver.eigenvalues().real();
258 eigenVe = solver.eigenvectors().real();
269 normal = computeNormal<T>(eigenVa, eigenVe);
273 densitie = computeDensity<T>(NN);
279 serialEigVector = serializeEigVec<T>(eigenVe);
288 for(
int i=0; i<colCount; ++i)
290 const float r = (float)std::rand()/(float)RAND_MAX;
294 const int k = data.
indices[first+i];
312 const int k = data.
indices[first];
315 data.
features.col(k).topRows(featDim-1) = mean;
324 for (
int i = 0; i < colCount; ++i)
326 mergedDesc /=
T(colCount);
#define LOG_INFO_STREAM(args)
Matrix descriptors
descriptors of points in the cloud, might be empty
void buildNew(BuildData &data, const int first, const int last, Vector &&minValues, Vector &&maxValues) const
ConstView getDescriptorViewByName(const std::string &name) const
Get a const view on a descriptor by name, throw an exception if it does not exist.
const bool keepEigenValues
PointMatcher< T >::Vector Vector
boost::optional< View > eigenVectors
const bool keepEigenVectors
The name for a certain number of dim.
boost::optional< View > normals
PointMatcher< T >::DataPoints::InvalidField InvalidField
Parametrizable::Parameters Parameters
Functions and classes that are not dependant on scalar type are defined in this namespace.
const bool averageExistingDescriptors
DataPoints::Labels Labels
Functions and classes that are dependant on scalar type are defined in this templatized class...
Sampling surface normals. First decimate the space until there is at most knn points, then find the center of mass and use the points to estimate nromal using eigen-decomposition.
boost::optional< View > eigenValues
boost::optional< View > densities
virtual DataPoints filter(const DataPoints &input)
virtual void inPlaceFilter(DataPoints &cloud)
const M::mapped_type & get(const M &m, const typename M::key_type &k)
The superclass of classes that are constructed using generic parameters. This class provides the para...
void conservativeResize(Index pointCount)
Resize the cloud to pointCount points, conserving existing ones.
Eigen::Block< Matrix > View
A view on a feature or descriptor.
Int64Matrix times
time associated to each points, might be empty
Matrix features
features of points in the cloud
PointMatcher< T >::Matrix Matrix
PM::DataPointsFilter DataPointsFilter
SamplingSurfaceNormalDataPointsFilter(const Parameters ¶ms=Parameters())
void allocateDescriptors(const Labels &newLabels)
Make sure a vector of descriptors of given names exist.
const unsigned samplingMethod
void fuseRange(BuildData &data, const int first, const int last) const
Labels descriptorLabels
labels of descriptors