SamplingSurfaceNormal.h
Go to the documentation of this file.
1 // kate: replace-tabs off; indent-width 4; indent-mode normal
2 // vim: ts=4:sw=4:noexpandtab
3 /*
4 
5 Copyright (c) 2010--2018,
6 François Pomerleau and Stephane Magnenat, ASL, ETHZ, Switzerland
7 You can contact the authors at <f dot pomerleau at gmail dot com> and
8 <stephane at magnenat dot net>
9 
10 All rights reserved.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of the <organization> nor the
20  names of its contributors may be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 DISCLAIMED. IN NO EVENT SHALL ETH-ASL BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 #pragma once
36 
37 #include "PointMatcher.h"
38 
40 template<typename T>
42 {
49 
50  typedef typename PointMatcher<T>::Vector Vector;
51  typedef typename PointMatcher<T>::Matrix Matrix;
54 
55 
56  inline static const std::string description()
57  {
58  return "Subsampling, Normals. This filter decomposes the point-cloud space in boxes, by recursively splitting the cloud through axis-aligned hyperplanes such as to maximize the evenness of the aspect ratio of the box. When the number of points in a box reaches a value knn or lower, the filter computes the center of mass of these points and its normal by taking the eigenvector corresponding to the smallest eigenvalue of all points in the box.";
59  }
60  inline static const ParametersDoc availableParameters()
61  {
62  return {
63  {"ratio", "ratio of points to keep with random subsampling. Matrix (normal, density, etc.) will be associated to all points in the same bin.", "0.5", "0.0000001", "1.0", &P::Comp<T>},
64  {"knn", "determined how many points are used to compute the normals. Direct link with the rapidity of the computation (large = fast). Technically, limit over which a box is splitted in two", "7", "3", "2147483647", &P::Comp<unsigned>},
65  {"samplingMethod", "if set to 0, random subsampling using the parameter ratio. If set to 1, bin subsampling with the resulting number of points being 1/knn.", "0", "0", "1", &P::Comp<unsigned>},
66  {"maxBoxDim", "maximum length of a box above which the box is discarded", "inf"},
67  {"averageExistingDescriptors", "whether the filter keep the existing point descriptors and average them or should it drop them", "1"},
68  {"keepNormals", "whether the normals should be added as descriptors to the resulting cloud", "1"},
69  {"keepDensities", "whether the point densities should be added as descriptors to the resulting cloud", "0"},
70  {"keepEigenValues", "whether the eigen values should be added as descriptors to the resulting cloud", "0"},
71  {"keepEigenVectors", "whether the eigen vectors should be added as descriptors to the resulting cloud", "0"}
72  };
73  }
74 
75  const T ratio;
76  const unsigned knn;
77  const unsigned samplingMethod;
78  const T maxBoxDim;
80  const bool keepNormals;
81  const bool keepDensities;
82  const bool keepEigenValues;
83  const bool keepEigenVectors;
84 
85 public:
88  virtual DataPoints filter(const DataPoints& input);
89  virtual void inPlaceFilter(DataPoints& cloud);
90 
91 protected:
92  struct BuildData
93  {
94  typedef std::vector<int> Indices;
95  typedef typename DataPoints::View View;
96 
97  Indices indices;
98  Indices indicesToKeep;
99  Matrix& features;
100  Matrix& descriptors;
101  boost::optional<View> normals;
102  boost::optional<View> densities;
103  boost::optional<View> eigenValues;
104  boost::optional<View> eigenVectors;
107 
108  BuildData(Matrix& features, Matrix& descriptors):
109  features(features),
110  descriptors(descriptors),
111  unfitPointsCount(0)
112  {
113  const int pointsCount(features.cols());
114  indices.reserve(pointsCount);
115  for (int i = 0; i < pointsCount; ++i)
116  indices.push_back(i);
117  }
118  };
119 
120  struct CompareDim
121  {
122  const int dim;
124  CompareDim(const int dim, const BuildData& buildData):dim(dim),buildData(buildData){}
125  bool operator() (const int& p0, const int& p1)
126  {
127  return buildData.features(dim, p0) <
128  buildData.features(dim, p1);
129  }
130  };
131 
132 protected:
133  void buildNew(BuildData& data, const int first, const int last, Vector&& minValues, Vector&& maxValues) const;
134  void fuseRange(BuildData& data, const int first, const int last) const;
135 };
136 
Parametrizable::ParametersDoc ParametersDoc
public interface
void buildNew(BuildData &data, const int first, const int last, Vector &&minValues, Vector &&maxValues) const
CompareDim(const int dim, const BuildData &buildData)
::std::string string
Definition: gtest.h:1979
data
Definition: icp.py:50
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
PointMatcher< T >::DataPoints::InvalidField InvalidField
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Functions and classes that are dependant on scalar type are defined in this templatized class...
Definition: PointMatcher.h:130
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.
virtual DataPoints filter(const DataPoints &input)
Parametrizable::ParameterDoc ParameterDoc
virtual void inPlaceFilter(DataPoints &cloud)
The documentation of a parameter.
BuildData(Matrix &features, Matrix &descriptors)
The superclass of classes that are constructed using generic parameters. This class provides the para...
An exception thrown when one tries to fetch the value of an unexisting parameter. ...
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
Eigen::Block< Matrix > View
A view on a feature or descriptor.
Definition: PointMatcher.h:210
An exception thrown when one tries to access features or descriptors unexisting or of wrong dimension...
Definition: PointMatcher.h:250
PointMatcher< T >::DataPoints DataPoints
PointMatcherSupport::Parametrizable Parametrizable
Parametrizable::InvalidParameter InvalidParameter
static const ParametersDoc availableParameters()
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector over ScalarType.
Definition: PointMatcher.h:161
PM::DataPointsFilter DataPointsFilter
SamplingSurfaceNormalDataPointsFilter(const Parameters &params=Parameters())
void fuseRange(BuildData &data, const int first, const int last) const
PointMatcherSupport::Parametrizable P


libpointmatcher
Author(s):
autogenerated on Sat May 27 2023 02:38:03