AliceVision
Photogrammetric Computer Vision Framework
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
aliceVision::voctree::VocabularyTree< Feature, Distance > Class Template Reference

Optimized vocabulary tree quantizer, templated on feature type and distance metric for maximum efficiency. More...

#include <VocabularyTree.hpp>

Inheritance diagram for aliceVision::voctree::VocabularyTree< Feature, Distance >:
aliceVision::voctree::IVocabularyTree

Public Member Functions

 VocabularyTree (const std::string &file)
 Create from vocabulary file. More...
 
template<class DescriptorT >
Word quantize (const DescriptorT &feature) const
 Quantizes a feature into a discrete word.
 
template<class DescriptorT >
std::vector< Word > quantize (const std::vector< DescriptorT > &features) const
 Quantizes a set of features into visual words.
 
template<class DescriptorT >
SparseHistogram quantizeToSparse (const std::vector< DescriptorT > &features) const
 Quantizes a set of features into sparse histogram of visual words.
 
SparseHistogram quantizeToSparse (const void *blindDescriptors) const override
 Create a SparseHistogram from a blind vector of descriptors. More...
 
uint32_t levels () const override
 Get the depth (number of levels) of the tree.
 
uint32_t splits () const override
 Get the branching factor (max splits at each node) of the tree.
 
uint32_t words () const override
 Get the number of words the tree contains.
 
void clear () override
 Clears vocabulary, leaving an empty tree.
 
void save (const std::string &file) const override
 Save vocabulary to a file. More...
 
void load (const std::string &file) override
 Load vocabulary from a file.
 
bool operator== (const VocabularyTree &other) const
 

Protected Member Functions

bool initialized () const
 
void setNodeCounts ()
 

Protected Attributes

std::vector< Feature > centers_
 
std::vector< uint8_t > valid_centers_
 
uint32_t k_
 
uint32_t levels_
 
uint32_t num_words_
 
uint32_t word_start_
 

Detailed Description

template<class Feature, template< typename, typename > class Distance = L2>
class aliceVision::voctree::VocabularyTree< Feature, Distance >

Optimized vocabulary tree quantizer, templated on feature type and distance metric for maximum efficiency.

Feature is the data type of one feature. It has no requirements except compatibility with the distance metric.

Distance is a functor that computes the distance between two Feature objects. It must have a result_type typedef specifying the type of the returned distance. For the purposes of VocabularyTree, this need not even be a metric; distances simply need to be comparable.

Constructor & Destructor Documentation

◆ VocabularyTree()

template<class Feature , template< typename, typename > class Distance>
aliceVision::voctree::VocabularyTree< Feature, Distance >::VocabularyTree ( const std::string &  file)

Create from vocabulary file.

Parameters
filevocabulary file path

Member Function Documentation

◆ quantizeToSparse()

template<class Feature , template< typename, typename > class Distance = L2>
SparseHistogram aliceVision::voctree::VocabularyTree< Feature, Distance >::quantizeToSparse ( const void *  blindDescriptors) const
inlineoverridevirtual

Create a SparseHistogram from a blind vector of descriptors.

Parameters
blindDescriptors
Returns

Implements aliceVision::voctree::IVocabularyTree.

◆ save()

template<class Feature , template< typename, typename > class Distance>
void aliceVision::voctree::VocabularyTree< Feature, Distance >::save ( const std::string &  file) const
overridevirtual

Save vocabulary to a file.

Todo:
Support serializing of non-"simple" feature classes
Todo:
Some identifying name for the distance used

Implements aliceVision::voctree::IVocabularyTree.

Member Data Documentation

◆ k_

template<class Feature , template< typename, typename > class Distance = L2>
uint32_t aliceVision::voctree::VocabularyTree< Feature, Distance >::k_
protected
Todo:
Consider bit-vector

The documentation for this class was generated from the following file: