ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
model.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/model.h"
11 #include "pybind/docstring.h"
13 
14 namespace cloudViewer {
15 namespace reconstruction {
16 namespace model {
17 
18 // Reconstruction model functions have similar arguments, sharing arg
19 // docstrings
20 static const std::unordered_map<std::string, std::string>
22  {"input_path",
23  "The input path containing cameras.bin/txt, images.bin/txt "
24  "and points3D.bin/txt."},
25  {"output_path",
26  "The output path containing target cameras.bin/txt, "
27  "images.bin/txt and points3D.bin/txt."},
28  {"database_path",
29  "Path to database in which to store the extracted data."},
30  {"ref_images_path",
31  "Path to text file containing reference images per line."},
32  {"transform_path",
33  "The alignment transformation matrix saving path."},
34  {"alignment_type",
35  "Alignment type: supported values are {plane, ecef, enu, "
36  "enu-unscaled, custom}."},
37  {"max_error",
38  "Maximum error for a sample to be considered as an inlier. "
39  "Note that the residual of an estimator corresponds to a "
40  "squared error."},
41  {"min_common_images", "Minimum common images."},
42  {"robust_alignment", "Whether align robustly or not."},
43  {"estimate_scale", "Whether estimate scale or not."},
44  {"min_inlier_observations",
45  "The threshold determines how many observations in a common "
46  "image must reproject within the given threshold.."},
47  {"max_reproj_error", "The Maximum re-projection error."},
48  {"output_type",
49  "The supported output type values are {BIN, TXT, NVM, "
50  "Bundler, VRML, PLY, R3D, CAM}."},
51  {"skip_distortion",
52  "Whether skip distortion or no. When skip_distortion == true "
53  "it supports all camera models with the caveat that it's "
54  "using the mean focal length which will be inaccurate for "
55  "camera models with two focal lengths and distortion."},
56  {"boundary", "The cropping boundary coordinates."},
57  {"gps_transform_path",
58  "The gps transformation parameters file path."},
59  {"method",
60  "The supported Model Orientation Alignment values are "
61  "{MANHATTAN-WORLD, IMAGE-ORIENTATION}."},
62  {"max_image_size",
63  "The maximum image size for line detection."},
64  {"split_type",
65  "The supported split type values are {tiles, extent, parts}."},
66  {"split_params", "The split parameters file path."},
67  {"num_threads", "The number of cpu thread."},
68  {"min_reg_images", "The minimum number of reg images."},
69  {"min_num_points", "The minimum number of points."},
70  {"overlap_ratio", "The overlapped ratio."},
71  {"min_area_ratio", "The minimum area ratio."},
72  {"is_inverse", "Whether inverse or not."}};
73 
74 void pybind_model_methods(py::module &m) {
75  m.def("align_model", &AlignModel, py::call_guard<py::gil_scoped_release>(),
76  "Function for the alignment of model", "input_path"_a,
77  "output_path"_a, "database_path"_a = "", "ref_images_path"_a = "",
78  "transform_path"_a = "", "alignment_type"_a = "plane",
79  "max_error"_a = 0.0, "min_common_images"_a = 3,
80  "robust_alignment"_a = true, "estimate_scale"_a = true);
81  docstring::FunctionDocInject(m, "align_model",
83 
84  m.def("analyze_model", &AnalyzeModel,
85  py::call_guard<py::gil_scoped_release>(),
86  "Function for the analyse of model", "input_path"_a);
87  docstring::FunctionDocInject(m, "analyze_model",
89 
90  m.def("compare_model", &CompareModel,
91  py::call_guard<py::gil_scoped_release>(),
92  "Function for the comparison of model", "input_path1"_a,
93  "input_path2"_a, "output_path"_a = "",
94  "min_inlier_observations"_a = 0.3, "max_reproj_error"_a = 8.0);
95  docstring::FunctionDocInject(m, "compare_model",
97 
98  m.def("convert_model", &ConvertModel,
99  py::call_guard<py::gil_scoped_release>(),
100  "Function for the convertion of model", "input_path"_a,
101  "output_path"_a, "output_type"_a, "skip_distortion"_a = false);
102  docstring::FunctionDocInject(m, "convert_model",
104 
105  m.def("crop_model", &CropModel, py::call_guard<py::gil_scoped_release>(),
106  "Function for the cropping of model", "input_path"_a, "output_path"_a,
107  "boundary"_a, "gps_transform_path"_a = "");
108  docstring::FunctionDocInject(m, "crop_model",
110 
111  m.def("merge_model", &MergeModel, py::call_guard<py::gil_scoped_release>(),
112  "Function for the merging of model", "input_path1"_a, "input_path2"_a,
113  "output_path"_a, "max_reproj_error"_a = 64.0);
114  docstring::FunctionDocInject(m, "merge_model",
116 
117  m.def("align_model_orientation", &AlignModelOrientation,
118  py::call_guard<py::gil_scoped_release>(),
119  "Function for the orientation alignment of model", "image_path"_a,
120  "input_path"_a, "output_path"_a, "method"_a = "MANHATTAN-WORLD",
121  "max_image_size"_a = 1024);
122  docstring::FunctionDocInject(m, "align_model_orientation",
124 
125  m.def("split_model", &SplitModel, py::call_guard<py::gil_scoped_release>(),
126  "Function for the splitting of model", "input_path"_a,
127  "output_path"_a, "split_type"_a, "split_params"_a,
128  "gps_transform_path"_a = "", "min_reg_images"_a = 10,
129  "min_num_points"_a = 100, "overlap_ratio"_a = 0.0,
130  "min_area_ratio"_a = 0.0, "num_threads"_a = -1);
131  docstring::FunctionDocInject(m, "split_model",
133 
134  m.def("transform_model", &TransformModel,
135  py::call_guard<py::gil_scoped_release>(),
136  "Function for the transformation of model", "input_path"_a,
137  "output_path"_a, "transform_path"_a, "is_inverse"_a = false);
138  docstring::FunctionDocInject(m, "transform_model",
140 }
141 
142 void pybind_model(py::module &m) {
143  py::module m_submodule = m.def_submodule("model", "Reconstruction model.");
144  pybind_model_methods(m_submodule);
145 }
146 
147 } // namespace model
148 } // namespace reconstruction
149 } // 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: model.cpp:21
void pybind_model(py::module &m)
Definition: model.cpp:142
void pybind_model_methods(py::module &m)
Definition: model.cpp:74
Generic file read and write utility for python interface.