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 
101  boost::optional<View> normals;
102  boost::optional<View> densities;
103  boost::optional<View> eigenValues;
104  boost::optional<View> eigenVectors;
107 
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;
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 
SamplingSurfaceNormalDataPointsFilter::maxBoxDim
const T maxBoxDim
Definition: SamplingSurfaceNormal.h:78
SamplingSurfaceNormalDataPointsFilter::Parameters
Parametrizable::Parameters Parameters
Definition: SamplingSurfaceNormal.h:45
SamplingSurfaceNormalDataPointsFilter::BuildData::eigenValues
boost::optional< View > eigenValues
Definition: SamplingSurfaceNormal.h:103
SamplingSurfaceNormalDataPointsFilter::Parametrizable
PointMatcherSupport::Parametrizable Parametrizable
Definition: SamplingSurfaceNormal.h:43
Vector
PM::Vector Vector
Definition: pypoint_matcher_helper.h:55
DataPointsFilter
PM::DataPointsFilter DataPointsFilter
Definition: pypoint_matcher_helper.h:22
SamplingSurfaceNormalDataPointsFilter::BuildData
Definition: SamplingSurfaceNormal.h:92
SamplingSurfaceNormalDataPointsFilter::InvalidField
PointMatcher< T >::DataPoints::InvalidField InvalidField
Definition: SamplingSurfaceNormal.h:53
SamplingSurfaceNormalDataPointsFilter::buildNew
void buildNew(BuildData &data, const int first, const int last, Vector &&minValues, Vector &&maxValues) const
Definition: SamplingSurfaceNormal.cpp:172
build_map.T
T
Definition: build_map.py:34
SamplingSurfaceNormalDataPointsFilter::CompareDim::buildData
const BuildData & buildData
Definition: SamplingSurfaceNormal.h:123
SamplingSurfaceNormalDataPointsFilter::ParameterDoc
Parametrizable::ParameterDoc ParameterDoc
Definition: SamplingSurfaceNormal.h:46
SamplingSurfaceNormalDataPointsFilter::Matrix
PointMatcher< T >::Matrix Matrix
Definition: SamplingSurfaceNormal.h:51
SamplingSurfaceNormalDataPointsFilter::ParametersDoc
Parametrizable::ParametersDoc ParametersDoc
Definition: SamplingSurfaceNormal.h:47
SamplingSurfaceNormalDataPointsFilter::BuildData::densities
boost::optional< View > densities
Definition: SamplingSurfaceNormal.h:102
PointMatcher
Functions and classes that are dependant on scalar type are defined in this templatized class.
Definition: PointMatcher.h:130
SamplingSurfaceNormalDataPointsFilter::keepNormals
const bool keepNormals
Definition: SamplingSurfaceNormal.h:80
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
SamplingSurfaceNormalDataPointsFilter::keepEigenValues
const bool keepEigenValues
Definition: SamplingSurfaceNormal.h:82
SamplingSurfaceNormalDataPointsFilter::BuildData::Indices
std::vector< int > Indices
Definition: SamplingSurfaceNormal.h:94
testing::internal::string
::std::string string
Definition: gtest.h:1979
SamplingSurfaceNormalDataPointsFilter::availableParameters
static const ParametersDoc availableParameters()
Definition: SamplingSurfaceNormal.h:60
SamplingSurfaceNormalDataPointsFilter::InvalidParameter
Parametrizable::InvalidParameter InvalidParameter
Definition: SamplingSurfaceNormal.h:48
SamplingSurfaceNormalDataPointsFilter::CompareDim::operator()
bool operator()(const int &p0, const int &p1)
Definition: SamplingSurfaceNormal.h:125
SamplingSurfaceNormalDataPointsFilter::fuseRange
void fuseRange(BuildData &data, const int first, const int last) const
Definition: SamplingSurfaceNormal.cpp:224
PointMatcher::DataPoints::InvalidField
An exception thrown when one tries to access features or descriptors unexisting or of wrong dimension...
Definition: PointMatcher.h:250
SamplingSurfaceNormalDataPointsFilter::P
PointMatcherSupport::Parametrizable P
Definition: SamplingSurfaceNormal.h:44
SamplingSurfaceNormalDataPointsFilter::BuildData::normals
boost::optional< View > normals
Definition: SamplingSurfaceNormal.h:101
SamplingSurfaceNormalDataPointsFilter::DataPoints
PointMatcher< T >::DataPoints DataPoints
Definition: SamplingSurfaceNormal.h:52
SamplingSurfaceNormalDataPointsFilter::CompareDim::CompareDim
CompareDim(const int dim, const BuildData &buildData)
Definition: SamplingSurfaceNormal.h:124
PointMatcherSupport::Parametrizable::ParametersDoc
std::vector< ParameterDoc > ParametersDoc
The documentation of all parameters.
Definition: Parametrizable.h:187
SamplingSurfaceNormalDataPointsFilter::samplingMethod
const unsigned samplingMethod
Definition: SamplingSurfaceNormal.h:77
SamplingSurfaceNormalDataPointsFilter::BuildData::unfitPointsCount
int unfitPointsCount
Definition: SamplingSurfaceNormal.h:106
align_sequence.params
params
Definition: align_sequence.py:13
SamplingSurfaceNormalDataPointsFilter
Sampling surface normals. First decimate the space until there is at most knn points,...
Definition: SamplingSurfaceNormal.h:41
icp.data
data
Definition: icp.py:50
PointMatcher::Matrix
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > Matrix
A dense matrix over ScalarType.
Definition: PointMatcher.h:169
SamplingSurfaceNormalDataPointsFilter::SamplingSurfaceNormalDataPointsFilter
SamplingSurfaceNormalDataPointsFilter(const Parameters &params=Parameters())
Definition: SamplingSurfaceNormal.cpp:51
SamplingSurfaceNormalDataPointsFilter::BuildData::BuildData
BuildData(Matrix &features, Matrix &descriptors)
Definition: SamplingSurfaceNormal.h:108
SamplingSurfaceNormalDataPointsFilter::BuildData::outputInsertionPoint
int outputInsertionPoint
Definition: SamplingSurfaceNormal.h:105
SamplingSurfaceNormalDataPointsFilter::keepDensities
const bool keepDensities
Definition: SamplingSurfaceNormal.h:81
SamplingSurfaceNormalDataPointsFilter::~SamplingSurfaceNormalDataPointsFilter
virtual ~SamplingSurfaceNormalDataPointsFilter()
Definition: SamplingSurfaceNormal.h:87
PointMatcherSupport::Parametrizable::InvalidParameter
An exception thrown when one tries to fetch the value of an unexisting parameter.
Definition: Parametrizable.h:144
SamplingSurfaceNormalDataPointsFilter::filter
virtual DataPoints filter(const DataPoints &input)
Definition: SamplingSurfaceNormal.cpp:70
PointMatcher::Vector
Eigen::Matrix< T, Eigen::Dynamic, 1 > Vector
A vector over ScalarType.
Definition: PointMatcher.h:161
SamplingSurfaceNormalDataPointsFilter::BuildData::eigenVectors
boost::optional< View > eigenVectors
Definition: SamplingSurfaceNormal.h:104
SamplingSurfaceNormalDataPointsFilter::averageExistingDescriptors
const bool averageExistingDescriptors
Definition: SamplingSurfaceNormal.h:79
SamplingSurfaceNormalDataPointsFilter::description
static const std::string description()
Definition: SamplingSurfaceNormal.h:56
SamplingSurfaceNormalDataPointsFilter::knn
const unsigned knn
Definition: SamplingSurfaceNormal.h:76
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
SamplingSurfaceNormalDataPointsFilter::Vector
PointMatcher< T >::Vector Vector
Definition: SamplingSurfaceNormal.h:50
PointMatcherSupport::Parametrizable::ParameterDoc
The documentation of a parameter.
Definition: Parametrizable.h:160
SamplingSurfaceNormalDataPointsFilter::ratio
const T ratio
Definition: SamplingSurfaceNormal.h:75
PointMatcher::DataPoints::View
Eigen::Block< Matrix > View
A view on a feature or descriptor.
Definition: PointMatcher.h:210
SamplingSurfaceNormalDataPointsFilter::CompareDim::dim
const int dim
Definition: SamplingSurfaceNormal.h:122
SamplingSurfaceNormalDataPointsFilter::keepEigenVectors
const bool keepEigenVectors
Definition: SamplingSurfaceNormal.h:83
SamplingSurfaceNormalDataPointsFilter::BuildData::indicesToKeep
Indices indicesToKeep
Definition: SamplingSurfaceNormal.h:98
SamplingSurfaceNormalDataPointsFilter::BuildData::indices
Indices indices
Definition: SamplingSurfaceNormal.h:97
SamplingSurfaceNormalDataPointsFilter::BuildData::View
DataPoints::View View
Definition: SamplingSurfaceNormal.h:95
SamplingSurfaceNormalDataPointsFilter::BuildData::descriptors
Matrix & descriptors
Definition: SamplingSurfaceNormal.h:100
PointMatcher.h
public interface
SamplingSurfaceNormalDataPointsFilter::BuildData::features
Matrix & features
Definition: SamplingSurfaceNormal.h:99
SamplingSurfaceNormalDataPointsFilter::CompareDim
Definition: SamplingSurfaceNormal.h:120
SamplingSurfaceNormalDataPointsFilter::inPlaceFilter
virtual void inPlaceFilter(DataPoints &cloud)
Definition: SamplingSurfaceNormal.cpp:80
PointMatcherSupport::Parametrizable::Parameters
std::map< std::string, Parameter > Parameters
Parameters stored as a map of string->string.
Definition: Parametrizable.h:199


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:10