Ocean
PointCorrespondences.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_TRACKING_POINT_CORRESPONDENCES_H
9 #define META_OCEAN_TRACKING_POINT_CORRESPONDENCES_H
10 
12 
15 
18 
19 #include <vector>
20 
21 namespace Ocean
22 {
23 
24 namespace Tracking
25 {
26 
27 /**
28  * This class implements functions determining point correspondences or validates their accuracy.
29  * @ingroup tracking
30  */
31 class OCEAN_TRACKING_EXPORT PointCorrespondences
32 {
33  public:
34 
35  /**
36  * This class defines a correspondence object holding at most one correspondence candidate.
37  */
38  class OCEAN_TRACKING_EXPORT Correspondence
39  {
40  public:
41 
42  /**
43  * Creates an empty correspondence object.
44  */
45  inline Correspondence();
46 
47  /**
48  * Creates a new correspondence object.
49  * @param index Index of the interest point the candidate belongs to
50  * @param candidateIndex Index of the candidate point
51  * @param candidateSqrDistance Square distance of the candidate point
52  */
53  inline Correspondence(const unsigned int index, const unsigned int candidateIndex, const Scalar candidateSqrDistance);
54 
55  /**
56  * Returns the index of the interest point.
57  * @return Interest point index
58  */
59  inline unsigned int index() const;
60 
61  /**
62  * Returns the index of the candidate point.
63  * @return Candidate point index.
64  */
65  inline unsigned int candidateIndex() const;
66 
67  /**
68  * Returns the square distance of the correspondence point.
69  * @return Correspondence point square distance
70  */
71  inline Scalar candidateSqrDistance() const;
72 
73  /**
74  * Returns whether this object holds a valid candidate.
75  * @return True, if so
76  */
77  explicit inline operator bool() const;
78 
79  protected:
80 
81  /// Index of the interest point.
82  unsigned int correspondenceIndex;
83 
84  /// Candidate index.
86 
87  /// Candidate square distance.
89  };
90 
91  /**
92  * Definition of a vector holding correspondence objects.
93  */
94  typedef std::vector<Correspondence> Correspondences;
95 
96  /**
97  * This class extends the correspondence object to allow at most two correspondence candidates.
98  */
99  class OCEAN_TRACKING_EXPORT RedundantCorrespondence : public Correspondence
100  {
101  public:
102 
103  /**
104  * Creates an empty redundant correspondence object.
105  */
106  inline RedundantCorrespondence();
107 
108  /**
109  * Creates a redundant correspondence object with two correspondence candidates.
110  * @param index Index of the interest point the candidate belongs to
111  * @param firstCandidateIndex Index of the first candidate point
112  * @param firstCandidateSqrDistance Square distance of the first candidate point
113  * @param secondCandidateIndex Index of the second candidate point
114  * @param secondCandidateSqrDistance Square distance of the second candidate point
115  */
116  inline RedundantCorrespondence(const unsigned int index, const unsigned int firstCandidateIndex, const Scalar firstCandidateSqrDistance, const unsigned int secondCandidateIndex, const Scalar secondCandidateSqrDistance);
117 
118  /**
119  * Returns the index of the second candidate point.
120  * @return Second candidate index
121  */
122  inline unsigned int secondCandidateIndex();
123 
124  /**
125  * Returns the square distance of the second candidate point.
126  * @return Second candidate square distance
127  */
128  inline Scalar secondCandidateSqrDistance();
129 
130  /**
131  * Returns whether this redundant correspondence object holds at least one valid correspondence candidate and whether the square distance uniqueness between the first and second candidate is above a given threshold.
132  * The uniqueness is determined by a simple (squared) distance factor.<br>
133  * A (squared) distance factor of e.g., sqr(2) means that the distance between a target point and the second nearest candidate must be twice as large as the distance between the target point and the nearest candidate so that the nearest counts as unique.
134  * @param uniquenessSqrFactor The squared factor to distinguish between a unique and non-unique correspondence, with range (0, infinity)
135  * @return True, if the product between first correspondence square distance and the uniqueness factor is higher than the second correspondence square distance
136  */
137  inline bool isUnique(const Scalar uniquenessSqrFactor) const;
138 
139  /**
140  * Returns whether this redundant correspondence objects holds a unique and also accurate correspondence candidate.
141  * First the candidate must be unique as determined by isUnique() and further the square distance must be below a given threshold.<br>
142  * The uniqueness is determined by a simple (squared) distance factor.<br>
143  * A (squared) distance factor of e.g., sqr(2) means that the distance between a target point and the second nearest candidate must be twice as large as the distance between the target point and the nearest candidate so that the nearest counts as unique.
144  * @param uniquenessSqrFactor Factor to distinguish between a unique and non-unique correspondence, with range (0, infinity)
145  * @param maxSqrDistance Maximal square distance allowed, with range [0, infinity)
146  * @return True, if so
147  */
148  inline bool isUniqueAndAccurate(const Scalar uniquenessSqrFactor, const Scalar maxSqrDistance) const;
149 
150  protected:
151 
152  /// Second candidate index.
154 
155  /// Second candidate square distance.
157  };
158 
159  /**
160  * Definition of a vector holding redundant correspondence sets.
161  */
162  typedef std::vector<RedundantCorrespondence> RedundantCorrespondences;
163 
164  public:
165 
166  /**
167  * Determines valid correspondences for a set of given object and corresponding image points combined with an extrinsic and intrinsic camera matrix.
168  * @param extrinsic Extrinsic camera matrix
169  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
170  * @param objectPoints 3D Object points corresponding to the given pose
171  * @param imagePoints 2D Image points corresponding to the image points
172  * @param correspondences Number of point correspondences to be used
173  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
174  * @param sqrPixelError Maximal allowed squared pixel error for a correspondence to count as valid
175  * @param validCorrespondences Optional resulting valid correspondence indices
176  * @return Number of valid correspondences
177  * @see determineValidCorrespondencesIF().
178  */
179  static inline unsigned int determineValidCorrespondences(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, const Geometry::ObjectPoint* objectPoints, const Geometry::ImagePoint* imagePoints, const size_t correspondences, const bool distortImagePoints, const Scalar sqrPixelError = Scalar(1.5 * 1.5), Indices32* validCorrespondences = nullptr);
180 
181  /**
182  * Determines valid correspondences for a set of given object and corresponding image points combined with an extrinsic and intrinsic camera matrix.
183  * @param invertedFlippedExtrinsic Inverted and flipped extrinsic camera matrix
184  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
185  * @param objectPoints 3D Object points corresponding to the given pose
186  * @param imagePoints 2D Image points corresponding to the image points
187  * @param correspondences Number of point correspondences to be used
188  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
189  * @param sqrPixelError Maximal allowed squared pixel error for a correspondence to count as valid
190  * @param validCorrespondences Optional resulting valid correspondence indices
191  * @return Number of valid correspondences
192  * @see determineValidCorrespondences().
193  */
194  static unsigned int determineValidCorrespondencesIF(const HomogenousMatrix4& invertedFlippedExtrinsic, const PinholeCamera& pinholeCamera, const Geometry::ObjectPoint* objectPoints, const Geometry::ImagePoint* imagePoints, const size_t correspondences, const bool distortImagePoints, const Scalar sqrPixelError = Scalar(1.5 * 1.5), Indices32* validCorrespondences = nullptr);
195 
196  /**
197  * Determines valid correspondences in a set of given object and corresponding image points.
198  * Invalid correspondences will be removed from the given point set. Thus, this function detects outliers.<br>
199  * @param extrinsic Extrinsic camera matrix
200  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
201  * @param objectPoints 3D Object points corresponding to the given pose, each 3D point matches to a 2D point with the same index
202  * @param imagePoints 2D Image points corresponding to the image points, each 2D point matches to a 3D point with the same index
203  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
204  * @param sqrPixelError Maximal allowed squared pixel error for a correspondence to count as valid
205  */
206  static inline void removeInvalidCorrespondences(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, Geometry::ObjectPoints& objectPoints, Geometry::ImagePoints& imagePoints, const bool distortImagePoints, const Scalar sqrPixelError = Scalar(1.5 * 1.5));
207 
208  /**
209  * Determines valid correspondences in a set of given object and corresponding image points.
210  * Invalid correspondences will be removed from the given point set. Thus, this function detects outliers.<br>
211  * @param invertedFlippedExtrinsic Inverted and flipped extrinsic camera matrix
212  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
213  * @param objectPoints 3D Object points corresponding to the given pose, each 3D point matches to a 2D point with the same index
214  * @param imagePoints 2D Image points corresponding to the image points, each 2D point matches to a 3D point with the same index
215  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
216  * @param sqrPixelError Maximal allowed squared pixel error for a correspondence to count as valid
217  */
218  static void removeInvalidCorrespondencesIF(const HomogenousMatrix4& invertedFlippedExtrinsic, const PinholeCamera& pinholeCamera, Geometry::ObjectPoints& objectPoints, Geometry::ImagePoints& imagePoints, const bool distortImagePoints, const Scalar sqrPixelError = Scalar(1.5 * 1.5));
219 
220  /**
221  * Determines the nearest candidates for all given image points from an extra set of candidate image points.<br>
222  * @param imagePoints Image points to find the candidates for
223  * @param numberImagePoints Number of image points
224  * @param candidatePoints Candidate points to found the nearest correspondences from
225  * @param numberCandidatePoints Number of given candidate points
226  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
227  * @param candidateUseCounter Optional used-counter of the candidate points
228  * @return Resulting redundant correspondences
229  */
230  static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint* candidatePoints, const size_t numberCandidatePoints, const Scalar searchWindowRadius, Indices32* candidateUseCounter = nullptr);
231 
232  /**
233  * Determines the nearest candidates for all given image points from an extra set of candidate image points.<br>
234  * This function first distributes all candidate points into an array to speed up the search process.<br>
235  * @param imagePoints Image points to find the candidates for
236  * @param numberImagePoints Number of image points
237  * @param candidatePoints Candidate points to found the nearest correspondences from
238  * @param numberCandidatePoints Number of given candidate points
239  * @param width The width of the image area in pixel
240  * @param height The height of the image area in pixel
241  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
242  * @param candidateUseCounter Optional used-counter of the candidate points
243  * @return Resulting redundant correspondences
244  */
245  static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint* candidatePoints, const size_t numberCandidatePoints, const unsigned int width, const unsigned int height, const Scalar searchWindowRadius, Indices32* candidateUseCounter = nullptr);
246 
247  /**
248  * Determines the nearest candidates for all given image points from a set of candidate projected object points (or simply a second set of image points).<br>
249  * All object points will be projected into the image plane to find the neighbors for the image points.<br>
250  * @param extrinsic Extrinsic camera matrix
251  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
252  * @param imagePoints Image points to find the candidates for
253  * @param numberImagePoints Number of image points
254  * @param candidatePoints Candidate points to found the nearest correspondences from
255  * @param numberCandidatePoints Number of given candidate points
256  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
257  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
258  * @param candidateUseCounter Optional used-counter of the candidate points
259  * @return Resulting redundant correspondences
260  */
261  static inline RedundantCorrespondences determineNearestCandidates(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ObjectPoint* candidatePoints, const size_t numberCandidatePoints, const bool distortImagePoints, const Scalar searchWindowRadius, Indices32* candidateUseCounter = nullptr);
262 
263  /**
264  * Determines the nearest candidates for all given image points from a set of candidate object points.<br>
265  * All object points will be projected into the image plane to find the neighbors for the image points.<br>
266  * @param invertedFlippedExtrinsic Inverted and flipped extrinsic camera matrix
267  * @param pinholeCamera The pinhole camera specifying the internal camera parameters and optionally distortion
268  * @param imagePoints Image points to find the candidates for
269  * @param numberImagePoints Number of image points
270  * @param candidatePoints Candidate points to found the nearest correspondences from
271  * @param numberCandidatePoints Number of given candidate points
272  * @param distortImagePoints True, to force the distortion of the image points using the distortion parameters of this camera object
273  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
274  * @param candidateUseCounter Optional used-counter of the candidate points
275  * @return Resulting redundant correspondences
276  */
277  static RedundantCorrespondences determineNearestCandidatesIF(const HomogenousMatrix4& invertedFlippedExtrinsic, const PinholeCamera& pinholeCamera, const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ObjectPoint* candidatePoints, const size_t numberCandidatePoints, const bool distortImagePoints, const Scalar searchWindowRadius, Indices32* candidateUseCounter = nullptr);
278 
279  /**
280  * Determines the nearest candidates for all given image points from a set of candidate image points.<br>
281  * The spatial distribution of the candidate points must be provided explicitly.<br>
282  * @param imagePoints Image points to find the candidates for
283  * @param numberImagePoints Number of image points
284  * @param candidatePoints Candidate points to found the nearest correspondences from
285  * @param numberCandidatePoints Number of given candidate points
286  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
287  * @param distributionCandidatePoints Distribution of the candidate points (may contain more points as defined by the number of candidate points)
288  * @param candidateUseCounter Optional used-counter of the candidate points
289  * @return Resulting redundant correspondences
290  */
291  static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint* candidatePoints, const size_t numberCandidatePoints, const Scalar searchWindowRadius, const Geometry::SpatialDistribution::DistributionArray& distributionCandidatePoints, Indices32* candidateUseCounter = nullptr);
292 
293  /**
294  * Determines the nearest candidates for all given image points from a set of candidate image points.<br>
295  * This function first distributes all candidate points into an array to speed up the search process.<br>
296  * Further, for each candidate point a given 2D line is provided that predicts the position of a corresponding image points (they must lie on these lines).<br>
297  * @param imagePoints Image points to find the candidates for
298  * @param numberImagePoints Number of image points
299  * @param candidatePoints Candidate points from those the nearest correspondences has to be found
300  * @param candidateLines Lines for each candidate point shrinking the search space to an almost 1D problem
301  * @param numberCandidatePoints Number of given candidate points
302  * @param width The width of the image area in pixel
303  * @param height The height of the image area in pixel
304  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
305  * @param maximalLineSqrDistance Maximal square distance between point and candidate line
306  * @param candidateUseCounter Optional used counter of the candidate points
307  * @return Resulting redundant correspondences
308  */
309  static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint* candidatePoints, const Line2* candidateLines, const size_t numberCandidatePoints, const unsigned int width, const unsigned int height, const Scalar searchWindowRadius, const Scalar maximalLineSqrDistance, Indices32* candidateUseCounter = nullptr);
310 
311  /**
312  * Determines the nearest candidates for all given image points from a set of candidate image points.<br>
313  * The spatial distribution of the candidate points must be provided explicitly.<br>
314  * Further, for each candidate point a given 2D line is provided that predicts the position of a corresponding image points (they must lie on these lines).<br>
315  * @param imagePoints Image points to find the candidates for
316  * @param numberImagePoints Number of image points
317  * @param candidatePoints Candidate points from those the nearest correspondences has to be found
318  * @param candidateLines Lines for each candidate point shrinking the search space to an almost 1D problem
319  * @param numberCandidatePoints Number of given candidate points
320  * @param searchWindowRadius Size of the search window (as 'radius') to accept a candidate, with range (0, infinity)
321  * @param maximalLineSqrDistance Maximal square distance between point and candidate line
322  * @param distributionCandidatePoints Distribution of the candidate points (may contain more points as defined by the number of candidate points)
323  * @param candidateUseCounter Optional used-counter of the candidate points
324  * @return Resulting redundant correspondences
325  */
326  static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint* candidatePoints, const Line2* candidateLines, const size_t numberCandidatePoints, const Scalar searchWindowRadius, const Scalar maximalLineSqrDistance, const Geometry::SpatialDistribution::DistributionArray& distributionCandidatePoints, Indices32* candidateUseCounter = nullptr);
327 
328  /**
329  * Finds the valid correspondences of a set of given 2D point correspondences according to the median distance of the entire set.
330  * @param firstPoints Points of the first set
331  * @param secondPoints Points of the second set, each point corresponds to one in the first set (with same index)
332  * @param numberPoints Number of provided points in each set
333  * @param thresholdFactor Factor that is applied to the median distance to filter valid correspondences
334  * @return Indices of all valid correspondences
335  */
336  static Indices32 filterValidCorrespondences(const Vector2* firstPoints, const Vector2* secondPoints, const size_t numberPoints, const Scalar thresholdFactor);
337 
338  /**
339  * Finds the valid correspondences of a set of given 2D point correspondences according to the median distance of a subset of the entire set.
340  * This function needs a set of indices determining the subset of the given points that are investigated.
341  * @param firstPoints Points of the first set
342  * @param secondPoints Points of the second set, each point corresponds to one in the first set (with same index)
343  * @param subsetIndices Subset of the given two point sets that are investigated for correspondence determination
344  * @param thresholdFactor Factor that is applied to the median distance to filter valid correspondences
345  * @return Indices of all valid correspondences
346  */
347  static Indices32 filterValidCorrespondences(const Vectors2& firstPoints, const Vectors2& secondPoints, const Indices32& subsetIndices, const Scalar thresholdFactor);
348 };
349 
351  correspondenceIndex((unsigned int)(-1)),
352  correspondenceCandidateIndex((unsigned int)(-1)),
353  correspondenceCandidateSqrDistance(Numeric::maxValue())
354 {
355  // nothing to do here
356 }
357 
358 inline PointCorrespondences::Correspondence::Correspondence(const unsigned int index, const unsigned int candidateIndex, const Scalar sqrDistance) :
359  correspondenceIndex(index),
360  correspondenceCandidateIndex(candidateIndex),
361  correspondenceCandidateSqrDistance(sqrDistance)
362 {
363  // nothing to do here
364 }
365 
367 {
368  return correspondenceIndex;
369 }
370 
372 {
373  return correspondenceCandidateIndex;
374 }
375 
377 {
378  return correspondenceCandidateSqrDistance;
379 }
380 
381 inline PointCorrespondences::Correspondence::operator bool() const
382 {
383  return correspondenceCandidateIndex != (unsigned int)(-1);
384 }
385 
387  Correspondence(),
388  correspondenceSecondCandidateIndex((unsigned int)(-1)),
389  correspondenceSecondCandidateSqrDistance(Numeric::maxValue())
390 {
391  // nothing to do here
392 }
393 
394 inline PointCorrespondences::RedundantCorrespondence::RedundantCorrespondence(const unsigned int index, const unsigned int firstCandidateIndex, const Scalar firstCandidateSqrDistance, const unsigned int secondCandidateIndex, const Scalar secondCandidateSqrDistance) :
395  Correspondence(index, firstCandidateIndex, firstCandidateSqrDistance),
396  correspondenceSecondCandidateIndex(secondCandidateIndex),
397  correspondenceSecondCandidateSqrDistance(secondCandidateSqrDistance)
398 {
399  // nothing to do here
400 }
401 
403 {
404  return correspondenceSecondCandidateIndex;
405 }
406 
408 {
409  return correspondenceSecondCandidateSqrDistance;
410 }
411 
412 inline bool PointCorrespondences::RedundantCorrespondence::isUnique(const Scalar uniquenessSqrFactor) const
413 {
414  return correspondenceCandidateIndex != (unsigned int)(-1) && correspondenceSecondCandidateSqrDistance >= uniquenessSqrFactor * correspondenceCandidateSqrDistance;
415 }
416 
417 inline bool PointCorrespondences::RedundantCorrespondence::isUniqueAndAccurate(const Scalar uniquenessSqrFactor, const Scalar maxSqrDistance) const
418 {
419  return correspondenceCandidateSqrDistance <= maxSqrDistance && isUnique(uniquenessSqrFactor);
420 }
421 
422 inline unsigned int PointCorrespondences::determineValidCorrespondences(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, const Geometry::ObjectPoint* objectPoints, const Geometry::ImagePoint* imagePoints, const size_t correspondences, const bool distortImagePoints, const Scalar sqrPixelError, Indices32* validCorrespondences)
423 {
424  return determineValidCorrespondencesIF(PinholeCamera::standard2InvertedFlipped(extrinsic), pinholeCamera, objectPoints, imagePoints, correspondences, distortImagePoints, sqrPixelError, validCorrespondences);
425 }
426 
427 inline void PointCorrespondences::removeInvalidCorrespondences(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, Geometry::ObjectPoints& objectPoints, Geometry::ImagePoints& imagePoints, const bool distortImagePoints, const Scalar sqrPixelError)
428 {
429  removeInvalidCorrespondencesIF(PinholeCamera::standard2InvertedFlipped(extrinsic), pinholeCamera, objectPoints, imagePoints, distortImagePoints, sqrPixelError);
430 }
431 
432 inline PointCorrespondences::RedundantCorrespondences PointCorrespondences::determineNearestCandidates(const HomogenousMatrix4& extrinsic, const PinholeCamera& pinholeCamera, const Geometry::ImagePoint* imagePoints, const size_t numberImagePoints, const Geometry::ObjectPoint* candidatePoints, const size_t numberCandidatePoints, const bool distortImagePoints, const Scalar searchWindowRadius, Indices32* candidateUseIndices)
433 {
434  return determineNearestCandidatesIF(PinholeCamera::standard2InvertedFlipped(extrinsic), pinholeCamera, imagePoints, numberImagePoints, candidatePoints, numberCandidatePoints, distortImagePoints, searchWindowRadius, candidateUseIndices);
435 }
436 
437 }
438 
439 }
440 
441 #endif // META_OCEAN_TRACKING_POINT_CORRESPONDENCES_H
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
Transforms a standard homogenous 4x4 viewing (extrinsic camera) matrix into an inverted and flipped c...
Definition: Camera.h:734
This class implements a distribution array.
Definition: SpatialDistribution.h:228
This class implements an infinite line in 2D space.
Definition: Line2.h:83
This class provides basic numeric functionalities.
Definition: Numeric.h:57
This class defines a correspondence object holding at most one correspondence candidate.
Definition: PointCorrespondences.h:39
Scalar correspondenceCandidateSqrDistance
Candidate square distance.
Definition: PointCorrespondences.h:88
unsigned int correspondenceIndex
Index of the interest point.
Definition: PointCorrespondences.h:82
unsigned int index() const
Returns the index of the interest point.
Definition: PointCorrespondences.h:366
Correspondence()
Creates an empty correspondence object.
Definition: PointCorrespondences.h:350
unsigned int correspondenceCandidateIndex
Candidate index.
Definition: PointCorrespondences.h:85
unsigned int candidateIndex() const
Returns the index of the candidate point.
Definition: PointCorrespondences.h:371
Scalar candidateSqrDistance() const
Returns the square distance of the correspondence point.
Definition: PointCorrespondences.h:376
This class extends the correspondence object to allow at most two correspondence candidates.
Definition: PointCorrespondences.h:100
bool isUniqueAndAccurate(const Scalar uniquenessSqrFactor, const Scalar maxSqrDistance) const
Returns whether this redundant correspondence objects holds a unique and also accurate correspondence...
Definition: PointCorrespondences.h:417
unsigned int correspondenceSecondCandidateIndex
Second candidate index.
Definition: PointCorrespondences.h:153
Scalar correspondenceSecondCandidateSqrDistance
Second candidate square distance.
Definition: PointCorrespondences.h:156
unsigned int secondCandidateIndex()
Returns the index of the second candidate point.
Definition: PointCorrespondences.h:402
Scalar secondCandidateSqrDistance()
Returns the square distance of the second candidate point.
Definition: PointCorrespondences.h:407
bool isUnique(const Scalar uniquenessSqrFactor) const
Returns whether this redundant correspondence object holds at least one valid correspondence candidat...
Definition: PointCorrespondences.h:412
RedundantCorrespondence()
Creates an empty redundant correspondence object.
Definition: PointCorrespondences.h:386
This class implements functions determining point correspondences or validates their accuracy.
Definition: PointCorrespondences.h:32
static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint *candidatePoints, const size_t numberCandidatePoints, const Scalar searchWindowRadius, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from an extra set of candidate image poi...
static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint *candidatePoints, const size_t numberCandidatePoints, const Scalar searchWindowRadius, const Geometry::SpatialDistribution::DistributionArray &distributionCandidatePoints, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from a set of candidate image points.
static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint *candidatePoints, const size_t numberCandidatePoints, const unsigned int width, const unsigned int height, const Scalar searchWindowRadius, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from an extra set of candidate image poi...
std::vector< RedundantCorrespondence > RedundantCorrespondences
Definition of a vector holding redundant correspondence sets.
Definition: PointCorrespondences.h:162
static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint *candidatePoints, const Line2 *candidateLines, const size_t numberCandidatePoints, const Scalar searchWindowRadius, const Scalar maximalLineSqrDistance, const Geometry::SpatialDistribution::DistributionArray &distributionCandidatePoints, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from a set of candidate image points.
static Indices32 filterValidCorrespondences(const Vector2 *firstPoints, const Vector2 *secondPoints, const size_t numberPoints, const Scalar thresholdFactor)
Finds the valid correspondences of a set of given 2D point correspondences according to the median di...
static unsigned int determineValidCorrespondencesIF(const HomogenousMatrix4 &invertedFlippedExtrinsic, const PinholeCamera &pinholeCamera, const Geometry::ObjectPoint *objectPoints, const Geometry::ImagePoint *imagePoints, const size_t correspondences, const bool distortImagePoints, const Scalar sqrPixelError=Scalar(1.5 *1.5), Indices32 *validCorrespondences=nullptr)
Determines valid correspondences for a set of given object and corresponding image points combined wi...
static RedundantCorrespondences determineNearestCandidates(const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ImagePoint *candidatePoints, const Line2 *candidateLines, const size_t numberCandidatePoints, const unsigned int width, const unsigned int height, const Scalar searchWindowRadius, const Scalar maximalLineSqrDistance, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from a set of candidate image points.
static Indices32 filterValidCorrespondences(const Vectors2 &firstPoints, const Vectors2 &secondPoints, const Indices32 &subsetIndices, const Scalar thresholdFactor)
Finds the valid correspondences of a set of given 2D point correspondences according to the median di...
static RedundantCorrespondences determineNearestCandidatesIF(const HomogenousMatrix4 &invertedFlippedExtrinsic, const PinholeCamera &pinholeCamera, const Geometry::ImagePoint *imagePoints, const size_t numberImagePoints, const Geometry::ObjectPoint *candidatePoints, const size_t numberCandidatePoints, const bool distortImagePoints, const Scalar searchWindowRadius, Indices32 *candidateUseCounter=nullptr)
Determines the nearest candidates for all given image points from a set of candidate object points.
static void removeInvalidCorrespondencesIF(const HomogenousMatrix4 &invertedFlippedExtrinsic, const PinholeCamera &pinholeCamera, Geometry::ObjectPoints &objectPoints, Geometry::ImagePoints &imagePoints, const bool distortImagePoints, const Scalar sqrPixelError=Scalar(1.5 *1.5))
Determines valid correspondences in a set of given object and corresponding image points.
static unsigned int determineValidCorrespondences(const HomogenousMatrix4 &extrinsic, const PinholeCamera &pinholeCamera, const Geometry::ObjectPoint *objectPoints, const Geometry::ImagePoint *imagePoints, const size_t correspondences, const bool distortImagePoints, const Scalar sqrPixelError=Scalar(1.5 *1.5), Indices32 *validCorrespondences=nullptr)
Determines valid correspondences for a set of given object and corresponding image points combined wi...
Definition: PointCorrespondences.h:422
static void removeInvalidCorrespondences(const HomogenousMatrix4 &extrinsic, const PinholeCamera &pinholeCamera, Geometry::ObjectPoints &objectPoints, Geometry::ImagePoints &imagePoints, const bool distortImagePoints, const Scalar sqrPixelError=Scalar(1.5 *1.5))
Determines valid correspondences in a set of given object and corresponding image points.
Definition: PointCorrespondences.h:427
std::vector< Correspondence > Correspondences
Definition of a vector holding correspondence objects.
Definition: PointCorrespondences.h:94
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition: Base.h:96
std::vector< ObjectPoint > ObjectPoints
Definition of a vector holding 3D object points.
Definition: geometry/Geometry.h:129
std::vector< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition: geometry/Geometry.h:123
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15