1 #ifndef _SUPER4PCS_ALGO_PAIRCREATIONFUNCTOR_H 2 #define _SUPER4PCS_ALGO_PAIRCREATIONFUNCTOR_H 6 #include "super4pcs/shared4pcs.h" 8 #include "super4pcs/accelerators/bbox.h" 10 #include "super4pcs/accelerators/pairExtraction/bruteForceFunctor.h" 11 #include "super4pcs/accelerators/pairExtraction/intersectionFunctor.h" 12 #include "super4pcs/accelerators/pairExtraction/intersectionPrimitive.h" 16 template <
typename _Scalar>
32 const std::vector<Point3D>&
Q_;
36 std::vector<unsigned int>
ids;
40 typedef Eigen::Matrix<Scalar, 3, 1>
Point;
49 std::vector<Point3D> base_3D_;
50 int base_point1_, base_point2_;
59 const std::vector<Point3D>& Q)
60 :options_(options), Q_(Q),
61 pairs(NULL), _ratio(1.f)
65 inline Point worldToUnit(
66 const Eigen::MatrixBase<typename PairCreationFunctor::Point> &p)
const {
67 static const Point half = Point::Ones() *
Scalar(0.5f);
68 return (p-_gcenter) / _ratio + half;
74 const Eigen::MatrixBase<typename PairCreationFunctor::Point> &p)
const {
75 static const Point half = Point::Ones() *
Scalar(0.5f);
76 return (p - half) * _ratio + _gcenter;
96 unsigned int nSamples = Q_.size();
98 points.reserve(nSamples);
99 primitives.reserve(nSamples);
103 for (
unsigned int i = 0; i < nSamples; ++i) {
109 _gcenter = bbox.center();
111 _ratio = bbox.diagonal().maxCoeff() + 0.001;
116 for (
unsigned int i = 0; i < nSamples; ++i) {
117 points[i] = worldToUnit(points[i]);
119 primitives.emplace_back(points[i],
Scalar(1.));
125 const Scalar nRadius = radius/_ratio;
126 for(
typename std::vector< Primitive >::iterator it = primitives.begin();
127 it != primitives.end(); ++it)
128 (*it).radius() = nRadius;
135 inline void setBase(
int base_point1,
int base_point2,
136 const std::vector<Point3D>& base_3D){
138 base_point1_ = base_point1;
139 base_point2_ = base_point2;
141 segment1 = (base_3D_[base_point2_].pos() -
142 base_3D_[base_point1_].pos()).normalized();
167 q.
normal().squaredNorm() > 0 &&
168 p.
normal().squaredNorm() > 0) {
169 const Scalar norm_threshold =
171 const double first_normal_angle = (q.
normal() - p.
normal()).norm();
172 const double second_normal_angle = (q.
normal() + p.
normal()).norm();
174 const Scalar first_norm_distance =
175 std::min(std::abs(first_normal_angle - pair_normals_angle),
176 std::abs(second_normal_angle - pair_normals_angle));
179 if (first_norm_distance > norm_threshold)
return;
183 const bool use_rgb = (p.
rgb()[0] >= 0 && q.
rgb()[0] >= 0 &&
184 base_3D_[base_point1_].rgb()[0] >= 0 &&
185 base_3D_[base_point2_].rgb()[0] >= 0);
186 bool color_good = (p.
rgb() - base_3D_[base_point1_].rgb()).norm() <
188 (q.
rgb() - base_3D_[base_point2_].rgb()).norm() <
191 if (use_rgb && ! color_good)
return;
195 const bool dist_good = (p.
pos() - base_3D_[base_point1_].pos()).norm() <
197 (q.
pos() - base_3D_[base_point2_].pos()).norm() <
199 if (! dist_good)
return;
205 if (std::acos(segment1.dot(segment2)) <= options_.
max_angle * M_PI / 180.0) {
206 pairs->emplace_back(j, i);
209 if (std::acos(segment1.dot(- segment2)) <= options_.
max_angle * M_PI / 180.0) {
211 pairs->emplace_back(i, j);
214 pairs->emplace_back(j, i);
215 pairs->emplace_back(i, j);
223 #endif // PAIRCREATIONFUNCTOR_H Eigen::Matrix< Scalar, 3, 1 > Point
Definition: pairCreationFunctor.h:40
double pair_normals_angle
Definition: pairCreationFunctor.h:26
Scalar max_color_distance
Maximum color RGB distance between corresponding vertices. Set negative to ignore.
Definition: shared4pcs.h:162
Point unitToWorld(const Eigen::MatrixBase< typename PairCreationFunctor::Point > &p) const
Definition: pairCreationFunctor.h:73
Definition: intersectionPrimitive.h:62
Scalar max_normal_difference
Maximum normal difference.
Definition: shared4pcs.h:156
std::vector< Primitive > primitives
Definition: pairCreationFunctor.h:45
void setRadius(Scalar radius)
Definition: pairCreationFunctor.h:124
void extend(InputIt first, InputIt last)
Definition: bbox.h:75
Scalar getNormalizedEpsilon(Scalar eps)
Definition: pairCreationFunctor.h:131
void synch3DContent()
Definition: pairCreationFunctor.h:90
Accelerators::PairExtraction::HyperSphere< typename PairCreationFunctor::Point, 3, Scalar > Primitive
Definition: pairCreationFunctor.h:42
const std::vector< Point3D > & Q_
Definition: pairCreationFunctor.h:32
The basic 3D point structure. A point potentially contains also directional information and color...
Definition: shared4pcs.h:61
const VectorType & rgb() const
Definition: shared4pcs.h:79
PairCreationFunctor(Match4PCSOptions options, const std::vector< Point3D > &Q)
Definition: pairCreationFunctor.h:57
void setBase(int base_point1, int base_point2, const std::vector< Point3D > &base_3D)
Definition: pairCreationFunctor.h:135
Eigen::Matrix< Scalar, 3, 1 > VectorType
Definition: shared4pcs.h:64
Scalar Scalar
Definition: pairCreationFunctor.h:20
std::vector< typename PairCreationFunctor::Point > points
Definition: pairCreationFunctor.h:44
PairsVector * pairs
Definition: pairCreationFunctor.h:34
std::vector< unsigned int > ids
Definition: pairCreationFunctor.h:36
double pair_distance_epsilon
Definition: pairCreationFunctor.h:28
Definition: pairCreationFunctor.h:17
Match4PCSOptions options_
Definition: pairCreationFunctor.h:31
Scalar max_angle
Maximum rotation angle. Set negative to ignore.
Definition: shared4pcs.h:160
Scalar max_translation_distance
Maximum translation distance. Set negative to ignore.
Definition: shared4pcs.h:158
void beginPrimitiveCollect(int)
Definition: pairCreationFunctor.h:146
Scalar norm_threshold
Definition: pairCreationFunctor.h:25
delta and overlap_estimation are the application parameters. All other parameters are more likely to ...
Definition: shared4pcs.h:148
Scalar unitToWorld(Scalar d) const
Definition: pairCreationFunctor.h:80
Point getPointInWorldCoord(int i) const
Definition: pairCreationFunctor.h:85
VectorType & pos()
Definition: shared4pcs.h:77
void endPrimitiveCollect(int)
Definition: pairCreationFunctor.h:147
const VectorType & normal() const
Definition: shared4pcs.h:81
double pair_distance
Definition: pairCreationFunctor.h:27
void process(int i, int j)
FIXME Pair filtering is the same than 4pcs. Need refactoring.
Definition: pairCreationFunctor.h:151
typename Point3D::VectorType VectorType
Definition: pairCreationFunctor.h:22
std::vector< std::pair< int, int > > PairsVector
Definition: pairCreationFunctor.h:21