AddDescriptor.cpp
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 #include "AddDescriptor.h"
5 
6 template <typename T>
8  PointMatcher<T>::DataPointsFilter("AddDescriptorDataPointsFilter",
9  AddDescriptorDataPointsFilter::availableParameters(), params),
10  descriptorName(Parametrizable::get<std::string>("descriptorName")),
11  descriptorDimension(Parametrizable::get<std::size_t>("descriptorDimension")),
12  descriptorValues(Parametrizable::getVector<T>("descriptorValues"))
13 {
14  assert(descriptorDimension == descriptorValues.size());
15 }
16 
17 // AddDescriptorDataPointsFilter
18 template<typename T>
20  const DataPoints& input)
21 {
22  DataPoints output(input);
23  inPlaceFilter(output);
24  return output;
25 }
26 
27 // In-place filter
28 template<typename T>
30  DataPoints& cloud)
31 {
32  Matrix matrix = PM::Matrix::Ones(descriptorDimension, cloud.getNbPoints());
33  for(std::size_t i = 0; i < descriptorDimension; ++i)
34  {
35  matrix.row(i) *= descriptorValues[i];
36  }
37  if(!cloud.descriptorExists(descriptorName))
38  {
39  cloud.addDescriptor(descriptorName, matrix);
40  }
41  else
42  {
43  if(descriptorDimension == cloud.getDescriptorDimension(descriptorName))
44  {
45  cloud.getDescriptorViewByName(descriptorName) = matrix;
46  }
47  else
48  {
49  // FIXME deal with overwriting descriptors that have different dimensions
50  throw std::runtime_error("Can't overwrite existing descriptor " + descriptorName + " with dimension " +
51  std::to_string(cloud.getDescriptorDimension(descriptorName)) +
52  " by a new descriptor with dimension " +
53  std::to_string(descriptorDimension) + ".");
54  }
55  }
56 
57 }
58 
build_map.T
T
Definition: build_map.py:34
PointMatcher::DataPoints::descriptorExists
bool descriptorExists(const std::string &name) const
Look if a descriptor with a given name exist.
Definition: pointmatcher/DataPoints.cpp:583
AddDescriptorDataPointsFilter::inPlaceFilter
virtual void inPlaceFilter(DataPoints &cloud)
Apply these filters to a point cloud without copying.
Definition: AddDescriptor.cpp:29
PointMatcher::DataPoints::addDescriptor
void addDescriptor(const std::string &name, const Matrix &newDescriptor)
Add a descriptor by name, remove first if already exists.
Definition: pointmatcher/DataPoints.cpp:533
PointMatcher
Functions and classes that are dependant on scalar type are defined in this templatized class.
Definition: PointMatcher.h:130
PointMatcher::DataPoints
A point cloud.
Definition: PointMatcher.h:207
testing::internal::string
::std::string string
Definition: gtest.h:1979
AddDescriptor.h
align_sequence.params
params
Definition: align_sequence.py:13
AddDescriptorDataPointsFilter
Add new descriptor to an existing point cloud.
Definition: AddDescriptor.h:10
PointMatcher::DataPointsFilter
A data filter takes a point cloud as input, transforms it, and produces another point cloud as output...
Definition: PointMatcher.h:440
PointMatcher::DataPoints::getNbPoints
unsigned getNbPoints() const
Return the number of points contained in the point cloud.
Definition: pointmatcher/DataPoints.cpp:158
PointMatcherSupport::Parametrizable
The superclass of classes that are constructed using generic parameters. This class provides the para...
Definition: Parametrizable.h:141
std
PointMatcherSupport::get
const M::mapped_type & get(const M &m, const typename M::key_type &k)
Definition: Bibliography.cpp:57
PointMatcher::DataPoints::getDescriptorDimension
unsigned getDescriptorDimension(const std::string &name) const
Return the dimension of a descriptor with a given name. Return 0 if the name is not found.
Definition: pointmatcher/DataPoints.cpp:597
AddDescriptorDataPointsFilter::descriptorValues
const std::vector< T > descriptorValues
Definition: AddDescriptor.h:30
AddDescriptorDataPointsFilter::filter
virtual DataPoints filter(const DataPoints &input)
Apply filters to input point cloud. This is the non-destructive version and returns a copy.
Definition: AddDescriptor.cpp:19
AddDescriptorDataPointsFilter::AddDescriptorDataPointsFilter
AddDescriptorDataPointsFilter(const Parameters &params=Parameters())
Definition: AddDescriptor.cpp:7
PointMatcher::DataPoints::getDescriptorViewByName
ConstView getDescriptorViewByName(const std::string &name) const
Get a const view on a descriptor by name, throw an exception if it does not exist.
Definition: pointmatcher/DataPoints.cpp:555
AddDescriptorDataPointsFilter::Parameters
Parametrizable::Parameters Parameters
Definition: AddDescriptor.h:19
AddDescriptorDataPointsFilter::Matrix
PointMatcher< T >::Matrix Matrix
Definition: AddDescriptor.h:24
AddDescriptorDataPointsFilter::descriptorDimension
const std::size_t descriptorDimension
Definition: AddDescriptor.h:29


libpointmatcher
Author(s):
autogenerated on Mon Jan 1 2024 03:24:42