22 #ifndef _OPENGR_UTILS_REGISTRATION_METRICS_H 23 #define _OPENGR_UTILS_REGISTRATION_METRICS_H 25 #include "gr/accelerators/kdtree.h" 33 template <
typename Scalar>
38 template <
typename Range>
39 inline Scalar
operator()(
const gr::KdTree<Scalar> & ref,
41 const Eigen::Ref<
const Eigen::MatrixXf>& mat,
42 Scalar terminate_value = Scalar( 0 ))
44 using RangeQuery =
typename gr::KdTree<Scalar>::
template RangeQuery<>;
46 std::atomic_uint good_points(0);
48 const size_t number_of_points = target.size();
49 const size_t terminate_int_value = terminate_value * number_of_points;
52 for (size_t i = 0; i < number_of_points; ++i) {
56 query.queryPoint = (mat * target[i].pos().homogeneous()).
template head<3>();
57 query.sqdist = sq_eps;
59 if ( ref.doQueryRestrictedClosestIndex( query ).first != gr::KdTree<Scalar>::invalidIndex() ) {
64 if (number_of_points - i + good_points < terminate_int_value) {
break; }
66 return Scalar(good_points) / Scalar(number_of_points);
72 template <
typename Scalar>
77 template <
typename Range>
78 inline Scalar
operator()(
const gr::KdTree<Scalar> & ref,
80 const Eigen::Ref<
const Eigen::MatrixXf>& mat,
81 Scalar terminate_value = Scalar( 0 ))
83 using RangeQuery =
typename gr::KdTree<Scalar>::
template RangeQuery<>;
85 std::atomic<Scalar> good_points(0);
87 auto kernel = [](Scalar x) {
88 return std::pow(std::pow(x,4) - Scalar(1), 2);
91 auto computeWeight = [kernel](Scalar sqx, Scalar th) {
92 return kernel( std::sqrt(sqx) / th );
95 const size_t number_of_points = target.size();
96 const size_t terminate_int_value = terminate_value * number_of_points;
99 for (size_t i = 0; i < number_of_points; ++i) {
103 query.queryPoint = (mat * target[i].pos().homogeneous()).
template head<3>();
104 query.sqdist = sq_eps;
106 auto result = ref.doQueryRestrictedClosestIndex( query );
108 if ( result.first != gr::KdTree<Scalar>::invalidIndex() ) {
109 assert (result.second <= query.sqdist);
110 good_points = good_points + computeWeight(result.second, epsilon_);
114 if (number_of_points - i + good_points < terminate_int_value) {
break; }
116 return Scalar(good_points) / Scalar(number_of_points);
Scalar operator()(const gr::KdTree< Scalar > &ref, const Range &target, const Eigen::Ref< const Eigen::MatrixXf > &mat, Scalar terminate_value=Scalar(0))
Definition: registrationMetrics.h:39
Scalar epsilon_
Support size of the LCP.
Definition: registrationMetrics.h:36
Scalar epsilon_
Support size of the LCP.
Definition: registrationMetrics.h:75
Implementation of the Largest Common PointSet metric.
Definition: registrationMetrics.h:34
CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::Scalar ComputeTransformation(const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< typename CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::MatrixType > transformation, const Sampler< PointType > &sampler, TransformVisitor &v)
Definition: congruentSetExplorationBase.hpp:61
void get(int queryId, int nElPerDim, int, typename NeighborhoodType< 3 >::ptr first, typename NeighborhoodType< 3 >::ptr)
Definition: utils.h:279
Scalar operator()(const gr::KdTree< Scalar > &ref, const Range &target, const Eigen::Ref< const Eigen::MatrixXf > &mat, Scalar terminate_value=Scalar(0))
Definition: registrationMetrics.h:78
Implementation of a weighted variant of the Largest Common PointSet metric.
Definition: registrationMetrics.h:73