vt::VocabularyTree< Feature, Distance, FeatureAllocator > Class Template Reference

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

#include <vocabulary_tree.h>

Inheritance diagram for vt::VocabularyTree< Feature, Distance, FeatureAllocator >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

void clear ()
 Clears vocabulary, leaving an empty tree.
uint32_t levels () const
 Get the depth (number of levels) of the tree.
void load (const std::string &file)
 Load vocabulary from a file.
Word quantize (const Feature &f) const
 Quantizes a feature into a discrete word.
void save (const std::string &file) const
 Save vocabulary to a file.
uint32_t splits () const
 Get the branching factor (max splits at each node) of the tree.
 VocabularyTree (const std::string &file, Distance d=Distance())
 Constructor, loads vocabulary from file.
 VocabularyTree (Distance d=Distance())
 Constructor, empty tree.
uint32_t words () const
 Get the number of words the tree contains.

Protected Types

typedef Distance::result_type distance_type

Protected Member Functions

bool initialized () const
void setNodeCounts ()

Protected Attributes

std::vector< Feature,
FeatureAllocator > 
centers_
Distance distance_
uint32_t k_
uint32_t levels_
uint32_t num_words_
std::vector< uint8_t > valid_centers_
uint32_t word_start_

Detailed Description

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
class vt::VocabularyTree< Feature, Distance, FeatureAllocator >

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.

FeatureAllocator is an STL-compatible allocator used to allocate Features internally.

Definition at line 32 of file vocabulary_tree.h.


Member Typedef Documentation

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
typedef Distance::result_type vt::VocabularyTree< Feature, Distance, FeatureAllocator >::distance_type [protected]

Definition at line 71 of file vocabulary_tree.h.


Constructor & Destructor Documentation

template<class Feature , class Distance, class FeatureAllocator >
vt::VocabularyTree< Feature, Distance, FeatureAllocator >::VocabularyTree ( Distance  d = Distance()  )  [inline]

Constructor, empty tree.

Parameters:
d Functor for computing the distance between two features
Todo:
Allocator parameter, also in MutableVocabularyTree, TreeBuilder...

Definition at line 89 of file vocabulary_tree.h.

template<class Feature , class Distance, class FeatureAllocator >
vt::VocabularyTree< Feature, Distance, FeatureAllocator >::VocabularyTree ( const std::string &  file,
Distance  d = Distance() 
) [inline]

Constructor, loads vocabulary from file.

Parameters:
file Saved vocabulary file
d Functor for computing the distance between two features

Definition at line 95 of file vocabulary_tree.h.


Member Function Documentation

template<class Feature , class Distance , class FeatureAllocator >
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::clear (  )  [inline]

Clears vocabulary, leaving an empty tree.

Definition at line 147 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
bool vt::VocabularyTree< Feature, Distance, FeatureAllocator >::initialized (  )  const [inline, protected]

Definition at line 82 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::levels (  )  const [inline]

Get the depth (number of levels) of the tree.

Definition at line 129 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::load ( const std::string &  file  )  [inline]

Load vocabulary from a file.

Reimplemented in vt::GenericTree.

Definition at line 171 of file vocabulary_tree.h.

template<class Feature, class Distance , class FeatureAllocator >
Word vt::VocabularyTree< Feature, Distance, FeatureAllocator >::quantize ( const Feature f  )  const [inline]

Quantizes a feature into a discrete word.

Definition at line 102 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::save ( const std::string &  file  )  const [inline]

Save vocabulary to a file.

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

Reimplemented in vt::GenericTree.

Definition at line 155 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::setNodeCounts (  )  [inline, protected]

Definition at line 198 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::splits (  )  const [inline]

Get the branching factor (max splits at each node) of the tree.

Definition at line 135 of file vocabulary_tree.h.

template<class Feature , class Distance , class FeatureAllocator >
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::words (  )  const [inline]

Get the number of words the tree contains.

Definition at line 141 of file vocabulary_tree.h.


Member Data Documentation

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
std::vector<Feature, FeatureAllocator> vt::VocabularyTree< Feature, Distance, FeatureAllocator >::centers_ [protected]

Definition at line 73 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
Distance vt::VocabularyTree< Feature, Distance, FeatureAllocator >::distance_ [protected]
Todo:
Consider bit-vector

Definition at line 75 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::k_ [protected]

Definition at line 77 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::levels_ [protected]

Definition at line 78 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::num_words_ [protected]

Definition at line 79 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
std::vector<uint8_t> vt::VocabularyTree< Feature, Distance, FeatureAllocator >::valid_centers_ [protected]

Definition at line 74 of file vocabulary_tree.h.

template<class Feature, class Distance = distance::L2<Feature>, class FeatureAllocator = typename DefaultAllocator<Feature>::type>
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::word_start_ [protected]

Definition at line 80 of file vocabulary_tree.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs


vocabulary_tree
Author(s): Patrick Mihelich
autogenerated on Fri Jan 11 09:14:12 2013