8 #ifndef META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_FEATURE_MAP_H
9 #define META_OCEAN_TRACKING_MAPBUILDING_UNIFIED_FEATURE_MAP_H
31 class UnifiedFeatureMap;
58 inline const Vectors3& objectPoints()
const;
65 inline const Indices32& objectPointIds()
const;
79 inline const Indices32& objectPointIndices()
const;
125 inline bool isValid()
const;
167 template <typename TImagePointDescriptor, typename TObjectPointDescriptor, typename TObjectPointVocabularyDescriptor, typename TDescriptorDistance = typename UnifiedDescriptor::DistanceTyper<TObjectPointVocabularyDescriptor>::Type, TDescriptorDistance(*tVocabularyDistanceFunction)(
const TObjectPointVocabularyDescriptor&,
const TObjectPointVocabularyDescriptor&) =
UnifiedDescriptorT<TObjectPointVocabularyDescriptor>::determineDistance>
210 const TObjectPointVocabularyDescriptor* objectPointVocabularyDescriptors()
const;
282 template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDescriptorDistance, TDescriptorDistance(*tVocabularyDistanceFunction)(const TObjectPo
intVocabularyDescriptor&, const TObjectPo
intVocabularyDescriptor&)>
284 clustersMeanFunction_(std::move(clustersMeanFunction)),
285 extractVocabularyDescriptorsFromMapFunction_(std::move(extractVocabularyDescriptorsFromMapFunction))
291 ocean_assert_and_suppress_unused(result, result);
294 template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDescriptorDistance, TDescriptorDistance(*tVocabularyDistanceFunction)(const TObjectPo
intVocabularyDescriptor&, const TObjectPo
intVocabularyDescriptor&)>
297 if (!objectPointVocabularyDescriptors_)
304 ocean_assert(
false &&
"This should never happen!");
310 if (vocabularyDescriptors ==
nullptr)
312 ocean_assert(
false &&
"This should never happen!");
319 template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDescriptorDistance, TDescriptorDistance(*tVocabularyDistanceFunction)(const TObjectPo
intVocabularyDescriptor&, const TObjectPo
intVocabularyDescriptor&)>
322 return objectPointDescriptorsForest_;
325 template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDescriptorDistance, TDescriptorDistance(*tVocabularyDistanceFunction)(const TObjectPo
intVocabularyDescriptor&, const TObjectPo
intVocabularyDescriptor&)>
328 if (!extractVocabularyDescriptorsFromMapFunction_)
333 if (objectPoints.empty() || objectPointIds.empty() || !descriptorMap)
338 if (objectPoints.size() != objectPointIds.size())
345 objectPointVocabularyDescriptors_ =
nullptr;
346 objectPointIndices_.clear();
347 descriptorMap_ =
nullptr;
349 objectPoints_ = std::move(objectPoints);
350 objectPointIds_ = std::move(objectPointIds);
351 descriptorMap_ = std::move(descriptorMap);
353 ocean_assert(descriptorMap_);
357 if (!extractVocabularyDescriptorsFromMapFunction_(*descriptorMap_, objectPoints_, objectPointIds_, objectPointIndices_, objectPointVocabularyDescriptors))
364 objectPointVocabularyDescriptors_ = std::make_shared<UnifiedDescriptorsVocabulary>(std::move(objectPointVocabularyDescriptors));
366 const UnifiedDescriptorsVocabulary& unifiedDescriptorsVocabulary =
dynamic_cast<const UnifiedDescriptorsVocabulary&
>(*objectPointVocabularyDescriptors_);
370 objectPointDescriptorsForest_ =
VocabularyForest(2, unifiedDescriptorsVocabulary.descriptors(), unifiedDescriptorsVocabulary.numberDescriptors(), clustersMeanFunction_, parameters,
WorkerPool::get().
scopedWorker()(), &randomGenerator);
372 objectPointOctree_ =
Geometry::Octree(objectPoints_.data(), objectPoints_.size(), Geometry::Octree::Parameters(40u,
true));
377 template <
typename TImagePo
intDescriptor,
typename TObjectPo
intDescriptor,
typename TObjectPo
intVocabularyDescriptor,
typename TDescriptorDistance, TDescriptorDistance(*tVocabularyDistanceFunction)(const TObjectPo
intVocabularyDescriptor&, const TObjectPo
intVocabularyDescriptor&)>
380 ocean_assert((imagePoints !=
nullptr && imagePointDescriptors !=
nullptr) || (imagePoints ==
nullptr && imagePointDescriptors ==
nullptr));
384 if (specializedDescriptorMap ==
nullptr)
386 ocean_assert(
false &&
"This should never happen!");
393 if (imagePoints !=
nullptr)
397 if (specializedImagePointDescriptors ==
nullptr)
402 unifiedUnguidedMatching = std::make_shared<UnifiedUnguidedMatching>(imagePoints, specializedImagePointDescriptors->
descriptors(), specializedImagePointDescriptors->
numberDescriptors(), objectPoints_.data(), objectPointVocabularyDescriptors(), objectPoints_.size(), objectPointIndices_.data(), objectPointDescriptorsForest());
403 unifiedGuidedMatching = std::make_shared<UnifiedGuidedMatching>(imagePoints, specializedImagePointDescriptors->
descriptors(), specializedImagePointDescriptors->
numberDescriptors(), objectPoints_.data(), objectPoints_.size(), objectPointOctree_, objectPointIds_.data(), specializedDescriptorMap->
descriptorMap());
407 unifiedUnguidedMatching = std::make_shared<UnifiedUnguidedMatching>(objectPoints_.data(), objectPointVocabularyDescriptors(), objectPoints_.size(), objectPointIndices_.data(), objectPointDescriptorsForest());
408 unifiedGuidedMatching = std::make_shared<UnifiedGuidedMatching>(objectPoints_.data(), objectPoints_.size(), objectPointOctree_, objectPointIds_.data(), specializedDescriptorMap->
descriptorMap());
411 return unifiedUnguidedMatching && unifiedGuidedMatching;
This class implements a recursive lock object.
Definition: Lock.h:31
This class implements a generator for random numbers.
Definition: RandomGenerator.h:42
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
static WorkerPool & get()
Returns a reference to the unique object.
Definition: Singleton.h:115
This class implements a helper class allowing to determine the descriptor type value for a descriptor...
Definition: UnifiedDescriptor.h:177
This class implements the base class for all unified descriptor maps in which ids are mapped to descr...
Definition: UnifiedDescriptorMap.h:38
This class implements the descriptor map for arbitrary descriptors.
Definition: UnifiedDescriptorMap.h:94
const DescriptorMap & descriptorMap() const
Returns the actual underlying descriptor map.
Definition: UnifiedDescriptorMap.h:204
This class implements the base class for unified descriptor objects with specific descriptor type.
Definition: UnifiedDescriptor.h:595
This class implements the base class for all unified descriptor buffers stored in a continuous memory...
Definition: UnifiedDescriptors.h:29
This class implements a type-based container for descriptors stored in a continuous memory like a vec...
Definition: UnifiedDescriptors.h:71
const TDescriptor * descriptors() const
Returns the pointer to the memory holding all descriptors of this object.
Definition: UnifiedDescriptors.h:149
size_t numberDescriptors() const override
Returns the number of descriptors this object holds.
Definition: UnifiedDescriptors.h:155
This class implements the base class for a feature map necessary to re-localize with optimized data s...
Definition: UnifiedFeatureMap.h:45
SharedUnifiedDescriptorMap descriptorMap_
The map mapping object point ids to their associated descriptors.
Definition: UnifiedFeatureMap.h:152
Indices32 objectPointIndices_
The indices of the corresponding 3D object points, one for each object point descriptor,...
Definition: UnifiedFeatureMap.h:146
Vectors3 objectPoints_
The 3D object points of the map.
Definition: UnifiedFeatureMap.h:137
Geometry::Octree objectPointOctree_
The octree holding the object points of the map.
Definition: UnifiedFeatureMap.h:149
const UnifiedDescriptors & objectPointVocabularyDescriptors() const
Returns the descriptors of the 3D object points adjusted/optimized for the vocabulary structure.
Definition: UnifiedFeatureMap.h:253
virtual ~UnifiedFeatureMap()=default
Disposes the object.
const Geometry::Octree & objectPointOctree() const
Returns the octree holding the object points of the map.
Definition: UnifiedFeatureMap.h:264
Lock lock_
The feature map's lock.
Definition: UnifiedFeatureMap.h:155
SharedUnifiedDescriptors objectPointVocabularyDescriptors_
The descriptors of the 3D object points adjusted for the vocabulary structure.
Definition: UnifiedFeatureMap.h:143
Indices32 objectPointIds_
The ids object point ids, one for each 3D object point.
Definition: UnifiedFeatureMap.h:140
UnifiedFeatureMap()=default
Default constructor creating an invalid feature map.
const Tracking::MapBuilding::UnifiedDescriptorMap & descriptorMap() const
Returns the map mapping object point ids to their associated descriptors.
Definition: UnifiedFeatureMap.h:269
bool isValid() const
Returns whether this feature map holds at least one feature.
Definition: UnifiedFeatureMap.h:275
const Indices32 & objectPointIndices() const
Returns the indices of the corresponding 3D object points, one for each object point descriptor,...
Definition: UnifiedFeatureMap.h:259
virtual const Tracking::VocabularyStructure & objectPointDescriptorsForest() const =0
Returns the vocabulary forest holding the descriptors of the object points of the map.
const Vectors3 & objectPoints() const
Returns the 3D object points of the map.
Definition: UnifiedFeatureMap.h:243
virtual bool createMatchingObjects(const Vector2 *imagePoints, const UnifiedDescriptors *imagePointDescriptors, SharedUnifiedUnguidedMatching &unifiedUnguidedMatching, SharedUnifiedGuidedMatching &unifiedGuidedMatching)=0
Creates the unguided matching and the guided matching object and initializes the objects with the nec...
virtual bool updateFeatureMap(Vectors3 &&objectPoints, Indices32 &&objectPointIds, SharedUnifiedDescriptorMap &&descriptorMap, RandomGenerator &randomGenerator)=0
Sets or updates the feature map to be used for relocalization.
const Indices32 & objectPointIds() const
Returns the ids object point ids, one for each 3D object point.
Definition: UnifiedFeatureMap.h:248
This class implements a specialized feature map with specific descriptor types.
Definition: UnifiedFeatureMap.h:169
std::function< bool(const UnifiedDescriptorMap &descriptorMap, Vectors3 &objectPoints, Indices32 &objectPointIds, Indices32 &objectPointIndices, TObjectPointVocabularyDescriptors &vocabularyDescriptors)> ExtractVocabularyDescriptorsFromMapFunction
Definition of a function allowing to serialize the features from a descriptor map so that the feature...
Definition: UnifiedFeatureMap.h:191
bool createMatchingObjects(const Vector2 *imagePoints, const UnifiedDescriptors *imagePointDescriptors, SharedUnifiedUnguidedMatching &unifiedUnguidedMatching, SharedUnifiedGuidedMatching &unifiedGuidedMatching) override
Creates the unguided matching and the guided matching object and initializes the objects with the nec...
Definition: UnifiedFeatureMap.h:378
ExtractVocabularyDescriptorsFromMapFunction extractVocabularyDescriptorsFromMapFunction_
The function allowing to extract the 3D object point descriptors from the feature map and creating se...
Definition: UnifiedFeatureMap.h:237
const TObjectPointVocabularyDescriptor * objectPointVocabularyDescriptors() const
Returns the descriptors of the object points used in the vocabulary tree.
Definition: UnifiedFeatureMap.h:295
std::vector< TObjectPointVocabularyDescriptor > TObjectPointVocabularyDescriptors
Definition of a vector holding vocabulary descriptors.
Definition: UnifiedFeatureMap.h:180
VocabularyForest::ClustersMeanFunction clustersMeanFunction_
The function allowing to determine the mean descriptors for individual clusters.
Definition: UnifiedFeatureMap.h:234
bool updateFeatureMap(Vectors3 &&objectPoints, Indices32 &&objectPointIds, SharedUnifiedDescriptorMap &&descriptorMap, RandomGenerator &randomGenerator) override
Sets or updates the feature map to be used for relocalization.
Definition: UnifiedFeatureMap.h:326
VocabularyForest objectPointDescriptorsForest_
The vocabulary forest holding the descriptors of the object points of the map.
Definition: UnifiedFeatureMap.h:240
UnifiedFeatureMapT(Vectors3 &&objectPoints, Indices32 &&objectPointIds, SharedUnifiedDescriptorMap &&descriptorMap, RandomGenerator &randomGenerator, typename VocabularyForest::ClustersMeanFunction clustersMeanFunction, ExtractVocabularyDescriptorsFromMapFunction extractVocabularyDescriptorsFromMapFunction)
Creates a new unified feature map object.
Definition: UnifiedFeatureMap.h:283
const VocabularyForest & objectPointDescriptorsForest() const override
Returns the vocabulary forest holding the descriptors of the object points of the map.
Definition: UnifiedFeatureMap.h:320
This class implements the base class for all guided matching objects.
Definition: UnifiedMatching.h:166
This class implements the guided matching object for specific features.
Definition: UnifiedMatching.h:285
This class implements the base class for all unguided matching objects.
Definition: UnifiedMatching.h:227
This class implements the unguided matching object for FREAK Multi features with 32 bytes or 256 bits...
Definition: UnifiedMatching.h:382
This class implements a Vocabulary Forest holding several Vocabulary Trees.
Definition: VocabularyTree.h:766
TDescriptors(*)(const unsigned int numberClusters, const TDescriptor *treeDescriptors, const Index32 *descriptorIndices, const Index32 *clusterIndicesForDescriptors, const size_t numberDescriptorIndices, Worker *worker) ClustersMeanFunction
Definition of a function pointer allowing to determine the mean descriptors for individual clusters.
Definition: VocabularyTree.h:813
This class stores construction parameters for a VocabularyStructure.
Definition: VocabularyTree.h:150
This class implements the base class for all Vocabulary objects.
Definition: VocabularyTree.h:42
ScopedWorker scopedWorker()
Returns a scoped object holding the real worker if available.
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:25
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< UnifiedDescriptorMap > SharedUnifiedDescriptorMap
Definition of a shared pointer holding a UnifiedDescriptorMap object.
Definition: UnifiedDescriptorMap.h:30
std::shared_ptr< UnifiedFeatureMap > SharedUnifiedFeatureMap
Definition of a shared pointer holding a UnifiedFeatureMap object.
Definition: UnifiedFeatureMap.h:31
std::shared_ptr< UnifiedUnguidedMatching > SharedUnifiedUnguidedMatching
Definition of a shared pointer holding an UnifiedUnguidedMatching object.
Definition: UnifiedMatching.h:274
std::shared_ptr< UnifiedDescriptors > SharedUnifiedDescriptors
Definition of a shared pointer holding a UnifiedDescriptors object.
Definition: UnifiedDescriptors.h:63
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15