|
vocabtree
0.0.1
|
Implements a Bag of Words based (BoW) image search. More...
#include <bag_of_words.hpp>


Data Structures | |
| struct | MatchResults |
| Subclass of match results base which also returns scores. More... | |
| struct | SearchParams |
| Subclass of train params base which specifies inverted index training parameters. More... | |
| struct | TrainParams |
| Subclass of train params base which specifies inverted index training parameters. More... | |
Public Member Functions | |
| BagOfWords () | |
| BagOfWords (const std::string &file_path) | |
| bool | train (Dataset &dataset, const std::shared_ptr< const TrainParamsBase > ¶ms, const std::vector< std::shared_ptr< const Image > > &examples) |
| Given a set of training parameters, list of images, trains. More... | |
| bool | load (const std::string &file_path) |
| Loads a trained search structure from the input filepath. More... | |
| bool | save (const std::string &file_path) const |
| Saves a trained search structure to the input filepath. More... | |
| std::shared_ptr< MatchResultsBase > | search (Dataset &dataset, const std::shared_ptr< const SearchParamsBase > ¶ms, const std::shared_ptr< const Image > &example) |
| Given a set of search parameters, a query image, searches for matching images and returns the match. More... | |
| cv::Mat | vocabulary () const |
| Returns the vocabulary matrix. More... | |
| uint32_t | num_clusters () const |
| Returns the number of clusters in the vocabulary. More... | |
Public Member Functions inherited from SearchBase | |
| SearchBase () | |
| SearchBase (const std::string &file_path) | |
| virtual | ~SearchBase () |
| std::vector< std::shared_ptr < MatchResultsBase > > | search (Dataset &dataset, const std::shared_ptr< SearchParamsBase > ¶ms, const std::vector< std::shared_ptr< const Image > > &examples) |
| Given a set of search parameters, list of query images, searches for matching images and returns the result matches. More... | |
Protected Attributes | |
| cv::Mat | vocabulary_matrix |
Implements a Bag of Words based (BoW) image search.
Note that search here is not implemented and would throw an error should you try to call it. A naive implementation would have to compute tf-idf with all possible image. Instead, you should train a BoW model and use this model in conjuction with a InvertedIndex search model to perform a query.
Definition at line 9 of file bag_of_words.hpp.
| BagOfWords::BagOfWords | ( | ) |
Definition at line 18 of file bag_of_words.cxx.
| BagOfWords::BagOfWords | ( | const std::string & | file_path | ) |
|
virtual |
Loads a trained search structure from the input filepath.
Implements SearchBase.
Definition at line 33 of file bag_of_words.cxx.
References filesystem::load_cvmat(), and vocabulary_matrix.
Referenced by BagOfWords(), and compute_bow().
| uint32_t BagOfWords::num_clusters | ( | ) | const |
Returns the number of clusters in the vocabulary.
Definition at line 156 of file bag_of_words.cxx.
References vocabulary_matrix.
|
virtual |
Saves a trained search structure to the input filepath.
Implements SearchBase.
Definition at line 47 of file bag_of_words.cxx.
References filesystem::create_file_directory(), vocabulary_matrix, and filesystem::write_cvmat().
Referenced by compute_bow(), main(), and train_bow().
|
virtual |
Given a set of search parameters, a query image, searches for matching images and returns the match.
Search is not valid for bag of words - this would require computing tf-idf on all possible images in the dataset, and this function will assert(0) should you try to run it. Instead, you should train a Bag of Words (BoW) model and use it with one of the other search mechanisms, such as the inverted index.
Implements SearchBase.
Definition at line 147 of file bag_of_words.cxx.
|
virtual |
Given a set of training parameters, list of images, trains.
Returns true if successful, false if not successful.
Implements SearchBase.
Definition at line 77 of file bag_of_words.cxx.
References filesystem::file_exists(), Dataset::image(), filesystem::load_cvmat(), Dataset::location(), vision::merge_descriptors(), BagOfWords::TrainParams::numClusters, and vocabulary_matrix.
Referenced by compute_bow(), main(), and train_bow().
| cv::Mat BagOfWords::vocabulary | ( | ) | const |
Returns the vocabulary matrix.
Definition at line 152 of file bag_of_words.cxx.
References vocabulary_matrix.
Referenced by compute_bow(), and main().
|
protected |
Definition at line 56 of file bag_of_words.hpp.
Referenced by load(), num_clusters(), save(), train(), and vocabulary().