vocabtree  0.0.1
vocab_tree_simple.cxx File Reference
#include "tests_config.hpp"
#include <search/vocab_tree/vocab_tree.hpp>
#include <iostream>
#include <utils/filesystem.hpp>
#include <utils/numerics.hpp>
#include <utils/dataset.hpp>
#include <utils/vision.hpp>
#include <utils/logger.hpp>
#include <vis/matches_page.hpp>
Include dependency graph for vocab_tree_simple.cxx:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 12 of file vocab_tree_simple.cxx.

References MatchesPage::add_match(), SimpleDataset::image(), Dataset::location(), Dataset::random_images(), s_oxfordmini_data_dir, s_oxfordmini_database_location, VocabTree::search(), VocabTree::split, VocabTree::train(), and MatchesPage::write().

12  {
13 
15  //LINFO << simple_dataset;
16 
17  //std::stringstream vocab_output_file;
18  //vocab_output_file << simple_dataset.location() << "/vocab/" << train_params->split << "-"
19  //<< train_params->depth << ".vocab";
20 
21  //std::shared_ptr<VocabTree> bow = std::make_shared<VocabTree>(vocab_output_file.str());
22 
23  VocabTree vt;
24  std::shared_ptr<VocabTree::TrainParams> train_params = std::make_shared<VocabTree::TrainParams>();
25  train_params->depth = 4;
26  train_params->split = 4;
27  vt.train(simple_dataset, train_params, simple_dataset.random_images(128));
28 
29  /*
30  std::stringstream index_output_file;
31  index_output_file << simple_dataset.location() << "/vocab/" << train_params->split << "-"
32  << train_params->depth << ".vtree";
33  filesystem::create_file_directory(index_output_file.str());
34  vt.save(index_output_file.str());
35  */
36 
37  MatchesPage html_output;
38  for (uint32_t i = 0; i<256; i++) {
39  std::shared_ptr<VocabTree::MatchResults> matches =
40  std::static_pointer_cast<VocabTree::MatchResults>(vt.search(simple_dataset, nullptr, simple_dataset.image(i)));
41  //LINFO << "Query " << i << ": " << *matches;
42  printf("Matches for image %d: ", i);
43  for (uint64_t id : matches->matches)
44  printf("%d ", id);
45  printf("\n");
46 
47  html_output.add_match(i, matches->matches, simple_dataset);
48  }
49 
50 
51  html_output.write(simple_dataset.location() + "/results/matches/");
52  return 0;
53 }