ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
image.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/image.h"
11 #include "pybind/docstring.h"
13 
14 namespace cloudViewer {
15 namespace reconstruction {
16 namespace image {
17 
18 // Reconstruction image 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  {"min_focal_length_ratio",
29  "Minimum ratio of focal length over minimum sensor "
30  "dimension."},
31  {"max_focal_length_ratio",
32  "Maximum ratio of focal length over maximum sensor "
33  "dimension."},
34  {"max_extra_param",
35  "Maximum magnitude of each extra parameter."},
36  {"min_num_observations", "The maximum number of observations."},
37  {"image_ids_path",
38  "Path to text file containing one image_id to delete per "
39  "line."},
40  {"image_names_path",
41  "Path to text file containing one image name to delete per "
42  "line."},
43  {"stereo_pairs_list",
44  "A text file path containing "
45  "stereo image pair names from. The text file is expected to "
46  "have one image pair per line, e.g.:\n"
47  "image_name1.jpg image_name2.jpg\n"
48  "image_name3.jpg image_name4.jpg\n"
49  "image_name5.jpg image_name6.jpg"},
50  {"blank_pixels",
51  "The amount of blank pixels in the undistorted image in the "
52  "range [0, 1]."},
53  {"min_scale",
54  "Minimum scale change of camera used to satisfy the blank "
55  "pixel constraint."},
56  {"max_scale",
57  "Maximum scale change of camera used to satisfy the blank "
58  "pixel constraint."},
59  {"max_image_size",
60  "Maximum image size in terms of width or height of the "
61  "undistorted camera."},
62  {"output_type",
63  "Output file format: supported values are {'COLMAP', 'PMVS', "
64  "'CMP-MVS'}."},
65  {"image_list_path",
66  "A text file path containing image file path."},
67  {"copy_policy",
68  "Supported copy policy are {copy, soft-link, hard-link}."},
69  {"num_patch_match_src_images",
70  "The number of patch match source images."},
71  {"roi_min_x",
72  "The value in the range [0, 1] that define the ROI (region "
73  "of interest) minimum x in original image."},
74  {"roi_min_y",
75  "The value in the range [0, 1] that define the ROI (region of "
76  "interest) minimum y in original image."},
77  {"roi_max_x",
78  "The value in the range [0, 1] that define the ROI (region "
79  "of interest) maximum x in original image."},
80  {"roi_max_y",
81  "The value in the range [0, 1] that define the ROI (region of "
82  "interest) maximum y in original image."}};
83 
84 void pybind_image_methods(py::module &m) {
85  m.def("delete_image", &DeleteImage,
86  py::call_guard<py::gil_scoped_release>(),
87  "Function for the deletion of images", "input_path"_a,
88  "output_path"_a, "image_ids_path"_a = "", "image_names_path"_a = "");
89  docstring::FunctionDocInject(m, "delete_image",
91 
92  m.def("filter_image", &FilterImage,
93  py::call_guard<py::gil_scoped_release>(),
94  "Function for the filtering of images", "input_path"_a,
95  "output_path"_a, "min_focal_length_ratio"_a = 0.1,
96  "max_focal_length_ratio"_a = 10.0, "max_extra_param"_a = 100.0,
97  "min_num_observations"_a = 10);
98  docstring::FunctionDocInject(m, "filter_image",
100 
101  m.def("rectify_image", &RectifyImage,
102  py::call_guard<py::gil_scoped_release>(),
103  "Function for the rectification of images", "image_path"_a,
104  "input_path"_a, "output_path"_a, "stereo_pairs_list"_a,
105  "blank_pixels"_a = 0.0, "min_scale"_a = 0.2, "max_scale"_a = 2.0,
106  "max_image_size"_a = -1);
107  docstring::FunctionDocInject(m, "rectify_image",
109 
110  m.def("register_image", &RegisterImage,
111  py::call_guard<py::gil_scoped_release>(),
112  "Function for the registeration of images", "database_path"_a,
113  "input_path"_a, "output_path"_a,
114  "incremental_mapper_options"_a = colmap::IncrementalMapperOptions());
115  docstring::FunctionDocInject(m, "register_image",
117 
118  m.def("undistort_image", &UndistortImage,
119  py::call_guard<py::gil_scoped_release>(),
120  "Function for the undistortion of images", "image_path"_a,
121  "input_path"_a, "output_path"_a, "image_list_path"_a = "",
122  "output_type"_a = "COLMAP", "copy_policy"_a = "copy",
123  "num_patch_match_src_images"_a = 20, "blank_pixels"_a = 0.0,
124  "min_scale"_a = 0.2, "max_scale"_a = 2.0, "max_image_size"_a = -1,
125  "roi_min_x"_a = 0.0, "roi_min_y"_a = 0.0, "roi_max_x"_a = 1.0,
126  "roi_max_y"_a = 1.0);
127  docstring::FunctionDocInject(m, "undistort_image",
129 
130  m.def("undistort_image_standalone", &UndistortImageStandalone,
131  py::call_guard<py::gil_scoped_release>(),
132  "Function for the standalone undistortion of images", "image_path"_a,
133  "input_path"_a, "output_path"_a, "blank_pixels"_a = 0.0,
134  "min_scale"_a = 0.2, "max_scale"_a = 2.0, "max_image_size"_a = -1,
135  "roi_min_x"_a = 0.0, "roi_min_y"_a = 0.0, "roi_max_x"_a = 1.0,
136  "roi_max_y"_a = 1.0);
137  docstring::FunctionDocInject(m, "undistort_image_standalone",
139 }
140 
141 void pybind_image(py::module &m) {
142  py::module m_submodule = m.def_submodule("image", "Reconstruction Images.");
143  pybind_image_methods(m_submodule);
144 }
145 
146 } // namespace image
147 } // namespace reconstruction
148 } // namespace cloudViewer
std::shared_ptr< core::Tensor > image
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
void pybind_image_methods(py::module &m)
Definition: image.cpp:84
static const std::unordered_map< std::string, std::string > map_shared_argument_docstrings
Definition: image.cpp:21
void pybind_image(py::module &m)
Definition: image.cpp:141
Generic file read and write utility for python interface.
colmap::IncrementalMapperOptions IncrementalMapperOptions