gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions > Class Template Reference

Class for the computation of the 4PCS algorithm. More...

#include <match4pcsBase.h>

+ Inheritance diagram for gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >:
+ Collaboration diagram for gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >:

Public Types

using CongruentBaseType = typename MatchBaseType::CongruentBaseType
 
using Coordinates = typename MatchBaseType::Coordinates
 
using Functor = _Functor< PosMutablePoint, PairFilteringFunctor, OptionsType >
 
using MatchBaseType = CongruentSetExplorationBase< Traits4pcs< PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
 
using MatrixType = typename MatchBaseType::MatrixType
 
using OptionsType = typename MatchBaseType::OptionsType
 
using PairFilteringFunctor = _PairFilteringFunctor
 
using PosMutablePoint = typename MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint
 
using Scalar = typename _PointType::Scalar
 
using Set = typename MatchBaseType::Set
 
using TransformVisitor = typename MatchBaseType::TransformVisitor
 
using VectorType = typename MatchBaseType::VectorType
 
- Public Types inherited from gr::CongruentSetExplorationBase< Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
using CongruentBaseType = typename Traits::Base
 
using Coordinates = typename Traits::Coordinates
 
using LogLevel = typename MatchBaseType::LogLevel
 
using MatchBaseType = MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
 
using MatrixType = typename MatchBaseType::MatrixType
 
using OptionsType = typename MatchBaseType::OptionsType
 
using PairFilteringFunctor = _PairFilteringFunctor
 
using PairsVector = std::vector< std::pair< int, int > >
 
using PosMutablePoint = typename MatchBaseType::PosMutablePoint
 
using RegistrationMetric = Utils::LCPMetric< Scalar >
 
using Scalar = typename MatchBaseType::Scalar
 
using Set = typename Traits::Set
 
using Traits = Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >
 
using TransformVisitor = _TransformVisitor
 
using VectorType = typename MatchBaseType::VectorType
 
- Public Types inherited from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
using LogLevel = Utils::LogLevel
 
using MatrixType = Eigen::Matrix< Scalar, 4, 4 >
 
using OptionsType = gr::Utils::CRTP< PairFilteringOptions......, Options >
 
using Scalar = typename _PointType::Scalar
 
using TransformVisitor = _TransformVisitor
 
using VectorType = typename _PointType::VectorType
 

Public Member Functions

bool generateCongruents (CongruentBaseType &base, Set &congruent_quads) override
 Find all the congruent set similar to the base in the second 3D model (Q). It could be with a 3 point base or a 4 point base. More...
 
const FunctorgetFunctor () const
 
bool initBase (CongruentBaseType &base) override
 Tries to compute an inital base from P. More...
 
void Initialize () override
 Initializes the data structures and needed values before the match computation. This method is called once the internal state of the Base class as been set. More...
 
 Match4pcsBase (const OptionsType &options, const Utils::Logger &logger)
 
bool SelectQuadrilateral (Scalar &invariant1, Scalar &invariant2, int &base1, int &base2, int &base3, int &base4)
 Selects a random triangle in the set P (then we add another point to keep the base as planar as possible). We apply a simple heuristic that works in most practical cases. The idea is to accept maximum distance, computed by the estimated overlap, multiplied by the diameter of P, and try to have a triangle with all three edges close to this distance. Wide triangles helps to make the transformation robust while too large triangles makes the probability of having all points in the inliers small so we try to trade-off. More...
 
bool TryQuadrilateral (Scalar &invariant1, Scalar &invariant2, int &id1, int &id2, int &id3, int &id4)
 Takes quadrilateral as a base, computes robust intersection point (approximate as the lines might not intersect) and returns the invariants corresponding to the two selected lines. The method also updates the order of the base base_3D_. More...
 
virtual ~Match4pcsBase ()
 
- Public Member Functions inherited from gr::CongruentSetExplorationBase< Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
Scalar ComputeTransformation (const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< MatrixType > transformation, const Sampler< _PointType > &sampler, TransformVisitor &v)
 Computes an approximation of the best LCP (directional) from Q to P and the rigid transformation that realizes it. The input sets may or may not contain normal information for any point. More...
 
EIGEN_MAKE_ALIGNED_OPERATOR_NEW CongruentSetExplorationBase (const OptionsType &options, const Utils::Logger &logger)
 
virtual bool initBase (CongruentBaseType &base)=0
 Tries to compute an inital base from P. More...
 
virtual ~CongruentSetExplorationBase ()
 
- Public Member Functions inherited from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
Scalar ComputeTransformation (const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< MatrixType > transformation, const Sampler< _PointType > &sampler, TransformVisitor &v)
 Computes an approximation of the best LCP (directional) from Q to P and the rigid transformation that realizes it. The input sets may or may not contain normal information for any point. More...
 
const std::vector< PosMutablePoint > & getFirstSampled () const
 Read access to the sampled clouds used for the registration. More...
 
