Class for efficiently matching a bag-of-words representation of a document (image) against a database of known documents.
More...
#include <Database.hpp>
|
| | Database (uint32_t num_words=0) |
| | Constructor. More...
|
| |
| DocId | insert (DocId doc_id, const SparseHistogram &document) |
| | Insert a new document. More...
|
| |
| void | sanityCheck (std::size_t N, std::map< std::size_t, DocMatches > &matches) const |
| | Perform a sanity check of the database by querying each document of the database and finding its top N matches. More...
|
| |
| void | find (const std::vector< Word > &document, std::size_t N, std::vector< DocMatch > &matches, const std::string &distanceMethod="strongCommonPoints") const |
| | Find the top N matches in the database for the query document. More...
|
| |
| void | find (const SparseHistogram &query, std::size_t N, std::vector< DocMatch > &matches, const std::string &distanceMethod="strongCommonPoints") const |
| | Find the top N matches in the database for the query document. More...
|
| |
| void | computeTfIdfWeights (float default_weight=1.0f) |
| | Compute the TF-IDF weights of all the words. To be called after inserting a corpus of training examples into the database. More...
|
| |
| std::size_t | size () const |
| | Return the size of the database in terms of number of documents. More...
|
| |
|
void | saveWeights (const std::string &file) const |
| | Save the vocabulary word weights to a file.
|
| |
|
void | loadWeights (const std::string &file) |
| | Load the vocabulary word weights from a file.
|
| |
|
const SparseHistogramPerImage & | getSparseHistogramPerImage () const |
| |
|
| std::ostream & | operator<< (std::ostream &os, const SparseHistogram &dv) |
| |
Class for efficiently matching a bag-of-words representation of a document (image) against a database of known documents.
◆ Database()
| aliceVision::voctree::Database::Database |
( |
uint32_t |
num_words = 0 | ) |
|
|
explicit |
Constructor.
If computing weights for a new vocabulary, num_words should be the size of the vocabulary. If calling loadWeights(), it can be left zero.
◆ computeTfIdfWeights()
| void aliceVision::voctree::Database::computeTfIdfWeights |
( |
float |
default_weight = 1.0f | ) |
|
Compute the TF-IDF weights of all the words. To be called after inserting a corpus of training examples into the database.
- Parameters
-
| default_weight | The default weight of a word that appears in none of the training documents. |
◆ find() [1/2]
| void aliceVision::voctree::Database::find |
( |
const SparseHistogram & |
query, |
|
|
std::size_t |
N, |
|
|
std::vector< DocMatch > & |
matches, |
|
|
const std::string & |
distanceMethod = "strongCommonPoints" |
|
) |
| const |
Find the top N matches in the database for the query document.
- Parameters
-
| [in] | query | The query document, a normalized set of quantized words. |
| [int] | N The number of matches to return. |
| [in] | distanceMethod | distance method (norm L1, etc.) |
| [out] | matches | IDs and scores for the top N matching database documents. |
| query | The query document, a normalized set of quantized words. |
| N | The number of matches to return. |
| [out] | matches | IDs and scores for the top N matching database documents. |
| [in] | distanceMethod | the method used to compute distance between histograms. |
◆ find() [2/2]
| void aliceVision::voctree::Database::find |
( |
const std::vector< Word > & |
document, |
|
|
std::size_t |
N, |
|
|
std::vector< DocMatch > & |
matches, |
|
|
const std::string & |
distanceMethod = "strongCommonPoints" |
|
) |
| const |
Find the top N matches in the database for the query document.
- Parameters
-
| [in] | document | The query document, a set of quantized words. |
| [in] | N | The number of matches to return. |
| [in] | distanceMethod | distance method (norm L1, etc.) |
| [out] | matches | IDs and scores for the top N matching database documents. |
| [in] | document | The query document, a set of quantized words. |
| [in] | N | The number of matches to return. |
| [out] | matches | IDs and scores for the top N matching database documents. |
| [in] | distanceMethod | the method used to compute distance between histograms. |
◆ insert()
| DocId aliceVision::voctree::Database::insert |
( |
DocId |
doc_id, |
|
|
const SparseHistogram & |
document |
|
) |
| |
Insert a new document.
- Parameters
-
| doc_id | Unique ID of the new document to insert |
| document | The set of quantized words in a document/image. |
- Returns
- An ID representing the inserted document.
◆ sanityCheck()
| void aliceVision::voctree::Database::sanityCheck |
( |
std::size_t |
N, |
|
|
std::map< std::size_t, DocMatches > & |
matches |
|
) |
| const |
Perform a sanity check of the database by querying each document of the database and finding its top N matches.
- Parameters
-
| [in] | N | The number of matches to return. |
| [out] | matches | IDs and scores for the top N matching database documents. |
◆ size()
| std::size_t aliceVision::voctree::Database::size |
( |
| ) |
const |
Return the size of the database in terms of number of documents.
**
- Returns
- the number of documents
Return the size of the database in terms of number of documents
- Returns
- the number of documents
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const SparseHistogram & |
dv |
|
) |
| |
|
friend |
The documentation for this class was generated from the following files:
- /home/docs/checkouts/readthedocs.org/user_builds/alicevision/checkouts/latest/src/aliceVision/voctree/Database.hpp
- /home/docs/checkouts/readthedocs.org/user_builds/alicevision/checkouts/latest/src/aliceVision/voctree/Database.cpp