ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vocab_tree.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include "exe/vocab_tree.h"
9 
10 #include "pipelines/option_utils.h"
11 #include "pipelines/vocab_tree.h"
12 
13 namespace cloudViewer {
14 
15 int BuildVocabTree(const std::string& database_path,
16  const std::string& vocab_tree_path,
17  int num_visual_words /*= 256 * 256*/,
18  int num_checks /*= 256*/,
19  int branching /*= 256*/,
20  int num_iterations /*= 11*/,
21  int max_num_images /*= -1*/) {
22  OptionsParser parser;
23  parser.registerOption("database_path", &database_path);
24  parser.registerOption("vocab_tree_path", &vocab_tree_path);
25  parser.registerOption("num_visual_words", &num_visual_words);
26  parser.registerOption("num_checks", &num_checks);
27  parser.registerOption("branching", &branching);
28  parser.registerOption("num_iterations", &num_iterations);
29  parser.registerOption("max_num_images", &max_num_images);
30  if (!parser.parseOptions()) return EXIT_FAILURE;
31 
32  return colmap::RunVocabTreeBuilder(parser.getArgc(), parser.getArgv());
33 }
34 
35 int RetrieveVocabTree(const std::string& database_path,
36  const std::string& vocab_tree_path,
37  const std::string& output_index_path /*= ""*/,
38  const std::string& query_image_list_path /*= ""*/,
39  const std::string& database_image_list_path /*= ""*/,
40  int max_num_images /*= -1*/,
41  int num_neighbors /*= 5*/,
42  int num_checks /*= 256*/,
43  int num_images_after_verification /*= 0*/,
44  int max_num_features /*= -1*/) {
45  OptionsParser parser;
46  parser.registerOption("database_path", &database_path);
47  parser.registerOption("vocab_tree_path", &vocab_tree_path);
48  parser.registerOption("output_index_path", &output_index_path);
49  parser.registerOption("query_image_list_path", &query_image_list_path);
50  parser.registerOption("database_image_list_path",
51  &database_image_list_path);
52  parser.registerOption("max_num_images", &max_num_images);
53  parser.registerOption("num_neighbors", &num_neighbors);
54  parser.registerOption("num_checks", &num_checks);
55  parser.registerOption("num_images_after_verification",
56  &num_images_after_verification);
57  parser.registerOption("max_num_features", &max_num_features);
58  if (!parser.parseOptions()) return EXIT_FAILURE;
59 
60  return colmap::RunVocabTreeRetriever(parser.getArgc(), parser.getArgv());
61 }
62 
63 } // namespace cloudViewer
void registerOption(const std::string &name, const T *option)
Definition: option_utils.h:43
Generic file read and write utility for python interface.
int RetrieveVocabTree(const std::string &database_path, const std::string &vocab_tree_path, const std::string &output_index_path, const std::string &query_image_list_path, const std::string &database_image_list_path, int max_num_images, int num_neighbors, int num_checks, int num_images_after_verification, int max_num_features)
Definition: vocab_tree.cpp:35
int BuildVocabTree(const std::string &database_path, const std::string &vocab_tree_path, int num_visual_words, int num_checks, int branching, int num_iterations, int max_num_images)
Definition: vocab_tree.cpp:15
int RunVocabTreeRetriever(int argc, char **argv)
Definition: vocab_tree.cc:157
int RunVocabTreeBuilder(int argc, char **argv)
Definition: vocab_tree.cc:123