const std::vector< PosMutablePoint > & getSecondSampled () const
 Read access to the sampled clouds used for the registration. More...
 
EIGEN_MAKE_ALIGNED_OPERATOR_NEW MatchBase (const OptionsType &options, const Utils::Logger &logger)
 
virtual ~MatchBase ()
 

Protected Member Functions

virtual bool initBase (CongruentBaseType &base, Scalar &invariant1, Scalar &invariant2)
 
- Protected Member Functions inherited from gr::CongruentSetExplorationBase< Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
const CongruentBaseTypebase3D () const
 
virtual bool generateCongruents (CongruentBaseType &base, Set &congruent_set)=0
 Find all the congruent set similar to the base in the second 3D model (Q). It could be with a 3 point base or a 4 point base. More...
 
bool Perform_N_steps (int n, Eigen::Ref< MatrixType > transformation, TransformVisitor &v)
 Performs n RANSAC iterations, each one of them containing base selection, finding congruent sets and verification. Returns true if the process can be terminated (the target LCP was obtained or the maximum number of trials has been reached), false otherwise. More...
 
bool TryCongruentSet (CongruentBaseType &base, Set &set, TransformVisitor &v, size_t &nbCongruent)
 Loop over the set of congruent 4-points and test the compatibility with the input base. More...
 
bool TryOneBase (TransformVisitor &v)
 Tries one base and finds the best transformation for this base. Returns true if the achieved LCP is greater than terminate_threshold_, else otherwise. More...
 
Scalar Verify (const Eigen::Ref< const MatrixType > &mat) const
 For each randomly picked base, verifies the computed transformation by computing the number of points that this transformation brings near points in Q. Returns the current LCP. R is the rotation matrix, (tx,ty,tz) is the translation vector and (cx,cy,cz) is the center of transformation.template <class matrixderived>=""> More...
 
- Protected Member Functions inherited from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
bool ComputeRigidTransformation (const Coordinates &ref, const Coordinates &candidate, const Eigen::Matrix< Scalar, 3, 1 > &centroid1, Eigen::Matrix< Scalar, 3, 1 > centroid2, Eigen::Ref< MatrixType > transform, Scalar &rms_, bool computeScale) const
 Computes the best rigid transformation between three corresponding pairs. The transformation is characterized by rotation matrix, translation vector and a center about which we rotate. The set of pairs is potentially being updated by the best permutation of the second set. Returns the RMS of the fit. The method is being called with n points but it applies the fit for only 3 after the best permutation is selected in the second set (see bellow). This is done because the solution for planar points is much simpler. The method is the closed-form solution by Horn: people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf. More...
 
void init (const InputRange1 &P, const InputRange2 &Q, const Sampler< _PointType > &sampler)
 Initializes the internal state of the Base class. More...
 
void Log (Args...args) const
 
Scalar MeanDistance () const
 Computes the mean distance between points in Q and their nearest neighbor. We need this for normalization of the user delta (See the paper) to the "scale" of the set. More...
 
bool SelectRandomTriangle (Scalar max_base_diameter, int &base1, int &base2, int &base3)
 Selects a random triangle in the set P (then we add another point to keep the base as planar as possible). We apply a simple heuristic that works in most practical cases. The idea is to accept maximum distance, computed by the estimated overlap, multiplied by the diameter of P, and try to have a triangle with all three edges close to this distance. Wide triangles helps to make the transformation robust while too large triangles makes the probability of having all points in the inliers small so we try to trade-off. More...
 

Protected Attributes

Functor fun_
 
- Protected Attributes inherited from gr::CongruentSetExplorationBase< Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
CongruentBaseType base_
 The points in the base (indices to P). It is being updated in every RANSAC iteration. More...
 
Coordinates base_3D_
 The 3D points of the base. More...
 
Scalar best_LCP_
 The best LCP (Largest Common Point) fraction so far. More...
 
CongruentBaseType current_congruent_
 The current congruent 4 points from Q. Every RANSAC iteration the algorithm examines a set of such congruent 4-points from Q and retains the best from them (the one that realizes the best LCP). More...
 
int current_trial_
 Current trial. More...
 
Scalar max_base_diameter_
 Maximum base diameter. It is computed automatically from the diameter of P and the estimated overlap and used to limit the distance between the points in the base in P so that the probability to have all points in the base as inliers is increased. More...
 
int number_of_trials_
 Number of trials. Every trial picks random base from P. More...
 
- Protected Attributes inherited from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
VectorType centroid_P_
 The centroid of P. More...
 
VectorType centroid_Q_
 The centroid of Q. More...
 
KdTree< Scalarkd_tree_
 KdTree used to compute the LCP. More...
 
const Utils::Loggerlogger_
 
OptionsType options_
 
Scalar P_diameter_
 The diameter of P. More...
 
