8#ifndef META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_MATCHING_H
9#define META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_MATCHING_H
95 template <
typename TDistance>
283template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TDistance = typename UnifiedDescriptor::DistanceTyper<TImagePointDescriptor>::Type>
300 template <
typename TDescriptor>
370template <u
int16_t tElements>
380template <typename TImagePointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDistance = typename UnifiedDescriptor::DistanceTyper<TImagePointDescriptor>::Type>
470template <u
int16_t tElements>
495 template <
typename TDescriptor>
670template <
typename TDistance>
673 if constexpr (std::is_floating_point<TDistance>::value)
741template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TDistance>
749template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TDistance>
758template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TDistance>
766template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TDistance>
774template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TDistance>
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);
780template <
typename TImagePo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDistance>
789template <
typename TImagePo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDistance>
799template <
typename TImagePo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDistance>
807template <
typename TImagePo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDistance>
815template <
typename TImagePo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDistance>
825 if constexpr (std::is_same<TImagePointDescriptor, DescriptorHandling::FreakMultiDescriptor256>::value)
834 if (matches.size() <
size_t(minimalNumberCorrespondences))
839 ocean_assert(matchedImagePoints.empty());
840 ocean_assert(matchedObjectPoints.empty());
842 matchedImagePoints.clear();
843 matchedObjectPoints.clear();
847 matchedImagePoints.emplace_back(
imagePoints_[match.queryDescriptorIndex()]);
static bool isInsideValueRange(const TValue &value)
Returns whether a given value of an arbitrary data type fits into the value range of 'T'.
Definition Numeric.h:3143
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
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
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.
CV::Detector::FREAKDescriptors32 ObjectPointDescriptor
Definition of the descriptor for 3D object points (several descriptors per point possible).
Definition UnifiedMatching.h:490
std::unordered_map< Index32, TDescriptor > UnorderedDescriptorMap
Definition of an unordered map mapping object point ids to descriptors.
Definition UnifiedMatching.h:496
unsigned int DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:481
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 UnorderedDescriptorMap< ObjectPointDescriptor > & objectPointDescriptorMap_
The map mapping object point ids to their corresponding descriptors.
Definition UnifiedMatching.h:551
CV::Detector::FREAKDescriptor32 ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:484
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:876
const CV::Detector::FREAKDescriptors32 * ImagePointDescriptorGroup
Definition of the groups of descriptors for 2D image points.
Definition UnifiedMatching.h:487
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_
Definition UnifiedMatching.h:356
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)
Creates a new matching object with 2D image points and 3D object points only.
Definition UnifiedMatching.h:750
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
TImagePointDescriptor ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:292
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
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
TDistance DescriptorDistance
Definition of the distance data type.
Definition UnifiedMatching.h:289
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:767
TObjectPointDescriptor ObjectPointDescriptor
Definition of the descriptor for 3D object points.
Definition UnifiedMatching.h:295
const ImagePointDescriptor * imagePointDescriptors_
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
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
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.
CV::Detector::FREAKDescriptor32 ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:566
Tracking::VocabularyForest< ObjectPointDescriptor, DescriptorDistance, UnifiedDescriptorT< ObjectPointDescriptor >::determineDistance > BinaryVocabularyForest
Definition of a vocabulary forest for object point descriptors.
Definition UnifiedMatching.h:575
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
BinaryVocabularyForest::TVocabularyTree BinaryVocabularyTree
Definition of a vocabulary tree for object point descriptors.
Definition UnifiedMatching.h:578
const ObjectPointDescriptor * objectPointDescriptors_
The descriptors for the object points, one for each index in 'objectPointIndices'.
Definition UnifiedMatching.h:633
UnifiedDescriptor::BinaryDescriptor< 256u > ObjectPointDescriptor
Definition of the descriptor for 3D object points (several descriptors per point possible).
Definition UnifiedMatching.h:572
const CV::Detector::FREAKDescriptors32 * ImagePointDescriptorGroup
Definition of the groups of descriptors for 2D image points.
Definition UnifiedMatching.h:569
unsigned int DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:563
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:907
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
TObjectPointVocabularyDescriptor ObjectPointVocabularyDescriptor
Definition of the descriptor for 3D object points.
Definition UnifiedMatching.h:392
TImagePointDescriptor ImagePointDescriptor
Definition of the descriptor for 2D image points.
Definition UnifiedMatching.h:389
TDistance DescriptorDistance
Definition of the distance for the binary descriptor.
Definition UnifiedMatching.h:386
void clearImagePoints()
Removes the image points from this object.
Definition UnifiedMatching.h:808
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
typename VocabularyForest::TVocabularyTree VocabularyTree
Definition of a vocabulary tree for object point descriptors.
Definition UnifiedMatching.h:398
const VocabularyForest & forestObjectPointDescriptors_
Definition UnifiedMatching.h:456
Tracking::VocabularyForest< ObjectPointVocabularyDescriptor, DescriptorDistance, UnifiedDescriptorT< ObjectPointVocabularyDescriptor >::determineDistance > VocabularyForest
Definition of a vocabulary forest for object point descriptors.
Definition UnifiedMatching.h:395
const ImagePointDescriptor * imagePointDescriptors_
Definition UnifiedMatching.h:450
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)
Creates a new matching object with 2D image points and 3D object points only.
Definition UnifiedMatching.h:790
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
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_
Definition UnifiedMatching.h:453
static void determineGuidedMatchings(const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector2 *imagePoints, const TImagePointDescriptor *imagePointDescriptors, const size_t numberImagePoints, const Vector3 *objectPoints, const Geometry::Octree &objectPointOctree, const Index32 *objectPointIds, const UnorderedDescriptorMap< TObjectPointDescriptor > &objectPointDescriptorMap, Vectors2 &matchedImagePoints, Vectors3 &matchedObjectPoints, const TDescriptorDistance maximalDescriptorDistance, Indices32 *matchedImagePointIndices=nullptr, Indices32 *matchedObjectPointIds=nullptr, Worker *worker=nullptr)
Determines the guided matching between 2D/3D correspondences.
Definition PoseEstimationT.h:745
This class implements a Vocabulary Forest holding several Vocabulary Trees.
Definition VocabularyTree.h:766
VocabularyTree< TDescriptor, TDistance, tDistanceFunction > TVocabularyTree
Definition of the Vocabulary Tree object.
Definition VocabularyTree.h:797
Matches< TDistance > Matches
Definition of a vector holding Match objects.
Definition VocabularyTree.h:807
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
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
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
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
AnyCameraT< Scalar > AnyCamera
Definition of an AnyCamera object with Scalar precision.
Definition AnyCamera.h:31
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
UnifiedUnguidedMatchingT< CV::Detector::FREAKDescriptor32, UnifiedDescriptor::BinaryDescriptor< 256u > > UnifiedUnguidedMatchingFreakMultiLevelDescriptor256
Definition of an UnifiedUnguidedMatchingT object for FREAK descriptors with 256 bits.
Definition UnifiedMatching.h:463
std::shared_ptr< UnifiedUnguidedMatching > SharedUnifiedUnguidedMatching
Definition of a shared pointer holding an UnifiedUnguidedMatching object.
Definition UnifiedMatching.h:274
UnifiedGuidedMatchingT< CV::Detector::FREAKDescriptor32, CV::Detector::FREAKDescriptors32 > UnifiedGuidedMatchingFreakMultiLevelDescriptor256
Definition of a UnifiedGuidedMatchingT object for FREAK descriptors with 256 bits.
Definition UnifiedMatching.h:363
UnifiedUnguidedMatchingT< UnifiedDescriptor::FloatDescriptor< tElements >, UnifiedDescriptor::FloatDescriptor< tElements > > UnifiedUnguidedMatchingFloatDescriptor
Definition of an UnifiedUnguidedMatchingT object for float descriptors.
Definition UnifiedMatching.h:471
UnifiedGuidedMatchingT< UnifiedDescriptor::FloatDescriptor< tElements >, UnifiedDescriptor::FloatDescriptors< tElements > > UnifiedGuidedMatchingFloatSingleLevelDescriptor
Definition of a UnifiedGuidedMatchingT object for float descriptors.
Definition UnifiedMatching.h:371
std::shared_ptr< UnifiedGuidedMatching > SharedUnifiedGuidedMatching
Definition of a shared pointer holding an UnifiedGuidedMatching object.
Definition UnifiedMatching.h:220
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
Namespace of the Map Building Tracking library.
Definition DescriptorHandling.h:25
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15