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/y2023/vision/viewer.cc b/y2023/vision/viewer.cc
index 78731e5..83ef483 100644
--- a/y2023/vision/viewer.cc
+++ b/y2023/vision/viewer.cc
@@ -1,3 +1,4 @@
+#include "absl/flags/flag.h"
#include "absl/strings/match.h"
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>
@@ -11,12 +12,13 @@
#include "frc971/vision/vision_generated.h"
#include "y2023/vision/vision_util.h"
-DEFINE_string(capture, "",
- "If set, capture a single image and save it to this filename.");
-DEFINE_string(channel, "/camera", "Channel name for the image.");
-DEFINE_string(config, "aos_config.json", "Path to the config file to use.");
-DEFINE_int32(rate, 100, "Time in milliseconds to wait between images");
-DEFINE_double(scale, 1.0, "Scale factor for images being displayed");
+ABSL_FLAG(std::string, capture, "",
+ "If set, capture a single image and save it to this filename.");
+ABSL_FLAG(std::string, channel, "/camera", "Channel name for the image.");
+ABSL_FLAG(std::string, config, "aos_config.json",
+ "Path to the config file to use.");
+ABSL_FLAG(int32_t, rate, 100, "Time in milliseconds to wait between images");
+ABSL_FLAG(double, scale, 1.0, "Scale factor for images being displayed");
namespace y2023::vision {
namespace {
@@ -41,12 +43,12 @@
cv::Mat bgr_image(cv::Size(image->cols(), image->rows()), CV_8UC3);
cv::cvtColor(image_color_mat, bgr_image, cv::COLOR_YUV2BGR_YUYV);
- if (!FLAGS_capture.empty()) {
- if (absl::EndsWith(FLAGS_capture, ".bfbs")) {
- aos::WriteFlatbufferToFile(FLAGS_capture,
+ if (!absl::GetFlag(FLAGS_capture).empty()) {
+ if (absl::EndsWith(absl::GetFlag(FLAGS_capture), ".bfbs")) {
+ aos::WriteFlatbufferToFile(absl::GetFlag(FLAGS_capture),
image_fetcher->CopyFlatBuffer());
} else {
- cv::imwrite(FLAGS_capture, bgr_image);
+ cv::imwrite(absl::GetFlag(FLAGS_capture), bgr_image);
}
return false;
@@ -54,9 +56,9 @@
cv::Mat undistorted_image;
cv::undistort(bgr_image, undistorted_image, intrinsics, dist_coeffs);
- if (FLAGS_scale != 1.0) {
- cv::resize(undistorted_image, undistorted_image, cv::Size(), FLAGS_scale,
- FLAGS_scale);
+ if (absl::GetFlag(FLAGS_scale) != 1.0) {
+ cv::resize(undistorted_image, undistorted_image, cv::Size(),
+ absl::GetFlag(FLAGS_scale), absl::GetFlag(FLAGS_scale));
}
cv::imshow("Display", undistorted_image);
@@ -76,7 +78,7 @@
void ViewerMain() {
aos::FlatbufferDetachedBuffer<aos::Configuration> config =
- aos::configuration::ReadConfig(FLAGS_config);
+ aos::configuration::ReadConfig(absl::GetFlag(FLAGS_config));
frc971::constants::WaitForConstants<Constants>(&config.message());
@@ -89,7 +91,7 @@
const cv::Mat dist_coeffs = CameraDistCoeffs(calibration_data);
aos::Fetcher<CameraImage> image_fetcher =
- event_loop.MakeFetcher<CameraImage>(FLAGS_channel);
+ event_loop.MakeFetcher<CameraImage>(absl::GetFlag(FLAGS_channel));
// Run the display loop
event_loop.AddPhasedLoop(
@@ -99,7 +101,7 @@
event_loop.Exit();
};
},
- ::std::chrono::milliseconds(FLAGS_rate));
+ ::std::chrono::milliseconds(absl::GetFlag(FLAGS_rate)));
event_loop.Run();