Scalar P_mean_distance_
 Mean distance between points and their nearest neighbor in the set P. Used to normalize the "delta" which is given in terms of this distance. More...
 
VectorType qcentroid1_
 
VectorType qcentroid2_
 
std::mt19937 randomGenerator_
 
std::vector< PosMutablePoint > sampled_P_3D_
 Sampled P (3D coordinates). More...
 
std::vector< PosMutablePoint > sampled_Q_3D_
 Sampled Q (3D coordinates). More...
 
Eigen::Matrix< Scalar, 4, 4 > transform_
 The transformation matrix by wich we transform Q to P. More...
 

Additional Inherited Members

- Static Public Attributes inherited from gr::CongruentSetExplorationBase< Traits4pcs< MatchBase< _PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions >::PosMutablePoint >, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >
static constexpr Scalar distance_factor
 
static constexpr Scalar kLargeNumber
 
- Static Protected Attributes inherited from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >
static constexpr int kNumberOfDiameterTrials
 

Detailed Description

template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
class gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >

Class for the computation of the 4PCS algorithm.

Parameters
Functoruse to determinate the use of Super4pcs or 4pcs algorithm.

Member Typedef Documentation

template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::CongruentBaseType = typename MatchBaseType::CongruentBaseType
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::Coordinates = typename MatchBaseType::Coordinates
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::Functor = _Functor<PosMutablePoint, PairFilteringFunctor, OptionsType>
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::MatchBaseType = CongruentSetExplorationBase<Traits4pcs<PosMutablePoint>, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions>
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::MatrixType = typename MatchBaseType::MatrixType
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::OptionsType = typename MatchBaseType::OptionsType
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::PairFilteringFunctor = _PairFilteringFunctor
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::PosMutablePoint = typename MatchBase<_PointType, _TransformVisitor, PairFilteringOptions, CongruentSetExplorationOptions>::PosMutablePoint
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::Scalar = typename _PointType::Scalar
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::Set = typename MatchBaseType::Set
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::TransformVisitor = typename MatchBaseType::TransformVisitor
template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
using gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::VectorType = typename MatchBaseType::VectorType

Constructor & Destructor Documentation

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::Match4pcsBase ( const OptionsType options,
const Utils::Logger logger 
)
inline

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::~Match4pcsBase ( )
virtual

Member Function Documentation

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
bool gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::generateCongruents ( CongruentBaseType base,
Set congruent_quads 
)
override

Find all the congruent set similar to the base in the second 3D model (Q). It could be with a 3 point base or a 4 point base.

Parameters
baseuse to find the similar points congruent in Q.
congruent_seta set of all point congruent found in Q.

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
const Functor& gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::getFunctor ( ) const
inline
template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
bool gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::initBase ( CongruentBaseType base)
override

Tries to compute an inital base from P.

Parameters
[out]baseThe base, if found. Initial value is not used. Modified as the computed base if the return value is true.
Returns
true if a base is found an initialized, false otherwise

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
bool gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::initBase ( CongruentBaseType base,
Scalar invariant1,
Scalar invariant2 
)
protectedvirtual

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
void gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::Initialize ( )
overridevirtual

Initializes the data structures and needed values before the match computation. This method is called once the internal state of the Base class as been set.

Reimplemented from gr::MatchBase< _PointType, _TransformVisitor, PairFilteringOptions..., CongruentSetExplorationOptions >.

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename PointType , typename TransformVisitor , typename PairFilteringFunctor , template< class, class > class PFO>
bool gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::SelectQuadrilateral ( Scalar invariant1,
Scalar invariant2,
int base1,
int base2,
int base3,
int base4 
)
inline

Selects a random triangle in the set P (then we add another point to keep the base as planar as possible). We apply a simple heuristic that works in most practical cases. The idea is to accept maximum distance, computed by the estimated overlap, multiplied by the diameter of P, and try to have a triangle with all three edges close to this distance. Wide triangles helps to make the transformation robust while too large triangles makes the probability of having all points in the inliers small so we try to trade-off.

+ Here is the call graph for this function:

template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
bool gr::Match4pcsBase< _Functor, PointType, TransformVisitor, PairFilteringFunctor, PFO >::TryQuadrilateral ( Scalar invariant1,
Scalar invariant2,
int id1,
int id2,
int id3,
int id4 
)
inline

Takes quadrilateral as a base, computes robust intersection point (approximate as the lines might not intersect) and returns the invariants corresponding to the two selected lines. The method also updates the order of the base base_3D_.

+ Here is the call graph for this function:

Member Data Documentation

template<template< typename, typename, typename > class _Functor, typename _PointType, typename _TransformVisitor, typename _PairFilteringFunctor, template< class, class > class PairFilteringOptions>
Functor gr::Match4pcsBase< _Functor, _PointType, _TransformVisitor, _PairFilteringFunctor, PairFilteringOptions >::fun_
protected

The documentation for this class was generated from the following files: