Optimized vocabulary tree quantizer, templated on feature type and distance metric for maximum efficiency. More...
#include <vocabulary_tree.h>
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 (Distance d=Distance()) | |
Constructor, empty tree. | |
VocabularyTree (const std::string &file, Distance d=Distance()) | |
Constructor, loads vocabulary from file. | |
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_ |
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.
typedef Distance::result_type vt::VocabularyTree< Feature, Distance, FeatureAllocator >::distance_type [protected] |
Definition at line 71 of file vocabulary_tree.h.
vt::VocabularyTree< Feature, Distance, FeatureAllocator >::VocabularyTree | ( | Distance | d = Distance() | ) |
Constructor, empty tree.
d | Functor for computing the distance between two features |
Definition at line 89 of file vocabulary_tree.h.
vt::VocabularyTree< Feature, Distance, FeatureAllocator >::VocabularyTree | ( | const std::string & | file, |
Distance | d = Distance() |
||
) |
Constructor, loads vocabulary from file.
file | Saved vocabulary file |
d | Functor for computing the distance between two features |
Definition at line 95 of file vocabulary_tree.h.
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::clear | ( | ) |
Clears vocabulary, leaving an empty tree.
Definition at line 147 of file vocabulary_tree.h.
bool vt::VocabularyTree< Feature, Distance, FeatureAllocator >::initialized | ( | ) | const [inline, protected] |
Definition at line 82 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::levels | ( | ) | const |
Get the depth (number of levels) of the tree.
Definition at line 129 of file vocabulary_tree.h.
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::load | ( | const std::string & | file | ) |
Load vocabulary from a file.
Reimplemented in vt::GenericTree.
Definition at line 171 of file vocabulary_tree.h.
Word vt::VocabularyTree< Feature, Distance, FeatureAllocator >::quantize | ( | const Feature & | f | ) | const |
Quantizes a feature into a discrete word.
Definition at line 102 of file vocabulary_tree.h.
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::save | ( | const std::string & | file | ) | const |
Save vocabulary to a file.
Reimplemented in vt::GenericTree.
Definition at line 155 of file vocabulary_tree.h.
void vt::VocabularyTree< Feature, Distance, FeatureAllocator >::setNodeCounts | ( | ) | [protected] |
Definition at line 198 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::splits | ( | ) | const |
Get the branching factor (max splits at each node) of the tree.
Definition at line 135 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::words | ( | ) | const |
Get the number of words the tree contains.
Definition at line 141 of file vocabulary_tree.h.
std::vector<Feature, FeatureAllocator> vt::VocabularyTree< Feature, Distance, FeatureAllocator >::centers_ [protected] |
Definition at line 73 of file vocabulary_tree.h.
Distance vt::VocabularyTree< Feature, Distance, FeatureAllocator >::distance_ [protected] |
Definition at line 75 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::k_ [protected] |
Definition at line 77 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::levels_ [protected] |
Definition at line 78 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::num_words_ [protected] |
Definition at line 79 of file vocabulary_tree.h.
std::vector<uint8_t> vt::VocabularyTree< Feature, Distance, FeatureAllocator >::valid_centers_ [protected] |
Definition at line 74 of file vocabulary_tree.h.
uint32_t vt::VocabularyTree< Feature, Distance, FeatureAllocator >::word_start_ [protected] |
Definition at line 80 of file vocabulary_tree.h.