Ocean
Loading...
Searching...
No Matches
UnifiedMatching.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_MAPBUILDING_UNIFIED_MATCHING_H
9#define META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_MATCHING_H
10
17
19#include "ocean/base/Worker.h"
20
22
25#include "ocean/math/Vector2.h"
26#include "ocean/math/Vector3.h"
27
30
31namespace Ocean
32{
33
34namespace Tracking
35{
36
37namespace MapBuilding
38{
39
40/**
41 * The base class for all unified matching objects.
42 * @ingroup trackingmapbuilding
43 */
45{
46 public:
47
48 /**
49 * Definition of a descriptor distance value.
50 */
52 {
53 public:
54
55 /**
56 * Default constructor with an invalid descriptor distance.
57 */
58 DistanceValue() = default;
59
60 /**
61 * Creates a new distance value for a binary descriptor.
62 * @param binaryDistance The binary distance, with range [0, infinity)
63 */
64 explicit inline DistanceValue(const unsigned int binaryDistance);
65
66 /**
67 * Creates a new distance for a floating point descriptor.
68 * @param floatDistance The floating point distance, with range [0, 1]
69 */
70 explicit inline DistanceValue(const float floatDistance);
71
72 /**
73 * Creates a new distance value which can be used for a binary descriptor and a floating point descriptor.
74 * @param binaryDistance The binary distance, with range [0, infinity)
75 * @param floatDistance The floating point distance, with range [0, 1]
76 */
77 explicit inline DistanceValue(const unsigned int binaryDistance, const float floatDistance);
78
79 /**
80 * Returns the binary distance.
81 * @return Binary distance, with range [0, infinity)
82 */
83 inline unsigned int binaryDistance() const;
84
85 /**
86 * Returns the floating point distance.
87 * @return Floating point distance, with range [0, 1]
88 */
89 inline float floatDistance() const;
90
91 /**
92 * Returns either the binary or the floating point distance.
93 * @return The binary or floating point distance depending on whether TDistance is an integer or a floating point
94 */
95 template <typename TDistance>
96 inline TDistance distance() const;
97
98 /**
99 * Returns whether the object holds a valid distance.
100 * @return True, if so
101 */
102 inline bool isValid() const;
103
104 protected:
105
106 /// The binary distance, with range [0, infinity), -1 if unknown.
107 unsigned int binaryDistance_ = (unsigned int)(-1);
108
109 /// The floating point distance, with range [0, 1], -1 if unknown
110 float floatDistance_ = -1.0f;
111 };
112
113 public:
114
115 /**
116 * Disposes this object.
117 */
118 virtual ~UnifiedMatching() = default;
119
120 /**
121 * Returns the number of image points.
122 * @return The number of image points
123 */
124 inline size_t numberImagePoints() const;
125
126 protected:
127
128 /**
129 * Creates a new matching object with 3D object points only.
130 * Does not create a copy of the given input.
131 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
132 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
133 */
134 inline UnifiedMatching(const Vector3* objectPoints, const size_t numberObjectPoints);
135
136 /**
137 * Creates a new matching object with 2D image points and 3D object points only.
138 * Does not create a copy of the given input.
139 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
140 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
141 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
142 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
143 */
144 inline UnifiedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints);
145
146 protected:
147
148 /// The 2D image points.
149 const Vector2* imagePoints_ = nullptr;
150
151 /// The number of 2D image points.
153
154 /// The 3D object points.
155 const Vector3* objectPoints_ = nullptr;
156
157 /// The number of 3D object points.
158 const size_t numberObjectPoints_ = 0;
159};
160
161/**
162 * This class implements the base class for all guided matching objects.
163 * @ingroup trackingmapbuilding
164 */
166{
167 public:
168
169 /**
170 * Determines the guided matching between 2D and 3D feature points.
171 * @param anyCamera The camera profile defining the projection, must be valid
172 * @param world_T_camera The camera pose, transforming camera to world, with default viewing direction into negative z-space and u-axis up, must be valid
173 * @param matchedImagePoints The resulting matched 2D image points
174 * @param matchedObjectPoints The resulting matched 3D object points, one for each matched image point
175 * @param maximalDescriptorDistance The maximal descriptor distance so that two descriptor count as match, must be valid
176 * @param matchedImagePointIndices Optional resulting indices of the matched 2D image points, nullptr if not of interest
177 * @param matchedObjectPointIds Optional resulting ids of the matched 3D image points, nullptr if not of interest
178 * @param worker Optional worker object to distribute the computation
179 */
180 virtual void determineGuidedMatchings(const AnyCamera& anyCamera, const HomogenousMatrix4& world_T_camera, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, const DistanceValue& maximalDescriptorDistance, Indices32* matchedImagePointIndices = nullptr, Indices32* matchedObjectPointIds = nullptr, Worker* worker = nullptr) const = 0;
181
182 protected:
183
184 /**
185 * Creates a new matching object with 3D object points only.
186 * Does not create a copy of the given input.
187 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
188 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
189 * @param objectPointOctree The octree holding all 3D object points
190 * @param objectPointIds The ids of all 3D object points, must be valid
191 */
192 inline UnifiedGuidedMatching(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds);
193
194 /**
195 * Creates a new matching object with 2D image points and 3D object points only.
196 * Does not create a copy of the given input.
197 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
198 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
199 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
200 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
201 * @param objectPointOctree The octree holding all 3D object points
202 * @param objectPointIds The ids of all 3D object points, must be valid
203 */
204 inline UnifiedGuidedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds);
205
206 protected:
207
208 /// The octree holding all 3D object points.
210
211 /// The ids of all 3D object points.
212 const Index32* objectPointIds_ = nullptr;
213};
214
215/**
216 * Definition of a shared pointer holding an UnifiedGuidedMatching object.
217 * @see UnifiedGuidedMatching.
218 * @ingroup trackingmapbuilding
219 */
220using SharedUnifiedGuidedMatching = std::shared_ptr<UnifiedGuidedMatching>;
221
222/**
223 * This class implements the base class for all unguided matching objects.
224 * @ingroup trackingmapbuilding
225 */
227{
228 public:
229
230 /**
231 * Determines the unguided matching between 2D and 3D feature points.
232 * @param minimalNumberCorrespondences The minimal number of feature correspondences, with range [1, infinity)
233 * @param maximalDescriptorDistance The maximal descriptor distance so that two descriptor count as match, must be valid
234 * @param matchedImagePoints Optional resulting matched 2D image points, nullptr if not of interest
235 * @param matchedObjectPoints Optional resulting matched 3D image points, nullptr if not of interest
236 * @param worker Optional worker object to distribute the computation
237 * @return True, if succeeded
238 */
239 virtual bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue& maximalDescriptorDistance, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, Worker* worker = nullptr) const = 0;
240
241 protected:
242
243 /**
244 * Creates a new matching object with 3D object points only.
245 * Does not create a copy of the given input.
246 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
247 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
248 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices, must be valid
249 */
250 inline UnifiedUnguidedMatching(const Vector3* objectPoints, const size_t numberObjectPoints, const Index32* objectPointIndices);
251
252 /**
253 * Creates a new matching object with 2D image points and 3D object points only.
254 * Does not create a copy of the given input.
255 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
256 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
257 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
258 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
259 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices, must be valid
260 */
261 inline UnifiedUnguidedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Index32* objectPointIndices);
262
263 protected:
264
265 /// The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices.
266 const Index32* objectPointIndices_ = nullptr;
267};
268
269/**
270 * Definition of a shared pointer holding an UnifiedUnguidedMatching object.
271 * @see UnifiedUnguidedMatching.
272 * @ingroup trackingmapbuilding
273 */
274using SharedUnifiedUnguidedMatching = std::shared_ptr<UnifiedUnguidedMatching>;
275
276/**
277 * This class implements the guided matching object for specific features.
278 * @tparam TImagePointDescriptor The data type of the image point descriptors, e.g., a single-level or a multi-level descriptor binary/float descriptor
279 * @tparam TObjectPointDescriptor The data type of the object point descriptors, e.g., a single-level or multi-level single/multi-view descriptor
280 * @tparam TDistance The data type of the distance between an image point and object point descriptor e.g., unsigned int or float
281 * @ingroup trackingmapbuilding
282 */
283template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance = typename UnifiedDescriptor::DistanceTyper<TImagePointDescriptor>::Type>
285{
286 public:
287
288 /// Definition of the distance data type.
289 typedef TDistance DescriptorDistance;
290
291 /// Definition of the descriptor for 2D image points.
292 typedef TImagePointDescriptor ImagePointDescriptor;
293
294 /// Definition of the descriptor for 3D object points.
295 typedef TObjectPointDescriptor ObjectPointDescriptor;
296
297 /**
298 * Definition of an unordered map mapping object point ids to descriptors.
299 */
300 template <typename TDescriptor>
301 using UnorderedDescriptorMap = std::unordered_map<Index32, TDescriptor>;
302
303 public:
304
305 /**
306 * Creates a new matching object with 3D object points only.
307 * Does not create a copy of the given input.
308 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
309 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
310 * @param objectPointOctree The octree holding all 3D object points
311 * @param objectPointIds The ids of all 3D object points, must be valid
312 * @param objectPointDescriptorMap The map mapping object point ids to their corresponding descriptors
313 */
314 inline UnifiedGuidedMatchingT(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap);
315
316 /**
317 * Creates a new matching object with 2D image points and 3D object points only.
318 * Does not create a copy of the given input.
319 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
320 * @param imagePointDescriptors The descriptors for the image points, one for each image point, can be nullptr if 'numberImagePoints == 0'
321 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
322 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
323 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
324 * @param objectPointOctree The octree holding all 3D object points
325 * @param objectPointIds The ids of all 3D object points, must be valid
326 * @param objectPointDescriptorMap The map mapping object point ids to their corresponding descriptors
327 */
328 inline UnifiedGuidedMatchingT(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap);
329
330 /**
331 * Updates the 2D image points e.g., to allow matching for a new camera frame.
332 * The input data will not be copied.
333 * @param imagePoints The new 2D image points, can be nullptr if 'numberImagePoints == 0'
334 * @param imagePointDescriptors The descriptors for the image points, can be nullptr if 'numberImagePoints == 0'
335 * @param numberImagePoints The number of image points, with range [0, infinity)
336 */
337 inline void updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints);
338
339 /**
340 * Removes the image points from this object.
341 */
342 inline void clearImagePoints();
343
344 /**
345 * Determines the guided matching between 2D and 3D feature points.
346 * @see UnifiedGuidedMatching::determineGuidedMatchings().
347 */
348 void determineGuidedMatchings(const AnyCamera& anyCamera, const HomogenousMatrix4& world_T_camera, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, const DistanceValue& maximalDescriptorDistance, Indices32* matchedImagePointIndices = nullptr, Indices32* matchedObjectPointIds = nullptr, Worker* worker = nullptr) const override;
349
350 protected:
351
352 /// The descriptors for the image points, one for each image point.
354
355 /// The map mapping object point ids to their corresponding descriptors.
357};
358
359/**
360 * Definition of a UnifiedGuidedMatchingT object for FREAK descriptors with 256 bits.
361 * @ingroup trackingmapbuilding
362 */
364
365/**
366 * Definition of a UnifiedGuidedMatchingT object for float descriptors.
367 * @tparam tElements The number of float elements, with range [1, infinity)
368 * @ingroup trackingmapbuilding
369 */
370template <uint16_t tElements>
372
373/**
374 * This class implements the unguided matching object for FREAK Multi features with 32 bytes or 256 bits.
375 * @tparam TImagePointDescriptor The data type of the image point descriptors, e.g., a single-level or a multi-level descriptor binary/float descriptor
376 * @tparam TObjectPointVocabularyDescriptor The data type of the object point descriptors, e.g., a single-level or multi-level single/multi-view descriptor
377 * @tparam TDistance The data type of the distance between an image point and object point descriptor e.g., unsigned int or float
378 * @ingroup trackingmapbuilding
379 */
380template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance = typename UnifiedDescriptor::DistanceTyper<TImagePointDescriptor>::Type>
382{
383 public:
384
385 /// Definition of the distance for the binary descriptor.
386 typedef TDistance DescriptorDistance;
387
388 /// Definition of the descriptor for 2D image points.
389 typedef TImagePointDescriptor ImagePointDescriptor;
390
391 /// Definition of the descriptor for 3D object points.
392 typedef TObjectPointVocabularyDescriptor ObjectPointVocabularyDescriptor;
393
394 /// Definition of a vocabulary forest for object point descriptors.
396
397 /// Definition of a vocabulary tree for object point descriptors.
399
400 public:
401
402 /**
403 * Creates a new matching object with 3D object points only.
404 * Does not create a copy of the given input.
405 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
406 * @param objectPointVocabularyDescriptors The descriptors for the object points, one for each index in 'objectPointIndices'
407 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
408 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices
409 * @param forestObjectPointDescriptors The vocabulary forest for the object point features
410 */
411 inline UnifiedUnguidedMatchingT(const Vector3* objectPoints, const ObjectPointVocabularyDescriptor* objectPointVocabularyDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const VocabularyForest& forestObjectPointDescriptors);
412
413 /**
414 * Creates a new matching object with 2D image points and 3D object points only.
415 * Does not create a copy of the given input.
416 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
417 * @param imagePointDescriptors The descriptors for the image points, one for each image point, can be nullptr if 'numberImagePoints == 0'
418 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
419 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
420 * @param objectPointVocabularyDescriptors The descriptors for the object points, one for each index in 'objectPointIndices'
421 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
422 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices, must be valid
423 * @param forestObjectPointDescriptors The vocabulary forest for the object point features
424 */
425 inline UnifiedUnguidedMatchingT(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints, const Vector3* objectPoints, const ObjectPointVocabularyDescriptor* objectPointVocabularyDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const VocabularyForest& forestObjectPointDescriptors);
426
427 /**
428 * Updates the 2D image points e.g., to allow matching for a new camera frame.
429 * The input data will not be copied.
430 * @param imagePoints The new 2D image points, can be nullptr if 'numberImagePoints == 0'
431 * @param imagePointDescriptors The descriptors for the image points, can be nullptr if 'numberImagePoints == 0'
432 * @param numberImagePoints The number of image points, with range [0, infinity)
433 */
434 inline void updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints);
435
436 /**
437 * Removes the image points from this object.
438 */
439 inline void clearImagePoints();
440
441 /**
442 * Determines the unguided matching between 2D and 3D feature points.
443 * @see UnifiedUnguidedMatching::determineUnguidedMatchings().
444 */
445 bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue& maximalDescriptorDistance, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, Worker* worker = nullptr) const override;
446
447 protected:
448
449 /// The descriptors for the image points, one for each image point.
451
452 /// The descriptors for the object points, one for each index in 'objectPointIndices'.
454
455 /// The vocabulary forest for the object point features.
457};
458
459/**
460 * Definition of an UnifiedUnguidedMatchingT object for FREAK descriptors with 256 bits.
461 * @ingroup trackingmapbuilding
462 */
464
465/**
466 * Definition of an UnifiedUnguidedMatchingT object for float descriptors.
467 * @tparam tElements The number of float elements the descriptors have, with range [1, infinity)
468 * @ingroup trackingmapbuilding
469 */
470template <uint16_t tElements>
472
473/**
474 * This class implements the guided matching object for groups of FREAK Multi features with 32 bytes or 256 bits.
475 * @ingroup trackingmapbuilding
476 */
478{
479 public:
480 /// Definition of the distance for the binary descriptor.
481 typedef unsigned int DescriptorDistance;
482
483 /// Definition of the descriptor for 2D image points.
485
486 /// Definition of the groups of descriptors for 2D image points.
488
489 /// Definition of the descriptor for 3D object points (several descriptors per point possible).
491
492 /**
493 * Definition of an unordered map mapping object point ids to descriptors.
494 */
495 template <typename TDescriptor>
496 using UnorderedDescriptorMap = std::unordered_map<Index32, TDescriptor>;
497
498 public:
499
500 /**
501 * Creates a new matching object with 3D object points only.
502 * Does not create a copy of the given input.
503 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
504 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
505 * @param objectPointOctree The octree holding all 3D object points
506 * @param objectPointIds The ids of all 3D object points, must be valid
507 * @param objectPointDescriptorMap The map mapping object point ids to their corresponding descriptors
508 */
509 inline UnifiedGuidedMatchingFreakMultiDescriptor256Group(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap);
510
511 /**
512 * Creates a new matching object with 2D image points and 3D object points only.
513 * Does not create a copy of the given input.
514 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
515 * @param imagePointDescriptorGroups The groups of descriptors for the image points, one for each image point, can be nullptr if 'numberImagePoints == 0'
516 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
517 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
518 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
519 * @param objectPointOctree The octree holding all 3D object points
520 * @param objectPointIds The ids of all 3D object points, must be valid
521 * @param objectPointDescriptorMap The map mapping object point ids to their corresponding descriptors
522 */
523 inline UnifiedGuidedMatchingFreakMultiDescriptor256Group(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap);
524
525 /**
526 * Determines the guided matching between 2D and 3D feature points.
527 * @see UnifiedGuidedMatching::determineGuidedMatchings().
528 */
529 void determineGuidedMatchings(const AnyCamera& anyCamera, const HomogenousMatrix4& world_T_camera, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, const DistanceValue& maximalDescriptorDistance, Indices32* matchedImagePointIndices = nullptr, Indices32* matchedObjectPointIds = nullptr, Worker* worker = nullptr) const override;
530
531 /**
532 * Updates the 2D image points e.g., to allow matching for a new camera frame.
533 * The input data will not be copied.
534 * @param imagePoints The new 2D image points, can be nullptr if 'numberImagePoints == 0'
535 * @param imagePointDescriptorGroups The descriptors for the image points, can be nullptr if 'numberImagePoints == 0'
536 * @param numberImagePoints The number of image points, with range [0, infinity)
537 */
538 inline void updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints);
539
540 /**
541 * Removes the image points from this object.
542 */
543 inline void clearImagePoints();
544
545 protected:
546
547 /// The groups of descriptors for the image points, one for each image point.
549
550 /// The map mapping object point ids to their corresponding descriptors.
552};
553
554/**
555 * This class implements the unguided matching object for groups of FREAK Multi features with 32 bytes or 256 bits.
556 * @ingroup trackingmapbuilding
557 */
559{
560 public:
561
562 /// Definition of the distance for the binary descriptor.
563 typedef unsigned int DescriptorDistance;
564
565 /// Definition of the descriptor for 2D image points.
567
568 /// Definition of the groups of descriptors for 2D image points.
570
571 /// Definition of the descriptor for 3D object points (several descriptors per point possible).
573
574 /// Definition of a vocabulary forest for object point descriptors.
576
577 /// Definition of a vocabulary tree for object point descriptors.
579
580 public:
581
582 /**
583 * Creates a new matching object with 3D object points only.
584 * Does not create a copy of the given input.
585 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
586 * @param objectPointDescriptors The descriptors for the object points, one for each index in 'objectPointIndices'
587 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
588 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices
589 * @param forestObjectPointDescriptors The vocabulary forest for the object point features
590 */
591 inline UnifiedUnguidedMatchingFreakMultiFeatures256Group(const Vector3* objectPoints, const ObjectPointDescriptor* objectPointDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const BinaryVocabularyForest& forestObjectPointDescriptors);
592
593 /**
594 * Creates a new matching object with 2D image points and 3D object points only.
595 * Does not create a copy of the given input.
596 * @param imagePoints The 2D image points, can be nullptr if 'numberImagePoints == 0'
597 * @param imagePointDescriptorGroups The groups of descriptors for the image points, one for each image point, can be nullptr if 'numberImagePoints == 0'
598 * @param numberImagePoints the number of 2D image points, with range [0, infinity)
599 * @param objectPoints The 3D object points, can be nullptr if 'numberObjectPoints == 0'
600 * @param objectPointDescriptors The descriptors for the object points, one for each index in 'objectPointIndices'
601 * @param numberObjectPoints The number of 3D object points, with range [0, infinity)
602 * @param objectPointIndices The indices of the corresponding 3D object points, one for each object point descriptor, mainly a map mapping descriptor indices to point indices, must be valid
603 * @param forestObjectPointDescriptors The vocabulary forest for the object point features
604 */
605 inline UnifiedUnguidedMatchingFreakMultiFeatures256Group(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints, const Vector3* objectPoints, const ObjectPointDescriptor* objectPointDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const BinaryVocabularyForest& forestObjectPointDescriptors);
606
607 /**
608 * Updates the 2D image points e.g., to allow matching for a new camera frame.
609 * The input data will not be copied.
610 * @param imagePoints The new 2D image points, can be nullptr if 'numberImagePoints == 0'
611 * @param imagePointDescriptorGroups The descriptors for the image points, can be nullptr if 'numberImagePoints == 0'
612 * @param numberImagePoints The number of image points, with range [0, infinity)
613 */
614 inline void updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints);
615
616 /**
617 * Removes the image points from this object.
618 */
619 inline void clearImagePoints();
620
621 /**
622 * Determines the guided matching between 2D and 3D feature points.
623 * @see UnifiedUnguidedMatching::determineUnguidedMatchings().
624 */
625 bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue& maximalDescriptorDistance, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, Worker* worker = nullptr) const override;
626
627 protected:
628
629 /// The groups of descriptors for the image points, one for each image point.
631
632 /// The descriptors for the object points, one for each index in 'objectPointIndices'.
634
635 /// The vocabulary forest for the object point features.
637};
638
639inline UnifiedMatching::DistanceValue::DistanceValue(const unsigned int binaryDistance) :
640 binaryDistance_(binaryDistance)
641{
642 ocean_assert(binaryDistance_ != (unsigned int)(-1));
643}
644
645inline UnifiedMatching::DistanceValue::DistanceValue(const float floatDistance) :
646 floatDistance_(floatDistance)
647{
648 ocean_assert(floatDistance_ >= 0.0f && floatDistance_ <= 1.0f);
649}
650
651inline UnifiedMatching::DistanceValue::DistanceValue(const unsigned int binaryDistance, const float floatDistance) :
652 binaryDistance_(binaryDistance),
653 floatDistance_(floatDistance)
654{
655 ocean_assert(isValid());
656}
657
659{
660 ocean_assert(binaryDistance_ != (unsigned int)(-1));
661 return binaryDistance_;
662}
663
665{
666 ocean_assert(floatDistance_ >= 0.0f);
667 return floatDistance_;
668}
669
670template <typename TDistance>
672{
673 if constexpr (std::is_floating_point<TDistance>::value)
674 {
675 return TDistance(floatDistance_);
676 }
677 else
678 {
679 ocean_assert(NumericT<TDistance>::isInsideValueRange(binaryDistance_));
680
681 return TDistance(binaryDistance_);
682 }
683}
684
686{
687 return binaryDistance_ != (unsigned int)(-1) || (floatDistance_ >= 0.0f && floatDistance_ <= 1.0f);
688}
689
690inline UnifiedMatching::UnifiedMatching(const Vector3* objectPoints, const size_t numberObjectPoints) :
691 objectPoints_(objectPoints),
692 numberObjectPoints_(numberObjectPoints)
693{
694 // nothing to do here
695}
696
697inline UnifiedMatching::UnifiedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints) :
698 imagePoints_(imagePoints),
699 numberImagePoints_(numberImagePoints),
700 objectPoints_(objectPoints),
701 numberObjectPoints_(numberObjectPoints)
702{
703 // nothing to do here
704}
705
707{
708 return numberImagePoints_;
709}
710
711inline UnifiedGuidedMatching::UnifiedGuidedMatching(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds) :
712 UnifiedMatching(objectPoints, numberObjectPoints),
713 objectPointOctree_(objectPointOctree),
714 objectPointIds_(objectPointIds)
715{
716 // nothing to do here
717}
718
719inline UnifiedGuidedMatching::UnifiedGuidedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds) :
720 UnifiedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints),
721 objectPointOctree_(objectPointOctree),
722 objectPointIds_(objectPointIds)
723{
724 // nothing to do here
725}
726
727inline UnifiedUnguidedMatching::UnifiedUnguidedMatching(const Vector3* objectPoints, const size_t numberObjectPoints, const Index32* objectPointIndices) :
728 UnifiedMatching(objectPoints, numberObjectPoints),
729 objectPointIndices_(objectPointIndices)
730{
731 // nothing to do here
732}
733
734inline UnifiedUnguidedMatching::UnifiedUnguidedMatching(const Vector2* imagePoints, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Index32* objectPointIndices) :
735 UnifiedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints),
736 objectPointIndices_(objectPointIndices)
737{
738 // nothing to do here
739}
740
741template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance>
742inline UnifiedGuidedMatchingT<TImagePointDescriptor, TObjectPointDescriptor, TDistance>::UnifiedGuidedMatchingT(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap) :
743 UnifiedGuidedMatching(objectPoints, numberObjectPoints, objectPointOctree, objectPointIds),
744 objectPointDescriptorMap_(objectPointDescriptorMap)
745{
746 // nothing to do here
747}
748
749template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance>
750inline UnifiedGuidedMatchingT<TImagePointDescriptor, TObjectPointDescriptor, TDistance>::UnifiedGuidedMatchingT(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap) :
751 UnifiedGuidedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints, objectPointOctree, objectPointIds),
752 imagePointDescriptors_(imagePointDescriptors),
753 objectPointDescriptorMap_(objectPointDescriptorMap)
754{
755 // nothing to do here
756}
757
758template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance>
759inline void UnifiedGuidedMatchingT<TImagePointDescriptor, TObjectPointDescriptor, TDistance>::updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints)
760{
761 imagePoints_ = imagePoints;
762 imagePointDescriptors_ = imagePointDescriptors;
763 numberImagePoints_ = numberImagePoints;
764}
765
766template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance>
768{
769 imagePoints_ = nullptr;
770 imagePointDescriptors_ = nullptr;
771 numberImagePoints_ = 0;
772}
773
774template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance>
775void UnifiedGuidedMatchingT<TImagePointDescriptor, TObjectPointDescriptor, TDistance>::determineGuidedMatchings(const AnyCamera& anyCamera, const HomogenousMatrix4& world_T_camera, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, const DistanceValue& maximalDescriptorDistance, Indices32* matchedImagePointIndices, Indices32* matchedObjectPointIds, Worker* worker) const
776{
777 PoseEstimationT::determineGuidedMatchings<ImagePointDescriptor, ObjectPointDescriptor, DescriptorDistance, UnifiedDescriptorT<TImagePointDescriptor>::determineDistance>(anyCamera, world_T_camera, imagePoints_, imagePointDescriptors_, numberImagePoints_, objectPoints_, objectPointOctree_, objectPointIds_, objectPointDescriptorMap_, matchedImagePoints, matchedObjectPoints, maximalDescriptorDistance.distance<TDistance>(), matchedImagePointIndices, matchedObjectPointIds, worker);
778}
779
780template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance>
781inline UnifiedUnguidedMatchingT<TImagePointDescriptor, TObjectPointVocabularyDescriptor, TDistance>::UnifiedUnguidedMatchingT(const Vector3* objectPoints, const ObjectPointVocabularyDescriptor* objectPointVocabularyDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const VocabularyForest& forestObjectPointDescriptors) :
782 UnifiedUnguidedMatching(objectPoints, numberObjectPoints, objectPointIndices),
783 objectPointVocabularyDescriptors_(objectPointVocabularyDescriptors),
784 forestObjectPointDescriptors_(forestObjectPointDescriptors)
785{
786 // nothing to do here
787}
788
789template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance>
790inline UnifiedUnguidedMatchingT<TImagePointDescriptor, TObjectPointVocabularyDescriptor, TDistance>::UnifiedUnguidedMatchingT(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints, const Vector3* objectPoints, const ObjectPointVocabularyDescriptor* objectPointVocabularyDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const VocabularyForest& forestObjectPointDescriptors) :
791 UnifiedUnguidedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints, objectPointIndices),
792 imagePointDescriptors_(imagePointDescriptors),
793 objectPointVocabularyDescriptors_(objectPointVocabularyDescriptors),
794 forestObjectPointDescriptors_(forestObjectPointDescriptors)
795{
796 // nothing to do here
797}
798
799template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance>
800inline void UnifiedUnguidedMatchingT<TImagePointDescriptor, TObjectPointVocabularyDescriptor, TDistance>::updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptor* imagePointDescriptors, const size_t numberImagePoints)
801{
802 imagePoints_ = imagePoints;
803 imagePointDescriptors_ = imagePointDescriptors;
804 numberImagePoints_ = numberImagePoints;
805}
806
807template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance>
809{
810 imagePoints_ = nullptr;
811 imagePointDescriptors_ = nullptr;
812 numberImagePoints_ = 0;
813}
814
815template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance>
816bool UnifiedUnguidedMatchingT<TImagePointDescriptor, TObjectPointVocabularyDescriptor, TDistance>::determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue& maximalDescriptorDistance, Vectors2& matchedImagePoints, Vectors3& matchedObjectPoints, Worker* worker) const
817{
818 if (imagePoints_ == nullptr || imagePointDescriptors_ == nullptr || numberImagePoints_ == 0)
819 {
820 return false;
821 }
822
823 typename VocabularyForest::Matches matches;
824
825 if constexpr (std::is_same<TImagePointDescriptor, DescriptorHandling::FreakMultiDescriptor256>::value) // TODO HACK
826 {
827 forestObjectPointDescriptors_.template matchMultiDescriptors<ImagePointDescriptor, DescriptorHandling::multiDescriptorFunction, VocabularyTree::MM_ALL_GOOD_LEAFS_2>(objectPointVocabularyDescriptors_, imagePointDescriptors_, numberImagePoints_, maximalDescriptorDistance.distance<TDistance>(), matches, worker);
828 }
829 else
830 {
831 forestObjectPointDescriptors_.template matchDescriptors<VocabularyTree::MM_ALL_GOOD_LEAFS_2>(objectPointVocabularyDescriptors_, imagePointDescriptors_, numberImagePoints_, maximalDescriptorDistance.distance<TDistance>(), matches, worker);
832 }
833
834 if (matches.size() < size_t(minimalNumberCorrespondences))
835 {
836 return false;
837 }
838
839 ocean_assert(matchedImagePoints.empty());
840 ocean_assert(matchedObjectPoints.empty());
841
842 matchedImagePoints.clear();
843 matchedObjectPoints.clear();
844
845 for (const typename VocabularyTree::Match& match : matches)
846 {
847 matchedImagePoints.emplace_back(imagePoints_[match.queryDescriptorIndex()]);
848 matchedObjectPoints.emplace_back(objectPoints_[objectPointIndices_[match.candidateDescriptorIndex()]]);
849 }
850
851 return true;
852}
853
854inline UnifiedGuidedMatchingFreakMultiDescriptor256Group::UnifiedGuidedMatchingFreakMultiDescriptor256Group(const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap) :
855 UnifiedGuidedMatching(objectPoints, numberObjectPoints, objectPointOctree, objectPointIds),
856 objectPointDescriptorMap_(objectPointDescriptorMap)
857{
858 // nothing to do here
859}
860
861inline UnifiedGuidedMatchingFreakMultiDescriptor256Group::UnifiedGuidedMatchingFreakMultiDescriptor256Group(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints, const Vector3* objectPoints, const size_t numberObjectPoints, const Geometry::Octree& objectPointOctree, const Index32* objectPointIds, const UnorderedDescriptorMap<ObjectPointDescriptor>& objectPointDescriptorMap) :
862 UnifiedGuidedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints, objectPointOctree, objectPointIds),
863 imagePointDescriptorGroups_(imagePointDescriptorGroups),
864 objectPointDescriptorMap_(objectPointDescriptorMap)
865{
866 // nothing to do here
867}
868
869inline void UnifiedGuidedMatchingFreakMultiDescriptor256Group::updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints)
870{
871 imagePoints_ = imagePoints;
872 imagePointDescriptorGroups_ = imagePointDescriptorGroups;
874}
875
882
883inline UnifiedUnguidedMatchingFreakMultiFeatures256Group::UnifiedUnguidedMatchingFreakMultiFeatures256Group(const Vector3* objectPoints, const ObjectPointDescriptor* objectPointDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const BinaryVocabularyForest& forestObjectPointDescriptors) :
884 UnifiedUnguidedMatching(objectPoints, numberObjectPoints, objectPointIndices),
885 objectPointDescriptors_(objectPointDescriptors),
886 forestObjectPointDescriptors_(forestObjectPointDescriptors)
887{
888 // nothing to do here
889}
890
891inline UnifiedUnguidedMatchingFreakMultiFeatures256Group::UnifiedUnguidedMatchingFreakMultiFeatures256Group(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints, const Vector3* objectPoints, const ObjectPointDescriptor* objectPointDescriptors, const size_t numberObjectPoints, const Index32* objectPointIndices, const BinaryVocabularyForest& forestObjectPointDescriptors) :
892 UnifiedUnguidedMatching(imagePoints, numberImagePoints, objectPoints, numberObjectPoints, objectPointIndices),
893 imagePointDescriptorGroups_(imagePointDescriptorGroups),
894 objectPointDescriptors_(objectPointDescriptors),
895 forestObjectPointDescriptors_(forestObjectPointDescriptors)
896{
897 // nothing to do here
898}
899
900inline void UnifiedUnguidedMatchingFreakMultiFeatures256Group::updateImagePoints(const Vector2* imagePoints, const ImagePointDescriptorGroup* imagePointDescriptorGroups, const size_t numberImagePoints)
901{
902 imagePoints_ = imagePoints;
903 imagePointDescriptorGroups_ = imagePointDescriptorGroups;
905}
906
913
914}
915
916}
917
918}
919
920#endif // META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_MATCHING_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class provides basic numeric functionalities.
Definition Numeric.h:57
std::array< float, tNumberElements > FloatDescriptor
Definition of a float descriptor.
Definition UnifiedDescriptor.h:140
std::vector< FloatDescriptor< tNumberElements > > FloatDescriptors
Definition of a vector holding float descriptors.
Definition UnifiedDescriptor.h:147
ByteDescriptor< tNumberBits/8u > BinaryDescriptor
Definition of a binary descriptor.
Definition UnifiedDescriptor.h:126
This class implements the guided matching object for groups of FREAK Multi features with 32 bytes or ...
Definition UnifiedMatching.h:478
UnifiedGuidedMatchingFreakMultiDescriptor256Group(const Vector3 *objectPoints, const size_t numberObjectPoints, const Geometry::Octree &objectPointOctree, const Index32 *objectPointIds, const UnorderedDescriptorMap< ObjectPointDescriptor > &objectPointDescriptorMap)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:854
CV::Detector::FREAKDescriptor32 ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:484
void determineGuidedMatchings(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, const DistanceValue &maximalDescriptorDistance, Indices32 *matchedImagePointIndices=nullptr, Indices32 *matchedObjectPointIds=nullptr, Worker *worker=nullptr) const override
Determines the guided matching between 2D and 3D feature points.
std::unordered_map< Index32, TDescriptor > UnorderedDescriptorMap
Definition of an unordered map mapping object point ids to descriptors.
Definition UnifiedMatching.h:496
CV::Detector::FREAKDescriptors32 ObjectPointDescriptor
Definition of the descriptor for 3D object points (several descriptors per point possible).
Definition UnifiedMatching.h:490
const ImagePointDescriptorGroup * imagePointDescriptorGroups_
The groups of descriptors for the image points, one for each image point.
Definition UnifiedMatching.h:548
void updateImagePoints(const Vector2 *imagePoints, const ImagePointDescriptorGroup *imagePointDescriptorGroups, const size_t numberImagePoints)
Updates the 2D image points e.g., to allow matching for a new camera frame.
Definition UnifiedMatching.h:869
const CV::Detector::FREAKDescriptors32 * ImagePointDescriptorGroup
Definition of the groups of descriptors for 2D image points.
Definition UnifiedMatching.h:487
const UnorderedDescriptorMap< ObjectPointDescriptor > & objectPointDescriptorMap_
The map mapping object point ids to their corresponding descriptors.
Definition UnifiedMatching.h:551
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:876
unsigned int DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:481
This class implements the base class for all guided matching objects.
Definition UnifiedMatching.h:166
const Geometry::Octree & objectPointOctree_
The octree holding all 3D object points.
Definition UnifiedMatching.h:209
const Index32 * objectPointIds_
The ids of all 3D object points.
Definition UnifiedMatching.h:212
UnifiedGuidedMatching(const Vector3 *objectPoints, const size_t numberObjectPoints, const Geometry::Octree &objectPointOctree, const Index32 *objectPointIds)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:711
virtual void determineGuidedMatchings(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, const DistanceValue &maximalDescriptorDistance, Indices32 *matchedImagePointIndices=nullptr, Indices32 *matchedObjectPointIds=nullptr, Worker *worker=nullptr) const =0
Determines the guided matching between 2D and 3D feature points.
This class implements the guided matching object for specific features.
Definition UnifiedMatching.h:285
const UnorderedDescriptorMap< ObjectPointDescriptor > & objectPointDescriptorMap_
The map mapping object point ids to their corresponding descriptors.
Definition UnifiedMatching.h:356
TObjectPointDescriptor ObjectPointDescriptor
Definition of the descriptor for 3D object points.
Definition UnifiedMatching.h:295
TImagePointDescriptor ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:292
void determineGuidedMatchings(const AnyCamera &anyCamera, const HomogenousMatrix4 &world_T_camera, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, const DistanceValue &maximalDescriptorDistance, Indices32 *matchedImagePointIndices=nullptr, Indices32 *matchedObjectPointIds=nullptr, Worker *worker=nullptr) const override
Determines the guided matching between 2D and 3D feature points.
Definition UnifiedMatching.h:775
void updateImagePoints(const Vector2 *imagePoints, const ImagePointDescriptor *imagePointDescriptors, const size_t numberImagePoints)
Updates the 2D image points e.g., to allow matching for a new camera frame.
Definition UnifiedMatching.h:759
TDistance DescriptorDistance
Definition of the distance data type.
Definition UnifiedMatching.h:289
UnifiedGuidedMatchingT(const Vector3 *objectPoints, const size_t numberObjectPoints, const Geometry::Octree &objectPointOctree, const Index32 *objectPointIds, const UnorderedDescriptorMap< ObjectPointDescriptor > &objectPointDescriptorMap)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:742
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:767
const ImagePointDescriptor * imagePointDescriptors_
The descriptors for the image points, one for each image point.
Definition UnifiedMatching.h:353
std::unordered_map< Index32, TDescriptor > UnorderedDescriptorMap
Definition of an unordered map mapping object point ids to descriptors.
Definition UnifiedMatching.h:301
Definition of a descriptor distance value.
Definition UnifiedMatching.h:52
float floatDistance_
The floating point distance, with range [0, 1], -1 if unknown.
Definition UnifiedMatching.h:110
unsigned int binaryDistance_
The binary distance, with range [0, infinity), -1 if unknown.
Definition UnifiedMatching.h:107
bool isValid() const
Returns whether the object holds a valid distance.
Definition UnifiedMatching.h:685
unsigned int binaryDistance() const
Returns the binary distance.
Definition UnifiedMatching.h:658
DistanceValue()=default
Default constructor with an invalid descriptor distance.
TDistance distance() const
Returns either the binary or the floating point distance.
Definition UnifiedMatching.h:671
float floatDistance() const
Returns the floating point distance.
Definition UnifiedMatching.h:664
The base class for all unified matching objects.
Definition UnifiedMatching.h:45
UnifiedMatching(const Vector3 *objectPoints, const size_t numberObjectPoints)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:690
const Vector3 * objectPoints_
The 3D object points.
Definition UnifiedMatching.h:155
const Vector2 * imagePoints_
The 2D image points.
Definition UnifiedMatching.h:149
const size_t numberObjectPoints_
The number of 3D object points.
Definition UnifiedMatching.h:158
virtual ~UnifiedMatching()=default
Disposes this object.
size_t numberImagePoints_
The number of 2D image points.
Definition UnifiedMatching.h:152
size_t numberImagePoints() const
Returns the number of image points.
Definition UnifiedMatching.h:706
This class implements the unguided matching object for groups of FREAK Multi features with 32 bytes o...
Definition UnifiedMatching.h:559
const ImagePointDescriptorGroup * imagePointDescriptorGroups_
The groups of descriptors for the image points, one for each image point.
Definition UnifiedMatching.h:630
const BinaryVocabularyForest & forestObjectPointDescriptors_
The vocabulary forest for the object point features.
Definition UnifiedMatching.h:636
bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue &maximalDescriptorDistance, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, Worker *worker=nullptr) const override
Determines the guided matching between 2D and 3D feature points.
UnifiedUnguidedMatchingFreakMultiFeatures256Group(const Vector3 *objectPoints, const ObjectPointDescriptor *objectPointDescriptors, const size_t numberObjectPoints, const Index32 *objectPointIndices, const BinaryVocabularyForest &forestObjectPointDescriptors)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:883
void updateImagePoints(const Vector2 *imagePoints, const ImagePointDescriptorGroup *imagePointDescriptorGroups, const size_t numberImagePoints)
Updates the 2D image points e.g., to allow matching for a new camera frame.
Definition UnifiedMatching.h:900
CV::Detector::FREAKDescriptor32 ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:566
const ObjectPointDescriptor * objectPointDescriptors_
The descriptors for the object points, one for each index in 'objectPointIndices'.
Definition UnifiedMatching.h:633
BinaryVocabularyForest::TVocabularyTree BinaryVocabularyTree
Definition of a vocabulary tree for object point descriptors.
Definition UnifiedMatching.h:578
const CV::Detector::FREAKDescriptors32 * ImagePointDescriptorGroup
Definition of the groups of descriptors for 2D image points.
Definition UnifiedMatching.h:569
Tracking::VocabularyForest< ObjectPointDescriptor, DescriptorDistance, UnifiedDescriptorT< ObjectPointDescriptor >::determineDistance > BinaryVocabularyForest
Definition of a vocabulary forest for object point descriptors.
Definition UnifiedMatching.h:575
unsigned int DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:563
UnifiedDescriptor::BinaryDescriptor< 256u > ObjectPointDescriptor
Definition of the descriptor for 3D object points (several descriptors per point possible).
Definition UnifiedMatching.h:572
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:907
This class implements the base class for all unguided matching objects.
Definition UnifiedMatching.h:227
virtual bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue &maximalDescriptorDistance, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, Worker *worker=nullptr) const =0
Determines the unguided matching between 2D and 3D feature points.
UnifiedUnguidedMatching(const Vector3 *objectPoints, const size_t numberObjectPoints, const Index32 *objectPointIndices)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:727
const Index32 * objectPointIndices_
The indices of the corresponding 3D object points, one for each object point descriptor,...
Definition UnifiedMatching.h:266
This class implements the unguided matching object for FREAK Multi features with 32 bytes or 256 bits...
Definition UnifiedMatching.h:382
VocabularyForest::TVocabularyTree VocabularyTree
Definition of a vocabulary tree for object point descriptors.
Definition UnifiedMatching.h:398
Tracking::VocabularyForest< ObjectPointVocabularyDescriptor, DescriptorDistance, UnifiedDescriptorT< ObjectPointVocabularyDescriptor >::determineDistance > VocabularyForest
Definition of a vocabulary forest for object point descriptors.
Definition UnifiedMatching.h:395
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:808
TImagePointDescriptor ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:389
bool determineUnguidedMatchings(const unsigned int minimalNumberCorrespondences, const DistanceValue &maximalDescriptorDistance, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, Worker *worker=nullptr) const override
Determines the unguided matching between 2D and 3D feature points.
Definition UnifiedMatching.h:816
const VocabularyForest & forestObjectPointDescriptors_
The vocabulary forest for the object point features.
Definition UnifiedMatching.h:456
TDistance DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:386
const ImagePointDescriptor * imagePointDescriptors_
The descriptors for the image points, one for each image point.
Definition UnifiedMatching.h:450
UnifiedUnguidedMatchingT(const Vector3 *objectPoints, const ObjectPointVocabularyDescriptor *objectPointVocabularyDescriptors, const size_t numberObjectPoints, const Index32 *objectPointIndices, const VocabularyForest &forestObjectPointDescriptors)
Creates a new matching object with 3D object points only.
Definition UnifiedMatching.h:781
TObjectPointVocabularyDescriptor ObjectPointVocabularyDescriptor
Definition of the descriptor for 3D object points.
Definition UnifiedMatching.h:392
void updateImagePoints(const Vector2 *imagePoints, const ImagePointDescriptor *imagePointDescriptors, const size_t numberImagePoints)
Updates the 2D image points e.g., to allow matching for a new camera frame.
Definition UnifiedMatching.h:800
const ObjectPointVocabularyDescriptor * objectPointVocabularyDescriptors_
The descriptors for the object points, one for each index in 'objectPointIndices'.
Definition UnifiedMatching.h:453
This class implements a Vocabulary Forest holding several Vocabulary Trees.
Definition VocabularyTree.h:766
Matches< TDistance > Matches
Definition of a vector holding Match objects.
Definition VocabularyTree.h:807
This class implements a Vocabulary Tree for feature descriptors.
Definition VocabularyTree.h:223
Match< TDistance > Match
Definition of a Match object using the distance data type of this tree.
Definition VocabularyTree.h:274
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
OctreeT< Scalar > Octree
Definition of an Octree using Scalar as data type.
Definition Octree.h:32
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
std::shared_ptr< UnifiedGuidedMatching > SharedUnifiedGuidedMatching
Definition of a shared pointer holding an UnifiedGuidedMatching object.
Definition UnifiedMatching.h:220
std::shared_ptr< UnifiedUnguidedMatching > SharedUnifiedUnguidedMatching
Definition of a shared pointer holding an UnifiedUnguidedMatching object.
Definition UnifiedMatching.h:274
std::vector< FREAKDescriptor32 > FREAKDescriptors32
Vector of 32-bytes long FREAK descriptors.
Definition FREAKDescriptor.h:69
FREAKDescriptorT< 32 > FREAKDescriptor32
Typedef for the 32-bytes long FREAK descriptor.
Definition FREAKDescriptor.h:66
The namespace covering the entire Ocean framework.
Definition Accessor.h:15