8 #ifndef META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_DESCRIPTOR_H
9 #define META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_DESCRIPTOR_H
111 template <u
int16_t tNumberBytes>
118 template <u
int16_t tNumberBytes>
125 template <u
int16_t tNumberBits>
132 template <u
int16_t tNumberBits>
139 template <u
int16_t tNumberElements>
146 template <u
int16_t tNumberElements>
165 template <
typename T>
175 template <
typename T>
285 template <
bool tMultiLevel,
bool tMultiView, u
int16_t tNumberBits>
295 template <
bool tMultiLevel,
bool tMultiView, u
int16_t tNumberElements>
304 template <DescriptorType tDescriptorType, u
int16_t tNumberItems>
326 template <u
int16_t tNumberBytes>
329 static_assert(tNumberBytes >= 8u,
"Most likely wrong descriptor!");
330 static_assert(tNumberBytes <= 8191u,
"Invalid descriptor!");
343 template <u
int16_t tNumberElements>
346 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
373 template <u
int16_t tNumberBytes>
376 static_assert(tNumberBytes >= 8u,
"Most likely wrong descriptor!");
377 static_assert(tNumberBytes <= 8191u,
"Invalid descriptor!");
387 return UnifiedDescriptor::descriptorType<DT_BINARY_SINGLE_LEVEL_SINGLE_VIEW, tNumberBytes * 8u>();
396 template <u
int16_t tNumberBytes>
399 static_assert(tNumberBytes >= 8u,
"Most likely wrong descriptor!");
400 static_assert(tNumberBytes <= 8191u,
"Invalid descriptor!");
410 return UnifiedDescriptor::descriptorType<DT_BINARY_SINGLE_LEVEL_MULTI_VIEW, tNumberBytes * 8u>();
419 template <u
int16_t tNumberElements>
422 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
432 return descriptorType<DT_FLOAT_SINGLE_LEVEL_SINGLE_VIEW, tNumberElements>();
441 template <u
int16_t tNumberElements>
444 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
450 return descriptorType<DT_FLOAT_SINGLE_LEVEL_MULTI_VIEW, tNumberElements>();
487 descriptorType_(descriptorType)
561 template <
bool tMultiLevel,
bool tMultiView, u
int16_t tNumberBits>
564 static_assert(tNumberBits >= 1u,
"Invalid number bits!");
569 template <
bool tMultiLevel,
bool tMultiView, u
int16_t tNumberElements>
572 static_assert(tNumberElements >= 1u,
"Invalid number elements!");
577 template <UnifiedDescriptor::DescriptorType tDescriptorType, u
int16_t tNumberItems>
580 static_assert(tDescriptorType != DescriptorType::DT_INVALID,
"Invalid descriptor type!");
581 static_assert(tNumberItems >= 1u,
"Invalid item number!");
593 template <typename TDescriptor, typename TDistance = typename UnifiedDescriptor::DistanceTyper<TDescriptor>::Type>
604 template <u
int16_t tNumberBytes>
607 static_assert(tNumberBytes >= 8u && tNumberBytes <= 8191u,
"Most likely wrong descriptor!");
608 static_assert(tNumberBytes <= 8191u,
"Invalid descriptor!");
643 template <u
int16_t tNumberBytes>
646 return CV::Detector::Descriptor::calculateHammingDistance<sizeof(Descriptor) * 8>(&descriptorA, &descriptorB);
649 template <u
int16_t tNumberBytes>
650 OCEAN_FORCE_INLINE
unsigned int UnifiedDescriptorT<typename UnifiedDescriptor::ByteDescriptor<tNumberBytes>>::determineDistance(
const Descriptor& descriptorA,
const Descriptors& descriptorsB)
652 unsigned int bestDistance = (
unsigned int)(-1);
654 for (
const Descriptor& descriptorB : descriptorsB)
656 const unsigned int distance = determineDistance(descriptorA, descriptorB);
658 if (distance < bestDistance)
660 bestDistance = distance;
672 template <u
int16_t tNumberElements>
675 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
710 template <u
int16_t tNumberElements>
713 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
717 for (
unsigned int n = 0u; n < tNumberElements; ++n)
719 const float difference = descriptorA[n] - descriptorB[n];
727 template <u
int16_t tNumberElements>
728 OCEAN_FORCE_INLINE
float UnifiedDescriptorT<typename UnifiedDescriptor::FloatDescriptor<tNumberElements>>::determineDistance(
const Descriptor& descriptorA,
const Descriptors& descriptorsB)
730 static_assert(tNumberElements >= 1u,
"Invalid number of elements!");
732 ocean_assert(descriptorsB.size() >= 1);
736 for (
const Descriptor& descriptorB : descriptorsB)
738 const float sqrDistance = determineDistance(descriptorA, descriptorB);
746 return bestSqrDistance;
777 static OCEAN_FORCE_INLINE
unsigned int determineDistance(
const Descriptor& descriptorA,
const Descriptor& descriptorB);
786 static OCEAN_FORCE_INLINE
unsigned int determineDistance(
const Descriptor& descriptorA,
const Descriptors& descriptorsB);
791 return descriptorA.distance(descriptorB);
796 unsigned int bestDistance = (
unsigned int)(-1);
798 for (
const Descriptor& descriptorB : descriptorsB)
800 const unsigned int distance = determineDistance(descriptorA, descriptorB);
802 if (distance < bestDistance)
804 bestDistance = distance;
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
static constexpr DescriptorType type()
Returns the type of the descriptor.
Definition: UnifiedDescriptor.h:385
static constexpr DescriptorType type()
Returns the type of the descriptor.
Definition: UnifiedDescriptor.h:408
static constexpr DescriptorType type()
Definition: UnifiedDescriptor.h:448
static constexpr DescriptorType type()
Definition: UnifiedDescriptor.h:464
static constexpr DescriptorType type()
Returns the type of the descriptor.
Definition: UnifiedDescriptor.h:430
static constexpr DescriptorType type()
Definition: UnifiedDescriptor.h:480
This class implements a helper class allowing to determine the descriptor type value for a descriptor...
Definition: UnifiedDescriptor.h:177
unsigned int Type
The distance type the descriptor uses.
Definition: UnifiedDescriptor.h:365
unsigned int Type
The distance type the descriptor uses.
Definition: UnifiedDescriptor.h:329
float Type
The distance type the descriptor uses.
Definition: UnifiedDescriptor.h:346
This class implements a helper class allowing to determine the type of the distance value between two...
Definition: UnifiedDescriptor.h:167
This class implements the base class for all unified descriptor objects.
Definition: UnifiedDescriptor.h:31
UnifiedDescriptor(const DescriptorType descriptorType)
Creates a new descriptors object.
Definition: UnifiedDescriptor.h:486
std::array< float, tNumberElements > FloatDescriptor
Definition of a float descriptor.
Definition: UnifiedDescriptor.h:140
DescriptorType descriptorType_
The descriptor type of all descriptors hold in this object.
Definition: UnifiedDescriptor.h:318
static constexpr uint16_t numberElements(const DescriptorType descriptorType)
Returns the number of elements a float descriptor is composed of.
Definition: UnifiedDescriptor.h:532
static constexpr uint64_t desriptorTypeNumberItemsEndBit_
The end/exclusive bit up to which the number of items are defined in the descriptor type.
Definition: UnifiedDescriptor.h:38
CV::Detector::FREAKDescriptor32 FreakMultiDescriptor256
Definition of a FREAK Multi Descriptor with 256 bits (32 bytes).
Definition: UnifiedDescriptor.h:153
static constexpr bool isBinary(const DescriptorType descriptorType)
Returns whether a descriptor type represents a binary-based descriptor.
Definition: UnifiedDescriptor.h:497
static constexpr uint64_t desriptorTypeNumberItemsBeginBit_
The first bit at which the number of items are defined in the descriptor type.
Definition: UnifiedDescriptor.h:35
static constexpr DescriptorType floatDescriptorType()
Returns a float descriptor type.
Definition: UnifiedDescriptor.h:570
static constexpr DescriptorType binaryDescriptorType()
Returns a binary descriptor type.
Definition: UnifiedDescriptor.h:562
static constexpr bool isMultiLevel(const DescriptorType descriptorType)
Returns whether a descriptor type represents a multi level descriptor.
Definition: UnifiedDescriptor.h:512
static constexpr bool isSingleLevel(const DescriptorType descriptorType)
Returns whether a descriptor type represents a single level descriptor.
Definition: UnifiedDescriptor.h:507
static constexpr uint64_t desriptorTypeCustomTypeBeginBit_
The first bit at which custom descriptors are defined in the descriptor type.
Definition: UnifiedDescriptor.h:41
std::vector< FreakMultiDescriptor256 > FreakMultiDescriptors256
Definition of vector holding FREAK Multi Descriptors with 256 bits (32 bytes).
Definition: UnifiedDescriptor.h:159
std::vector< FloatDescriptor< tNumberElements > > FloatDescriptors
Definition of a vector holding float descriptors.
Definition: UnifiedDescriptor.h:147
static constexpr bool isMultiView(const DescriptorType descriptorType)
Returns whether a descriptor type represents a multi view descriptor.
Definition: UnifiedDescriptor.h:522
std::vector< BinaryDescriptor< tNumberBits > > BinaryDescriptors
Definition of a vector holding binary descriptors.
Definition: UnifiedDescriptor.h:133
DescriptorType descriptorType() const
Returns the descriptor type of all descriptors hold in this object.
Definition: UnifiedDescriptor.h:492
static constexpr bool isCustom(const DescriptorType descriptorType)
Returns whether a descriptor type represents a custom descriptor.
Definition: UnifiedDescriptor.h:537
static constexpr uint16_t numberBits(const DescriptorType descriptorType)
Returns the number of bits a binary descriptor is composed of.
Definition: UnifiedDescriptor.h:527
std::vector< ByteDescriptor< tNumberBytes > > ByteDescriptors
Definition of a vector holding byte descriptors.
Definition: UnifiedDescriptor.h:119
static constexpr bool isSingleView(const DescriptorType descriptorType)
Returns whether a descriptor type represents a single view descriptor.
Definition: UnifiedDescriptor.h:517
DescriptorType
Definition of descriptor types.
Definition: UnifiedDescriptor.h:49
@ DT_FLOAT_SINGLE_LEVEL_MULTI_VIEW
A multi view, single level, float descriptor.
Definition: UnifiedDescriptor.h:90
@ DT_FLOAT_MULTI_LEVEL_MULTI_VIEW
A multi view, multi level, float descriptor.
Definition: UnifiedDescriptor.h:94
@ DT_BINARY_MULTI_LEVEL_MULTI_VIEW
A multi view, multi level, binary descriptor.
Definition: UnifiedDescriptor.h:85
@ DT_FLOAT_MULTI_LEVEL_SINGLE_VIEW
A single view, multi level, float descriptor.
Definition: UnifiedDescriptor.h:92
@ DT_FLOAT_SINGLE_LEVEL_SINGLE_VIEW
A single view, single level, float descriptor.
Definition: UnifiedDescriptor.h:88
@ DT_MULTI_LEVEL
A descriptor containing multiple levels (e.g., scale level).
Definition: UnifiedDescriptor.h:61
@ DT_BINARY_SINGLE_LEVEL
A single level binary descriptor.
Definition: UnifiedDescriptor.h:69
@ DT_FREAK_MULTI_LEVEL_MULTI_VIEW_256
A custom multi view, multi level, FREAK descriptor with 256 bits.
Definition: UnifiedDescriptor.h:104
@ DT_BINARY_SINGLE_LEVEL_MULTI_VIEW
A multi view, single level, binary descriptor.
Definition: UnifiedDescriptor.h:81
@ DT_FLOAT_MULTI_LEVEL
A multi level float descriptor.
Definition: UnifiedDescriptor.h:76
@ DT_BINARY_SINGLE_LEVEL_SINGLE_VIEW
A single view, single level, binary descriptor.
Definition: UnifiedDescriptor.h:79
@ DT_BINARY
A binary-based descriptor.
Definition: UnifiedDescriptor.h:54
@ DT_INVALID
An invalid descriptor.
Definition: UnifiedDescriptor.h:51
@ DT_FLOAT_SINGLE_LEVEL_SINGLE_VIEW_128
A single view, single level, float descriptor with 128 elements.
Definition: UnifiedDescriptor.h:97
@ DT_FLOAT_SINGLE_LEVEL
A single level float descriptor.
Definition: UnifiedDescriptor.h:74
@ DT_FLOAT
A float-based descriptor.
Definition: UnifiedDescriptor.h:56
@ DT_FLOAT_SINGLE_LEVEL_MULTI_VIEW_128
A multi view, single level, float descriptor with 128 elements.
Definition: UnifiedDescriptor.h:99
@ DT_SINGLE_LEVEL
A descriptor containing only one level.
Definition: UnifiedDescriptor.h:59
@ DT_BINARY_MULTI_LEVEL
A multi level binary descriptor.
Definition: UnifiedDescriptor.h:71
@ DT_BINARY_MULTI_LEVEL_SINGLE_VIEW
A single view, multi level, binary descriptor.
Definition: UnifiedDescriptor.h:83
@ DT_MULTI_VIEW
A descriptor based on multiple views (e.g., a descriptor of a 3D object point observed from several d...
Definition: UnifiedDescriptor.h:66
@ DT_SINGLE_VIEW
A descriptor based on a single view (e.g., a descriptor of a 2D image point in a single camera image)...
Definition: UnifiedDescriptor.h:64
@ DT_FREAK_MULTI_LEVEL_SINGLE_VIEW_256
A custom single view, multi level, FREAK descriptor with 256 bits.
Definition: UnifiedDescriptor.h:102
static constexpr bool isFloat(const DescriptorType descriptorType)
Returns whether a descriptor type represents a float-based descriptor.
Definition: UnifiedDescriptor.h:502
ByteDescriptor< tNumberBits/8u > BinaryDescriptor
Definition of a binary descriptor.
Definition: UnifiedDescriptor.h:126
std::array< uint8_t, tNumberBytes > ByteDescriptor
Definition of a byte descriptor.
Definition: UnifiedDescriptor.h:112
std::vector< Descriptor > Descriptors
Definition of a vector holding descriptors.
Definition: UnifiedDescriptor.h:620
static OCEAN_FORCE_INLINE unsigned int determineDistance(const Descriptor &descriptorA, const Descriptors &descriptorsB)
Determines the distance between a single-view descriptor and a multi-view descriptor.
ByteDescriptor< tNumberBytes > Descriptor
The data type of the descriptor.
Definition: UnifiedDescriptor.h:607
static OCEAN_FORCE_INLINE unsigned int determineDistance(const Descriptor &descriptorA, const Descriptor &descriptorB)
Determines the distance between two single-view descriptors.
static OCEAN_FORCE_INLINE float determineDistance(const Descriptor &descriptorA, const Descriptors &descriptorsB)
Determines the distance between a single-view descriptor and a multi-view descriptor.
FloatDescriptor< tNumberElements > Descriptor
The data type of the descriptor.
Definition: UnifiedDescriptor.h:675
static OCEAN_FORCE_INLINE float determineDistance(const Descriptor &descriptorA, const Descriptor &descriptorB)
Determines the distance between two single-view descriptors.
std::vector< Descriptor > Descriptors
Definition of a vector holding descriptors.
Definition: UnifiedDescriptor.h:687
UnifiedDescriptor::FreakMultiDescriptor256 Descriptor
The data type of the descriptor.
Definition: UnifiedDescriptor.h:761
std::vector< Descriptor > Descriptors
Definition of a vector holding descriptors.
Definition: UnifiedDescriptor.h:766
This class implements the base class for unified descriptor objects with specific descriptor type.
Definition: UnifiedDescriptor.h:595
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
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