5 #ifndef OPENGR_FUNCTORFEATUREPOINTTEST_H 6 #define OPENGR_FUNCTORFEATUREPOINTTEST_H 8 #include "gr/utils/shared.h" 13 #ifdef PARSED_BY_DOXYGEN 37 template <
class Derived,
class TBase>
42 template <
typename PointType,
typename WantedOptionsAndMore>
43 inline std::pair<
bool,
bool>
operator() (
const PointType& ,
45 typename PointType::Scalar ,
48 const WantedOptionsAndMore &options) {
49 return std::make_pair(options.dummyFilteringResponse, options.dummyFilteringResponse);
60 template <
class Derived,
class TBase>
62 using Scalar =
typename TBase::Scalar;
75 template <
typename PointType,
typename WantedOptionsAndMore>
76 inline std::pair<
bool,
bool>
operator() (
const PointType& p,
78 typename PointType::Scalar pair_normals_angle,
81 const WantedOptionsAndMore &options) {
82 static_assert( WantedOptionsAndMore::IS_ADAPTIVEPOINTFILTER_OPTIONS,
83 "Options passed to AdaptivePointFilter must inherit AdaptivePointFilter::Options" );
84 using Scalar =
typename PointType::Scalar;
85 using VectorType =
typename PointType::VectorType;
88 std::pair<
bool,
bool> res;
92 VectorType segment1 = (b1.pos() - b0.pos()).normalized();
94 if ( options.max_normal_difference > 0 &&
95 q.normal().squaredNorm() > 0 &&
96 p.normal().squaredNorm() > 0) {
97 const Scalar norm_threshold =
98 0.5 * options.max_normal_difference *
M_PI / 180.0;
99 const double first_normal_angle = (q.normal() - p.normal()).norm();
100 const double second_normal_angle = (q.normal() + p.normal()).norm();
102 const Scalar first_norm_distance =
103 std::min(std::abs(first_normal_angle - pair_normals_angle),
104 std::abs(second_normal_angle - pair_normals_angle));
107 if (first_norm_distance > norm_threshold)
return res;
110 if (options.max_color_distance > 0) {
111 const bool use_rgb = (p.rgb()[0] >= 0 && q.rgb()[0] >= 0 &&
114 bool color_good = (p.rgb() - b0.rgb()).norm() <
115 options.max_color_distance &&
116 (q.rgb() - b1.rgb()).norm() <
117 options.max_color_distance;
119 if (use_rgb && ! color_good)
return res;
122 if (options.max_translation_distance > 0) {
123 const bool dist_good = (p.pos() - b0.pos()).norm() <
124 options.max_translation_distance &&
125 (q.pos() - b1.pos()).norm() <
126 options.max_translation_distance;
127 if (! dist_good)
return res;
131 if (options.max_angle > 0){
132 VectorType segment2 = (q.pos() - p.pos()).normalized();
133 if (std::acos(segment1.dot(segment2)) <= options.max_angle *
M_PI / 180.0) {
137 if (std::acos(segment1.dot(- segment2)) <= options.max_angle *
M_PI / 180.0) {
std::pair< bool, bool > operator()(const PointType &p, const PointType &q, typename PointType::Scalar pair_normals_angle, const PointType &b0, const PointType &b1, const WantedOptionsAndMore &options)
Verify that the 2 points found in Q are similar to 2 of the points in the base. A filter by point fea...
Definition: PointPairFilter.h:76
Functor used in n-pcs algorithm to filters pairs of points according to the exploration basis...
Definition: PointPairFilter.h:59
Definition: PointPairFilter.h:69
Definition: PointPairFilter.h:40
Definition: PointPairFilter.h:38
Scalar max_color_distance
Maximum color RGB distance between corresponding vertices. Set negative to ignore.
Definition: PointPairFilter.h:67
#define M_PI
Definition: utils.h:57
Functor used in n-pcs algorithm to filters pairs of points according to the exploration basis...
Definition: PointPairFilter.h:36
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
bool dummyFilteringResponse
Definition: PointPairFilter.h:39
Definition: PointPairFilter.h:61
Scalar max_normal_difference
Maximum normal difference.
Definition: PointPairFilter.h:65
std::pair< bool, bool > operator()(const PointType &, const PointType &, typename PointType::Scalar, const PointType &, const PointType &, const WantedOptionsAndMore &options)
Definition: PointPairFilter.h:43