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/y2019/vision/BUILD b/y2019/vision/BUILD
index 78298a1..af6da5b 100644
--- a/y2019/vision/BUILD
+++ b/y2019/vision/BUILD
@@ -40,7 +40,8 @@
target_compatible_with = ["@platforms//os:linux"],
deps = [
"//aos/vision/image:image_types",
- "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
],
)
@@ -94,7 +95,7 @@
"//aos/vision/blob:transpose",
"//aos/vision/debug:debug_framework",
"//aos/vision/math:vector",
- "@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/flags:flag",
],
)
@@ -105,6 +106,7 @@
deps = [
":image_writer",
":target_finder",
+ "//aos:init",
"//aos/vision/blob:codec",
"//aos/vision/blob:find_blob",
"//aos/vision/events:epoll_events",
@@ -115,7 +117,8 @@
"//y2019/jevois:uart",
"//y2019/jevois/camera:image_stream",
"//y2019/jevois/camera:reader",
- "@com_github_google_glog//:glog",
+ "@com_google_absl//absl/log",
+ "@com_google_absl//absl/log:check",
"@com_google_ceres_solver//:ceres",
],
)
@@ -150,6 +153,7 @@
target_compatible_with = VISION_TARGETS,
deps = [
":target_finder",
+ "//aos:init",
"//aos/logging",
"//aos/vision/blob:codec",
"//aos/vision/blob:find_blob",
diff --git a/y2019/vision/debug_viewer.cc b/y2019/vision/debug_viewer.cc
index 1a93f87..31fee54 100644
--- a/y2019/vision/debug_viewer.cc
+++ b/y2019/vision/debug_viewer.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include "gflags/gflags.h"
+#include "absl/flags/flag.h"
#include <Eigen/Dense>
#include "aos/vision/blob/move_scale.h"
@@ -19,7 +19,7 @@
using aos::vision::Segment;
using aos::vision::Vector;
-DEFINE_int32(camera, 10, "The camera to use the intrinsics for");
+ABSL_FLAG(int32_t, camera, 10, "The camera to use the intrinsics for");
namespace y2019::vision {
diff --git a/y2019/vision/global_calibration.cc b/y2019/vision/global_calibration.cc
index bb3259e..b502f3b 100644
--- a/y2019/vision/global_calibration.cc
+++ b/y2019/vision/global_calibration.cc
@@ -1,5 +1,8 @@
#include <fstream>
+#include "absl/flags/flag.h"
+
+#include "aos/init.h"
#include "aos/logging/implementations.h"
#include "aos/logging/logging.h"
#include "aos/vision/blob/codec.h"
@@ -14,28 +17,26 @@
// CERES Clashes with logging symbols...
#include "ceres/ceres.h"
-DEFINE_int32(camera_id, -1, "The camera ID to calibrate");
-DEFINE_string(prefix, "", "The image filename prefix");
+ABSL_FLAG(int32_t, camera_id, -1, "The camera ID to calibrate");
+ABSL_FLAG(std::string, prefix, "", "The image filename prefix");
-DEFINE_string(constants, "y2019/vision/constants.cc",
- "Path to the constants file to update");
+ABSL_FLAG(std::string, constants, "y2019/vision/constants.cc",
+ "Path to the constants file to update");
-DEFINE_double(beginning_tape_measure_reading, 11,
- "The tape measure measurement (in inches) of the first image.");
-DEFINE_int32(image_count, 75, "The number of images to capture");
-DEFINE_double(tape_start_x, -12.5,
- "The starting location of the tape measure in x relative to the "
- "CG in inches.");
-DEFINE_double(tape_start_y, -0.5,
- "The starting location of the tape measure in y relative to the "
- "CG in inches.");
+ABSL_FLAG(double, beginning_tape_measure_reading, 11,
+ "The tape measure measurement (in inches) of the first image.");
+ABSL_FLAG(int32_t, image_count, 75, "The number of images to capture");
+ABSL_FLAG(double, tape_start_x, -12.5,
+ "The starting location of the tape measure in x relative to the "
+ "CG in inches.");
+ABSL_FLAG(double, tape_start_y, -0.5,
+ "The starting location of the tape measure in y relative to the "
+ "CG in inches.");
-DEFINE_double(
- tape_direction_x, -1.0,
- "The x component of \"1\" inch along the tape measure in meters.");
-DEFINE_double(
- tape_direction_y, 0.0,
- "The y component of \"1\" inch along the tape measure in meters.");
+ABSL_FLAG(double, tape_direction_x, -1.0,
+ "The x component of \"1\" inch along the tape measure in meters.");
+ABSL_FLAG(double, tape_direction_y, 0.0,
+ "The y component of \"1\" inch along the tape measure in meters.");
using ::aos::monotonic_clock;
using ::aos::events::DataSocket;
@@ -88,17 +89,18 @@
void main(int argc, char **argv) {
using namespace y2019::vision;
- ::gflags::ParseCommandLineFlags(&argc, &argv, false);
+ aos::InitGoogle(&argc, &argv);
+ std::string prefix = absl::GetFlag(FLAGS_prefix);
DatasetInfo info = {
- FLAGS_camera_id,
- {{FLAGS_tape_start_x * kInchesToMeters,
- FLAGS_tape_start_y * kInchesToMeters}},
- {{FLAGS_tape_direction_x * kInchesToMeters,
- FLAGS_tape_direction_y * kInchesToMeters}},
- FLAGS_beginning_tape_measure_reading,
- FLAGS_prefix.c_str(),
- FLAGS_image_count,
+ absl::GetFlag(FLAGS_camera_id),
+ {{absl::GetFlag(FLAGS_tape_start_x) * kInchesToMeters,
+ absl::GetFlag(FLAGS_tape_start_y) * kInchesToMeters}},
+ {{absl::GetFlag(FLAGS_tape_direction_x) * kInchesToMeters,
+ absl::GetFlag(FLAGS_tape_direction_y) * kInchesToMeters}},
+ absl::GetFlag(FLAGS_beginning_tape_measure_reading),
+ prefix.c_str(),
+ absl::GetFlag(FLAGS_image_count),
};
TargetFinder target_finder;
@@ -140,8 +142,8 @@
::std::cout << "error = " << summary.final_cost << ";\n";
for (int i = 0; i < info.num_images; ++i) {
- ::aos::vision::DatasetFrame frame =
- aos::vision::LoadFile(FLAGS_prefix + std::to_string(i) + ".yuyv");
+ ::aos::vision::DatasetFrame frame = aos::vision::LoadFile(
+ absl::GetFlag(FLAGS_prefix) + std::to_string(i) + ".yuyv");
const ::aos::vision::ImageFormat fmt{640, 480};
::aos::vision::BlobList imgs =
@@ -289,7 +291,8 @@
results.dataset = info;
results.intrinsics = IntrinsicParams::get(&intrinsics[0]);
results.geometry = CameraGeometry::get(&geometry[0]);
- DumpCameraConstants(FLAGS_constants.c_str(), info.camera_id, results);
+ DumpCameraConstants(absl::GetFlag(FLAGS_constants).c_str(), info.camera_id,
+ results);
}
} // namespace y2019::vision
diff --git a/y2019/vision/image_writer.cc b/y2019/vision/image_writer.cc
index 9b73a81..18b8cae 100644
--- a/y2019/vision/image_writer.cc
+++ b/y2019/vision/image_writer.cc
@@ -4,7 +4,8 @@
#include <fstream>
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
namespace y2019::vision {
diff --git a/y2019/vision/target_sender.cc b/y2019/vision/target_sender.cc
index 650693c..6be52a5 100644
--- a/y2019/vision/target_sender.cc
+++ b/y2019/vision/target_sender.cc
@@ -4,6 +4,7 @@
#include <random>
#include <thread>
+#include "aos/init.h"
#include "aos/vision/blob/codec.h"
#include "aos/vision/blob/find_blob.h"
#include "aos/vision/events/socket_types.h"
@@ -18,7 +19,8 @@
// This has to be last to preserve compatibility with other headers using AOS
// logging.
-#include "glog/logging.h"
+#include "absl/log/check.h"
+#include "absl/log/log.h"
using ::aos::monotonic_clock;
using ::aos::events::DataSocket;
@@ -162,13 +164,9 @@
}
int main(int argc, char **argv) {
- (void)argc;
- (void)argv;
using namespace y2019::vision;
using frc971::jevois::CameraCommand;
- // gflags::ParseCommandLineFlags(&argc, &argv, false);
- FLAGS_logtostderr = true;
- google::InitGoogleLogging(argv[0]);
+ aos::InitGoogle(&argc, &argv);
int itsDev = open_terminos("/dev/ttyS0");
frc971::jevois::CobsPacketizer<frc971::jevois::uart_to_camera_size()> cobs;