ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
colmap.cc
Go to the documentation of this file.
1 // Copyright (c) 2018, ETH Zurich and UNC Chapel Hill.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 //
14 // * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of
15 // its contributors may be used to endorse or promote products derived
16 // from this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 // POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de)
31 
32 #include "exe/database.h"
33 #include "exe/feature.h"
34 #include "exe/gui.h"
35 #include "exe/image.h"
36 #include "exe/model.h"
37 #include "exe/mvs.h"
38 #include "exe/sfm.h"
39 #include "exe/vocab_tree.h"
40 #include "util/version.h"
41 
42 namespace {
43 
44 typedef std::function<int(int, char**)> command_func_t;
45 
46 int ShowHelp(
47  const std::vector<std::pair<std::string, command_func_t>>& commands) {
48  std::cout << colmap::StringPrintf(
49  "%s -- Structure-from-Motion and Multi-View Stereo\n"
50  " (%s)",
51  colmap::GetVersionInfo().c_str(),
52  colmap::GetBuildInfo().c_str())
53  << std::endl
54  << std::endl;
55 
56  std::cout << "Usage:" << std::endl;
57  std::cout << " colmap [command] [options]" << std::endl << std::endl;
58 
59  std::cout << "Documentation:" << std::endl;
60  std::cout << " https://colmap.github.io/" << std::endl << std::endl;
61 
62  std::cout << "Example usage:" << std::endl;
63  std::cout << " colmap help [ -h, --help ]" << std::endl;
64  std::cout << " colmap gui" << std::endl;
65  std::cout << " colmap gui -h [ --help ]" << std::endl;
66  std::cout << " colmap automatic_reconstructor -h [ --help ]" << std::endl;
67  std::cout << " colmap automatic_reconstructor --image_path IMAGES "
68  "--workspace_path WORKSPACE"
69  << std::endl;
70  std::cout
71  << " colmap feature_extractor --image_path IMAGES --database_path "
72  "DATABASE"
73  << std::endl;
74  std::cout << " colmap exhaustive_matcher --database_path DATABASE"
75  << std::endl;
76  std::cout << " colmap mapper --image_path IMAGES --database_path DATABASE "
77  "--output_path MODEL"
78  << std::endl;
79  std::cout << " ..." << std::endl << std::endl;
80 
81  std::cout << "Available commands:" << std::endl;
82  std::cout << " help" << std::endl;
83  for (const auto& command : commands) {
84  std::cout << " " << command.first << std::endl;
85  }
86  std::cout << std::endl;
87 
88  return EXIT_SUCCESS;
89 }
90 
91 } // namespace
92 
93 int main(int argc, char** argv) {
94  using namespace colmap;
95 
96  InitializeGlog(argv);
97 #ifdef GUI_ENABLED
98  Q_INIT_RESOURCE(resources);
99 #endif
100 
101  std::vector<std::pair<std::string, command_func_t>> commands;
102  commands.emplace_back("gui", &RunGraphicalUserInterface);
103  commands.emplace_back("automatic_reconstructor",
105  commands.emplace_back("bundle_adjuster", &RunBundleAdjuster);
106  commands.emplace_back("color_extractor", &RunColorExtractor);
107  commands.emplace_back("database_cleaner", &RunDatabaseCleaner);
108  commands.emplace_back("database_creator", &RunDatabaseCreator);
109  commands.emplace_back("database_merger", &RunDatabaseMerger);
110  commands.emplace_back("delaunay_mesher", &RunDelaunayMesher);
111  commands.emplace_back("exhaustive_matcher", &RunExhaustiveMatcher);
112  commands.emplace_back("feature_extractor", &RunFeatureExtractor);
113  commands.emplace_back("feature_importer", &RunFeatureImporter);
114  commands.emplace_back("hierarchical_mapper", &RunHierarchicalMapper);
115  commands.emplace_back("image_deleter", &RunImageDeleter);
116  commands.emplace_back("image_filterer", &RunImageFilterer);
117  commands.emplace_back("image_rectifier", &RunImageRectifier);
118  commands.emplace_back("image_registrator", &RunImageRegistrator);
119  commands.emplace_back("image_texturer", &RunImageTexturer);
120  commands.emplace_back("image_undistorter", &RunImageUndistorter);
121  commands.emplace_back("image_undistorter_standalone",
123  commands.emplace_back("mapper", &RunMapper);
124  commands.emplace_back("matches_importer", &RunMatchesImporter);
125  commands.emplace_back("model_aligner", &RunModelAligner);
126  commands.emplace_back("model_analyzer", &RunModelAnalyzer);
127  commands.emplace_back("model_comparer", &RunModelComparer);
128  commands.emplace_back("model_converter", &RunModelConverter);
129  commands.emplace_back("model_cropper", &RunModelCropper);
130  commands.emplace_back("model_merger", &RunModelMerger);
131  commands.emplace_back("model_orientation_aligner",
133  commands.emplace_back("model_splitter", &RunModelSplitter);
134  commands.emplace_back("model_transformer", &RunModelTransformer);
135  commands.emplace_back("patch_match_stereo", &RunPatchMatchStereo);
136  commands.emplace_back("point_filtering", &RunPointFiltering);
137  commands.emplace_back("point_triangulator", &RunPointTriangulator);
138  commands.emplace_back("poisson_mesher", &RunPoissonMesher);
139  commands.emplace_back("project_generator", &RunProjectGenerator);
140  commands.emplace_back("rig_bundle_adjuster", &RunRigBundleAdjuster);
141  commands.emplace_back("sequential_matcher", &RunSequentialMatcher);
142  commands.emplace_back("spatial_matcher", &RunSpatialMatcher);
143  commands.emplace_back("stereo_fusion", &RunStereoFuser);
144  commands.emplace_back("transitive_matcher", &RunTransitiveMatcher);
145  commands.emplace_back("vocab_tree_builder", &RunVocabTreeBuilder);
146  commands.emplace_back("vocab_tree_matcher", &RunVocabTreeMatcher);
147  commands.emplace_back("vocab_tree_retriever", &RunVocabTreeRetriever);
148 
149 #ifdef Q_OS_MAC
150  // only support gui on MacOS
151  const std::string command = "gui";
152 #else
153  if (argc == 1) {
154  return ShowHelp(commands);
155  }
156  const std::string command = argv[1];
157 #endif
158  if (command == "help" || command == "-h" || command == "--help") {
159  return ShowHelp(commands);
160  } else {
161  command_func_t matched_command_func = nullptr;
162  for (const auto& command_func : commands) {
163  if (command == command_func.first) {
164  matched_command_func = command_func.second;
165  break;
166  }
167  }
168  if (matched_command_func == nullptr) {
169  std::cerr << StringPrintf(
170  "ERROR: Command `%s` not recognized. To list "
171  "the "
172  "available commands, run `colmap help`.",
173  command.c_str())
174  << std::endl;
175  return EXIT_FAILURE;
176  } else {
177  int command_argc = argc - 1;
178  char** command_argv = &argv[1];
179  command_argv[0] = argv[0];
180  return matched_command_func(command_argc, command_argv);
181  }
182  }
183 
184  return ShowHelp(commands);
185 }
int main(int argc, char **argv)
Definition: colmap.cc:93
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
int RunModelAligner(int argc, char **argv)
Definition: model.cc:196
int RunImageUndistorter(int argc, char **argv)
Definition: image.cc:311
void InitializeGlog(char **argv)
Definition: logging.cc:36
int RunPoissonMesher(int argc, char **argv)
Definition: mvs.cc:123
int RunModelOrientationAligner(int argc, char **argv)
Definition: model.cc:628
int RunModelConverter(int argc, char **argv)
Definition: model.cc:463
int RunImageFilterer(int argc, char **argv)
Definition: image.cc:156
int RunModelComparer(int argc, char **argv)
Definition: model.cc:367
std::string GetBuildInfo()
Definition: version.cc:40
int RunMatchesImporter(int argc, char **argv)
Definition: feature.cc:238
int RunImageUndistorterStandalone(int argc, char **argv)
Definition: image.cc:408
int RunColorExtractor(int argc, char **argv)
Definition: sfm.cc:167
int RunVocabTreeRetriever(int argc, char **argv)
Definition: vocab_tree.cc:157
int RunImageRectifier(int argc, char **argv)
Definition: image.cc:205
int RunVocabTreeBuilder(int argc, char **argv)
Definition: vocab_tree.cc:123
int RunSequentialMatcher(int argc, char **argv)
Definition: feature.cc:315
int RunPatchMatchStereo(int argc, char **argv)
Definition: mvs.cc:81
std::string GetVersionInfo()
Definition: version.cc:36
int RunStereoFuser(int argc, char **argv)
Definition: mvs.cc:138
int RunPointTriangulator(int argc, char **argv)
Definition: sfm.cc:339
int RunHierarchicalMapper(int argc, char **argv)
Definition: sfm.cc:262
int RunModelCropper(int argc, char **argv)
Definition: model.cc:509
int RunImageDeleter(int argc, char **argv)
Definition: image.cc:78
int RunDatabaseCleaner(int argc, char **argv)
Definition: database.cc:40
int RunFeatureExtractor(int argc, char **argv)
Definition: feature.cc:137
int RunTransitiveMatcher(int argc, char **argv)
Definition: feature.cc:373
int RunModelMerger(int argc, char **argv)
Definition: model.cc:582
int RunImageTexturer(int argc, char **argv)
Definition: image.cc:497
int RunMapper(int argc, char **argv)
Definition: sfm.cc:185
int RunImageRegistrator(int argc, char **argv)
Definition: image.cc:240
int RunGraphicalUserInterface(int argc, char **argv)
Definition: gui.cc:39
int RunDatabaseMerger(int argc, char **argv)
Definition: database.cc:91
int RunRigBundleAdjuster(int argc, char **argv)
Definition: sfm.cc:655
int RunProjectGenerator(int argc, char **argv)
Definition: gui.cc:76
int RunDelaunayMesher(int argc, char **argv)
Definition: mvs.cc:43
int RunModelSplitter(int argc, char **argv)
Definition: model.cc:694
int RunSpatialMatcher(int argc, char **argv)
Definition: feature.cc:344
std::string StringPrintf(const char *format,...)
Definition: string.cc:131
int RunFeatureImporter(int argc, char **argv)
Definition: feature.cc:196
int RunAutomaticReconstructor(int argc, char **argv)
Definition: sfm.cc:48
int RunModelAnalyzer(int argc, char **argv)
Definition: model.cc:332
int RunBundleAdjuster(int argc, char **argv)
Definition: sfm.cc:135
int RunVocabTreeMatcher(int argc, char **argv)
Definition: feature.cc:402
int RunPointFiltering(int argc, char **argv)
Definition: sfm.cc:302
int RunModelTransformer(int argc, char **argv)
Definition: model.cc:879
int RunExhaustiveMatcher(int argc, char **argv)
Definition: feature.cc:286
int RunDatabaseCreator(int argc, char **argv)
Definition: database.cc:81