vocabtree  0.0.1
vocab_tree_simple.cxx
Go to the documentation of this file.
1 #include "tests_config.hpp"
3 #include <iostream>
4 
5 #include <utils/filesystem.hpp>
6 #include <utils/numerics.hpp>
7 #include <utils/dataset.hpp>
8 #include <utils/vision.hpp>
9 #include <utils/logger.hpp>
10 #include <vis/matches_page.hpp>
11 
12 int main(int argc, char *argv[]) {
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 }