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 
9 
10 #include "pipelines/vocab_tree.h"
11 #include "pybind/docstring.h"
13 
14 namespace cloudViewer {
15 namespace reconstruction {
16 namespace vocab_tree {
17 
18 // Reconstruction vocabulary tree functions have similar arguments, sharing arg
19 // docstrings
20 static const std::unordered_map<std::string, std::string>
22  {"database_path",
23  "Path to database in which to store the extracted data"},
24  {"vocab_tree_path", "The vocabulary tree path."},
25  {"num_visual_words",
26  "The desired number of visual words, i.e. the number of leaf "
27  "node clusters. Note that the actual number of visual words "
28  "might be less."},
29  {"num_checks",
30  "The number of checks in the nearest neighbor search."},
31  {"branching",
32  "The branching factor of the hierarchical k-means tree."},
33  {"num_iterations",
34  "The number of iterations for the clustering."},
35  {"max_num_images", "The maximum number of images."},
36  {"database_image_list_path", "The database image list path."},
37  {"query_image_list_path", "The query image list path."},
38  {"output_index_path", "The output index path."},
39  {"max_num_images",
40  "The maximum number of most similar images to retrieve."},
41  {"num_neighbors",
42  "The number of nearest neighbor visual words that each "
43  "feature descriptor is assigned to."},
44  {"num_images_after_verification",
45  "Whether to perform spatial verification after image "
46  "retrieval."},
47  {"max_num_features", "The maximum number of features."}};
48 
49 void pybind_vocab_tree_methods(py::module &m) {
50  m.def("build_vocab_tree", &BuildVocabTree,
51  py::call_guard<py::gil_scoped_release>(),
52  "Function for the building of vocabulary tree", "database_path"_a,
53  "vocab_tree_path"_a, "num_visual_words"_a = 256 * 256,
54  "num_checks"_a = 256, "branching"_a = 256, "num_iterations"_a = 11,
55  "max_num_images"_a = -1);
56  docstring::FunctionDocInject(m, "build_vocab_tree",
58 
59  m.def("retrieve_vocab_tree", &RetrieveVocabTree,
60  py::call_guard<py::gil_scoped_release>(),
61  "Function for the retrieve of vocabulary tree", "database_path"_a,
62  "vocab_tree_path"_a, "output_index_path"_a = "",
63  "query_image_list_path"_a = "", "database_image_list_path"_a = "",
64  "max_num_images"_a = -1, "num_neighbors"_a = 5, "num_checks"_a = 256,
65  "num_images_after_verification"_a = 0, "max_num_features"_a = -1);
66  docstring::FunctionDocInject(m, "retrieve_vocab_tree",
68 }
69 
70 void pybind_vocab_tree(py::module &m) {
71  py::module m_submodule =
72  m.def_submodule("vocab_tree", "Reconstruction vocabulary tree.");
73  pybind_vocab_tree_methods(m_submodule);
74 }
75 
76 } // namespace vocab_tree
77 } // namespace reconstruction
78 } // namespace cloudViewer
void FunctionDocInject(py::module &pybind_module, const std::string &function_name, const std::unordered_map< std::string, std::string > &map_parameter_body_docs)
Definition: docstring.cpp:76
static const std::unordered_map< std::string, std::string > map_shared_argument_docstrings
Definition: vocab_tree.cpp:21
void pybind_vocab_tree_methods(py::module &m)
Definition: vocab_tree.cpp:49
Generic file read and write utility for python interface.