-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_toolbox_cli.cc
More file actions
43 lines (40 loc) · 1.61 KB
/
image_toolbox_cli.cc
File metadata and controls
43 lines (40 loc) · 1.61 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
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/status/status.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
#include "image_processing_toolbox.h"
#include "status_macros.h"
ABSL_FLAG(std::string, input_video_path, "testdata/video.mp4",
"Input video path file.");
ABSL_FLAG(std::string, output_directory, "/tmp/frames",
"Directory which have the frame files.");
ABSL_FLAG(std::int32_t, threshold, 0,
"Minimum feature count to output new image. Mutually exclusive with number_frames.");
ABSL_FLAG(int32_t, number_frames, 50,
"Number of frames to take from the input file. Mutually exclusive with threshold.");
absl::Status Run() {
if (absl::GetFlag(FLAGS_threshold) > 0 && !
absl::GetFlag(FLAGS_number_frames)) {
RETURN_IF_ERROR(
sfm::SaveRelatedFrames(absl::GetFlag(FLAGS_input_video_path), absl::
GetFlag(FLAGS_output_directory), absl::GetFlag(FLAGS_threshold)));
} else if (!absl::GetFlag(FLAGS_threshold) && absl::GetFlag(
FLAGS_number_frames) > 0) {
RETURN_IF_ERROR(
sfm::SaveFrames(absl::GetFlag(FLAGS_input_video_path), absl::GetFlag(
FLAGS_number_frames), absl::
GetFlag(FLAGS_output_directory)));
} else return absl::InvalidArgumentError("Mutually exclusive options");
return absl::OkStatus();
}
int main(int argc, char** argv) {
google::InitGoogleLogging(*argv);
absl::ParseCommandLine(argc, argv);
gflags::SetCommandLineOption("logtostderr", "1");
if (auto status = Run(); !status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}