From dcfbdb88fb5e4bb3c0915b614faa56d8e0b38f68 Mon Sep 17 00:00:00 2001 From: David OK Date: Sun, 29 Oct 2023 14:31:03 +0000 Subject: [PATCH] MAINT: deduplicate code. --- cpp/drafts/ChessboardDetection/EdgeStatistics.hpp | 5 ----- .../FeatureDetectors/edge_detection_example.cpp | 6 ------ .../Sara/FeatureMatching/video_edge_matching.cpp | 6 ------ .../orthogonal_vanishing_point_detection.cpp | 14 ++++---------- cpp/src/DO/Sara/Core/PhysicalQuantities.hpp | 14 +++++++++++++- .../examples/halide_edge_detection_example.cpp | 6 ------ 6 files changed, 17 insertions(+), 34 deletions(-) diff --git a/cpp/drafts/ChessboardDetection/EdgeStatistics.hpp b/cpp/drafts/ChessboardDetection/EdgeStatistics.hpp index 64b320cb3..8531dd3cd 100644 --- a/cpp/drafts/ChessboardDetection/EdgeStatistics.hpp +++ b/cpp/drafts/ChessboardDetection/EdgeStatistics.hpp @@ -14,11 +14,6 @@ #include -inline constexpr auto operator"" _percent(long double x) -> long double -{ - return x / 100; -} - namespace DO::Sara { auto is_strong_edge(const ImageView& grad_mag, diff --git a/cpp/examples/Sara/FeatureDetectors/edge_detection_example.cpp b/cpp/examples/Sara/FeatureDetectors/edge_detection_example.cpp index 9f5e9bbb1..cb51cd543 100644 --- a/cpp/examples/Sara/FeatureDetectors/edge_detection_example.cpp +++ b/cpp/examples/Sara/FeatureDetectors/edge_detection_example.cpp @@ -35,12 +35,6 @@ using namespace std; using namespace DO::Sara; -inline constexpr long double operator"" _percent(long double x) -{ - return x / 100; -} - - auto is_strong_edge(const ImageView& grad_mag, const std::vector& edge, const float grad_thres) -> float diff --git a/cpp/examples/Sara/FeatureMatching/video_edge_matching.cpp b/cpp/examples/Sara/FeatureMatching/video_edge_matching.cpp index 571992705..ba25ebea3 100644 --- a/cpp/examples/Sara/FeatureMatching/video_edge_matching.cpp +++ b/cpp/examples/Sara/FeatureMatching/video_edge_matching.cpp @@ -37,12 +37,6 @@ using namespace std; using namespace DO::Sara; -inline constexpr long double operator"" _percent(long double x) -{ - return x / 100; -} - - auto initialize_camera_intrinsics_1() { auto intrinsics = BrownConradyCamera32{}; diff --git a/cpp/examples/Sara/MultiViewGeometry/orthogonal_vanishing_point_detection.cpp b/cpp/examples/Sara/MultiViewGeometry/orthogonal_vanishing_point_detection.cpp index f6d8c8662..5e4d49d09 100644 --- a/cpp/examples/Sara/MultiViewGeometry/orthogonal_vanishing_point_detection.cpp +++ b/cpp/examples/Sara/MultiViewGeometry/orthogonal_vanishing_point_detection.cpp @@ -41,12 +41,6 @@ namespace po = boost::program_options; using namespace DO::Sara; -inline constexpr long double operator"" _percent(long double x) -{ - return x / 100; -} - - auto initialize_camera_intrinsics_1() { auto intrinsics = BrownConradyCamera32{}; @@ -239,13 +233,13 @@ int sara_graphics_main(int argc, char** argv) // Output save. const auto basename = fs::path(video_filepath).stem().string(); - VideoWriter video_writer{ + const auto output_file = #if defined(__APPLE__) - "/Users/david/Desktop/" + basename + ".ortho-vp.mp4", + "/Users/david/Desktop/" + basename + ".ortho-vp.mp4"; #else - "/home/david/Desktop/" + basename + ".ortho-vp.mp4", + "/home/david/Desktop/" + basename + ".ortho-vp.mp4"; #endif - frame.sizes()}; + auto video_writer = VideoWriter{output_file, frame.sizes()}; // Show the local extrema. diff --git a/cpp/src/DO/Sara/Core/PhysicalQuantities.hpp b/cpp/src/DO/Sara/Core/PhysicalQuantities.hpp index 6c8e21724..865b1e1f5 100644 --- a/cpp/src/DO/Sara/Core/PhysicalQuantities.hpp +++ b/cpp/src/DO/Sara/Core/PhysicalQuantities.hpp @@ -426,7 +426,19 @@ namespace DO::Sara { -> PixelUnits<2> { const auto ratio = sensor_sizes.cast() / focal_length.value; - return image_sizes.cast().cwiseProduct(ratio).cast(); + return image_sizes.cast() + .cwiseProduct(ratio) + .cast(); + } + +} // namespace DO::Sara + + +namespace DO::Sara { + + inline constexpr auto operator"" _percent(long double x) -> long double + { + return x / 100; } } // namespace DO::Sara diff --git a/cpp/src/DO/Shakti/Halide/Generators/examples/halide_edge_detection_example.cpp b/cpp/src/DO/Shakti/Halide/Generators/examples/halide_edge_detection_example.cpp index 95bff3a30..50842ef24 100644 --- a/cpp/src/DO/Shakti/Halide/Generators/examples/halide_edge_detection_example.cpp +++ b/cpp/src/DO/Shakti/Halide/Generators/examples/halide_edge_detection_example.cpp @@ -180,12 +180,6 @@ namespace v2 { } // namespace v2 -inline constexpr long double operator"" _percent(long double x) -{ - return x / 100; -} - - int main(int argc, char** argv) { DO::Sara::GraphicsApplication app(argc, argv);