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 
8 #include "exe/image.h"
9 
10 #include "pipelines/image.h"
11 #include "pipelines/option_utils.h"
12 
13 namespace cloudViewer {
14 
15 int DeleteImage(const std::string& input_path,
16  const std::string& output_path,
17  const std::string& image_ids_path /*= ""*/,
18  const std::string& image_names_path /*= ""*/) {
19  OptionsParser parser;
20  parser.registerOption("input_path", &input_path);
21  parser.registerOption("output_path", &output_path);
22  // Path to text file containing one image_id to delete per line
23  parser.registerOption("image_ids_path", &image_ids_path);
24  // Path to text file containing one image name to delete per line
25  parser.registerOption("image_names_path", &image_names_path);
26  if (!parser.parseOptions()) return EXIT_FAILURE;
27 
28  return colmap::RunImageDeleter(parser.getArgc(), parser.getArgv());
29 }
30 
31 int FilterImage(const std::string& input_path,
32  const std::string& output_path,
33  double min_focal_length_ratio /*= 0.1*/,
34  double max_focal_length_ratio /*= 10.0*/,
35  double max_extra_param /*= 100.0*/,
36  std::size_t min_num_observations /*= 10*/) {
37  OptionsParser parser;
38  parser.registerOption("input_path", &input_path);
39  parser.registerOption("output_path", &output_path);
40  parser.registerOption("min_focal_length_ratio", &min_focal_length_ratio);
41  parser.registerOption("max_focal_length_ratio", &max_focal_length_ratio);
42  parser.registerOption("max_extra_param", &max_extra_param);
43  parser.registerOption("min_num_observations", &min_num_observations);
44  if (!parser.parseOptions()) return EXIT_FAILURE;
45 
46  return colmap::RunImageFilterer(parser.getArgc(), parser.getArgv());
47 }
48 
49 int RectifyImage(const std::string& image_path,
50  const std::string& input_path,
51  const std::string& output_path,
52  const std::string& stereo_pairs_list,
53  double blank_pixels /*= 0.0*/,
54  double min_scale /*= 0.2*/,
55  double max_scale /*= 2.0*/,
56  int max_image_size /*= -1*/) {
57  OptionsParser parser;
58  parser.registerOption("image_path", &image_path);
59  parser.registerOption("input_path", &input_path);
60  parser.registerOption("output_path", &output_path);
61  parser.registerOption("stereo_pairs_list", &stereo_pairs_list);
62  parser.registerOption("blank_pixels", &blank_pixels);
63  parser.registerOption("min_scale", &min_scale);
64  parser.registerOption("max_scale", &max_scale);
65  parser.registerOption("max_image_size", &max_image_size);
66  if (!parser.parseOptions()) return EXIT_FAILURE;
67 
68  return colmap::RunImageRectifier(parser.getArgc(), parser.getArgv());
69 }
70 
72  const std::string& database_path,
73  const std::string& input_path,
74  const std::string& output_path,
75  const colmap::IncrementalMapperOptions& incremental_mapper_options) {
76  OptionsParser parser;
77  parser.registerOption("database_path", &database_path);
78  parser.registerOption("input_path", &input_path);
79  parser.registerOption("output_path", &output_path);
80  parser.addMapperOptions(incremental_mapper_options);
81  if (!parser.parseOptions()) return EXIT_FAILURE;
82 
83  return colmap::RunImageRegistrator(parser.getArgc(), parser.getArgv());
84 }
85 
86 int UndistortImage(const std::string& image_path,
87  const std::string& input_path,
88  const std::string& output_path,
89  const std::string& image_list_path /*= ""*/,
90  const std::string& output_type /*= "COLMAP"*/,
91  const std::string& copy_policy /*= "copy"*/,
92  int num_patch_match_src_images /* = 20*/,
93  double blank_pixels /*= 0.0*/,
94  double min_scale /*= 0.2*/,
95  double max_scale /*= 2.0*/,
96  int max_image_size /*= -1 */,
97  double roi_min_x /*= 0.0*/,
98  double roi_min_y /*= 0.0*/,
99  double roi_max_x /*= 1.0*/,
100  double roi_max_y /*= 1.0*/) {
101  OptionsParser parser;
102  parser.registerOption("image_path", &image_path);
103  parser.registerOption("input_path", &input_path);
104  parser.registerOption("output_path", &output_path);
105  parser.registerOption("image_list_path", &image_list_path);
106  // supported {COLMAP, PMVS, CMP-MVS}
107  parser.registerOption("output_type", &output_type);
108  // supported {copy, soft-link, hard-link}
109  parser.registerOption("copy_policy", &copy_policy);
110  parser.registerOption("num_patch_match_src_images",
111  &num_patch_match_src_images);
112  parser.registerOption("blank_pixels", &blank_pixels);
113  parser.registerOption("min_scale", &min_scale);
114  parser.registerOption("max_scale", &max_scale);
115  parser.registerOption("max_image_size", &max_image_size);
116  parser.registerOption("roi_min_x", &roi_min_x);
117  parser.registerOption("roi_min_y", &roi_min_y);
118  parser.registerOption("roi_max_x", &roi_max_x);
119  parser.registerOption("roi_max_y", &roi_max_y);
120 
121  if (!parser.parseOptions()) return EXIT_FAILURE;
122 
123  return colmap::RunImageUndistorter(parser.getArgc(), parser.getArgv());
124 }
125 
126 int UndistortImageStandalone(const std::string& image_path,
127  const std::string& input_file,
128  const std::string& output_path,
129  double blank_pixels /*= 0.0*/,
130  double min_scale /*= 0.2*/,
131  double max_scale /*= 2.0*/,
132  int max_image_size /*= -1 */,
133  double roi_min_x /*= 0.0*/,
134  double roi_min_y /*= 0.0*/,
135  double roi_max_x /*= 1.0*/,
136  double roi_max_y /*= 1.0*/) {
137  OptionsParser parser;
138  parser.registerOption("image_path", &image_path);
139  parser.registerOption("input_file", &input_file);
140  parser.registerOption("output_path", &output_path);
141  parser.registerOption("blank_pixels", &blank_pixels);
142  parser.registerOption("min_scale", &min_scale);
143  parser.registerOption("max_scale", &max_scale);
144  parser.registerOption("max_image_size", &max_image_size);
145  parser.registerOption("roi_min_x", &roi_min_x);
146  parser.registerOption("roi_min_y", &roi_min_y);
147  parser.registerOption("roi_max_x", &roi_max_x);
148  parser.registerOption("roi_max_y", &roi_max_y);
149 
150  if (!parser.parseOptions()) return EXIT_FAILURE;
151 
153  parser.getArgv());
154 }
155 
156 } // namespace cloudViewer
void addMapperOptions(const colmap::IncrementalMapperOptions &incremental_mapper_options)
void registerOption(const std::string &name, const T *option)
Definition: option_utils.h:43
Generic file read and write utility for python interface.
int FilterImage(const std::string &input_path, const std::string &output_path, double min_focal_length_ratio, double max_focal_length_ratio, double max_extra_param, std::size_t min_num_observations)
Definition: image.cpp:31
int UndistortImageStandalone(const std::string &image_path, const std::string &input_file, const std::string &output_path, double blank_pixels, double min_scale, double max_scale, int max_image_size, double roi_min_x, double roi_min_y, double roi_max_x, double roi_max_y)
Definition: image.cpp:126
int RectifyImage(const std::string &image_path, const std::string &input_path, const std::string &output_path, const std::string &stereo_pairs_list, double blank_pixels, double min_scale, double max_scale, int max_image_size)
Definition: image.cpp:49
int RegisterImage(const std::string &database_path, const std::string &input_path, const std::string &output_path, const colmap::IncrementalMapperOptions &incremental_mapper_options)
Definition: image.cpp:71
int DeleteImage(const std::string &input_path, const std::string &output_path, const std::string &image_ids_path, const std::string &image_names_path)
Definition: image.cpp:15
int UndistortImage(const std::string &image_path, const std::string &input_path, const std::string &output_path, const std::string &image_list_path, const std::string &output_type, const std::string &copy_policy, int num_patch_match_src_images, double blank_pixels, double min_scale, double max_scale, int max_image_size, double roi_min_x, double roi_min_y, double roi_max_x, double roi_max_y)
Definition: image.cpp:86
int RunImageUndistorter(int argc, char **argv)
Definition: image.cc:311
int RunImageFilterer(int argc, char **argv)
Definition: image.cc:156
int RunImageUndistorterStandalone(int argc, char **argv)
Definition: image.cc:408
int RunImageRectifier(int argc, char **argv)
Definition: image.cc:205
int RunImageDeleter(int argc, char **argv)
Definition: image.cc:78
int RunImageRegistrator(int argc, char **argv)
Definition: image.cc:240