-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_main.cc
More file actions
45 lines (39 loc) · 1.45 KB
/
run_main.cc
File metadata and controls
45 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <fstream>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
#include "google/protobuf/text_format.h"
#include "reconstruction.h"
#include "sfm.h"
#include "status_macros.h"
ABSL_FLAG(std::string, images_directory,
"testdata/reconstruction/kleenex/two_frames",
"Directory with input image frames");
ABSL_FLAG(std::string, calibration_file, "testdata/pixel_6a_calibration.txtpb",
"Intrinsic camera calibration");
ABSL_FLAG(std::string, output_point_cloud_file, "/tmp/kleenex_2.ply",
"Point cloud in PLY format");
absl::Status Run() {
ASSIGN_OR_RETURN(auto camera_matrix,
sfm::LoadCameraMatrixFromTextProtoFile(
absl::GetFlag(FLAGS_calibration_file)));
sfm::Reconstruction reconstruction(camera_matrix);
ASSIGN_OR_RETURN(
auto image_paths,
sfm::GetFilesFromDirectory(absl::GetFlag(FLAGS_images_directory)));
RETURN_IF_ERROR(reconstruction.Run(
image_paths, absl::GetFlag(FLAGS_output_point_cloud_file)));
RETURN_IF_ERROR(reconstruction.VisualizeMatches());
return absl::OkStatus();
}
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
absl::ParseCommandLine(argc, argv);
gflags::SetCommandLineOption("logtostderr", "1");
if (const auto status = Run(); !status.ok()) {
LOG(ERROR) << "Failed: " << status.message();
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}