Move over to ABSL logging and flags.
Removes gperftools too since that wants gflags.
Here come the fireworks.
Change-Id: I79cb7bcf60f1047fbfa28bfffc21a0fd692e4b1c
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/vision/intrinsics_calibration.cc b/frc971/vision/intrinsics_calibration.cc
index e0ec38c..eb5605b 100644
--- a/frc971/vision/intrinsics_calibration.cc
+++ b/frc971/vision/intrinsics_calibration.cc
@@ -1,6 +1,7 @@
#include <cmath>
#include <regex>
+#include "absl/flags/flag.h"
#include "absl/strings/str_format.h"
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>
@@ -14,32 +15,35 @@
#include "frc971/vision/intrinsics_calibration_lib.h"
// TODO: Would be nice to remove this, but it depends on year-by-year Constants
-DEFINE_string(base_intrinsics, "",
- "Intrinsics to use for estimating board pose prior to solving "
- "for the new intrinsics.");
-DEFINE_string(calibration_folder, ".", "Folder to place calibration files.");
-DEFINE_string(camera_id, "", "Camera ID in format YY-NN-- year and number.");
-DEFINE_string(channel, "/camera", "Camera channel to use");
-DEFINE_string(config, "aos_config.json", "Path to the config file to use.");
-DEFINE_string(cpu_name, "", "Pi/Orin name to calibrate.");
-DEFINE_bool(display_undistorted, false,
- "If true, display the undistorted image.");
+ABSL_FLAG(std::string, base_intrinsics, "",
+ "Intrinsics to use for estimating board pose prior to solving "
+ "for the new intrinsics.");
+ABSL_FLAG(std::string, calibration_folder, ".",
+ "Folder to place calibration files.");
+ABSL_FLAG(std::string, camera_id, "",
+ "Camera ID in format YY-NN-- year and number.");
+ABSL_FLAG(std::string, channel, "/camera", "Camera channel to use");
+ABSL_FLAG(std::string, config, "aos_config.json",
+ "Path to the config file to use.");
+ABSL_FLAG(std::string, cpu_name, "", "Pi/Orin name to calibrate.");
+ABSL_FLAG(bool, display_undistorted, false,
+ "If true, display the undistorted image.");
namespace frc971::vision {
namespace {
void Main() {
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
aos::ShmEventLoop event_loop(&config.message());
- std::string hostname = FLAGS_cpu_name;
+ std::string hostname = absl::GetFlag(FLAGS_cpu_name);
if (hostname == "") {
hostname = aos::network::GetHostname();
LOG(INFO) << "Using pi/orin name from hostname as " << hostname;
}
- CHECK(!FLAGS_base_intrinsics.empty())
+ CHECK(!absl::GetFlag(FLAGS_base_intrinsics).empty())
<< "Need a base intrinsics json to use to auto-capture images when the "
"camera moves.";
std::unique_ptr<aos::ExitHandle> exit_handle = event_loop.MakeExitHandle();
@@ -54,18 +58,19 @@
std::string camera_name = absl::StrCat(
"/", aos::network::ParsePiOrOrin(hostname).value(),
std::to_string(aos::network::ParsePiOrOrinNumber(hostname).value()),
- FLAGS_channel);
+ absl::GetFlag(FLAGS_channel));
// THIS IS A HACK FOR 2024, since we call Orin2 "Imu"
if (aos::network::ParsePiOrOrin(hostname).value() == "orin" &&
aos::network::ParsePiOrOrinNumber(hostname).value() == 2) {
LOG(INFO) << "\nHACK for 2024: Renaming orin2 to imu\n";
- camera_name = absl::StrCat("/imu", FLAGS_channel);
+ camera_name = absl::StrCat("/imu", absl::GetFlag(FLAGS_channel));
}
- IntrinsicsCalibration extractor(&event_loop, hostname, camera_name,
- FLAGS_camera_id, FLAGS_base_intrinsics,
- FLAGS_display_undistorted,
- FLAGS_calibration_folder, exit_handle.get());
+ IntrinsicsCalibration extractor(
+ &event_loop, hostname, camera_name, absl::GetFlag(FLAGS_camera_id),
+ absl::GetFlag(FLAGS_base_intrinsics),
+ absl::GetFlag(FLAGS_display_undistorted),
+ absl::GetFlag(FLAGS_calibration_folder), exit_handle.get());
event_loop.Run();