MCPcopy Create free account
hub / github.com/ComputationalRobotics/XM-code / RunMapper

Function RunMapper

deps/glomap/glomap/exe/global_mapper.cc:15–95  ·  view source on GitHub ↗

------------------------------------- Mappers starting from COLMAP database -------------------------------------

Source from the content-addressed store, hash-verified

13// Mappers starting from COLMAP database
14// -------------------------------------
15int RunMapper(int argc, char** argv) {
16 std::string database_path;
17 std::string output_path;
18
19 std::string image_path = "";
20 std::string constraint_type = "ONLY_POINTS";
21 std::string output_format = "bin";
22
23 OptionManager options;
24 options.AddRequiredOption("database_path", &database_path);
25 options.AddRequiredOption("output_path", &output_path);
26 options.AddDefaultOption("image_path", &image_path);
27 options.AddDefaultOption("constraint_type",
28 &constraint_type,
29 "{ONLY_POINTS, ONLY_CAMERAS, "
30 "POINTS_AND_CAMERAS_BALANCED, POINTS_AND_CAMERAS}");
31 options.AddDefaultOption("output_format", &output_format, "{bin, txt}");
32 options.AddGlobalMapperFullOptions();
33
34 options.Parse(argc, argv);
35
36 if (!colmap::ExistsFile(database_path)) {
37 LOG(ERROR) << "`database_path` is not a file";
38 return EXIT_FAILURE;
39 }
40
41 if (constraint_type == "ONLY_POINTS") {
42 options.mapper->opt_gp.constraint_type =
43 GlobalPositionerOptions::ONLY_POINTS;
44 } else if (constraint_type == "ONLY_CAMERAS") {
45 options.mapper->opt_gp.constraint_type =
46 GlobalPositionerOptions::ONLY_CAMERAS;
47 } else if (constraint_type == "POINTS_AND_CAMERAS_BALANCED") {
48 options.mapper->opt_gp.constraint_type =
49 GlobalPositionerOptions::POINTS_AND_CAMERAS_BALANCED;
50 } else if (constraint_type == "POINTS_AND_CAMERAS") {
51 options.mapper->opt_gp.constraint_type =
52 GlobalPositionerOptions::POINTS_AND_CAMERAS;
53 } else {
54 LOG(ERROR) << "Invalid constriant type";
55 return EXIT_FAILURE;
56 }
57
58 // Check whether output_format is valid
59 if (output_format != "bin" && output_format != "txt") {
60 LOG(ERROR) << "Invalid output format";
61 return EXIT_FAILURE;
62 }
63
64 // Load the database
65 ViewGraph view_graph;
66 std::unordered_map<camera_t, Camera> cameras;
67 std::unordered_map<image_t, Image> images;
68 std::unordered_map<track_t, Track> tracks;
69
70 const colmap::Database database(database_path);
71 ConvertDatabaseToGlomap(database, view_graph, cameras, images);
72

Callers

nothing calls this directly

Calls 7

ConvertDatabaseToGlomapFunction · 0.85
AddRequiredOptionMethod · 0.80
AddDefaultOptionMethod · 0.80
ParseMethod · 0.80
SolveMethod · 0.45

Tested by

no test coverage detected