From e27602488d6045df5300dea166ffe8d00c9414dc Mon Sep 17 00:00:00 2001 From: Arnaud Fauconnet Date: Wed, 19 Jul 2023 17:37:16 +0200 Subject: [PATCH] Found a way to unify the hdr_output_folder so that it's set across both the publisher and the camera_simulator with just the flag --- event_camera_simulator/esim/src/camera_simulator.cpp | 8 +++----- event_camera_simulator/esim_common/CMakeLists.txt | 2 ++ .../esim_common/include/esim/common/hdr.hpp | 5 +++++ event_camera_simulator/esim_common/src/hdr.cpp | 9 +++++++++ event_camera_simulator/esim_ros/cfg/from_folder.conf | 1 + .../esim_visualization/src/hdr_publisher.cpp | 12 +++--------- 6 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 event_camera_simulator/esim_common/include/esim/common/hdr.hpp create mode 100644 event_camera_simulator/esim_common/src/hdr.cpp diff --git a/event_camera_simulator/esim/src/camera_simulator.cpp b/event_camera_simulator/esim/src/camera_simulator.cpp index 1fa4b6f..2837dce 100644 --- a/event_camera_simulator/esim/src/camera_simulator.cpp +++ b/event_camera_simulator/esim/src/camera_simulator.cpp @@ -1,16 +1,14 @@ #include "opencv2/imgcodecs.hpp" +#include #include #include #include #include #include -#define FRAME_DIR_PATH "/home/arno/sim_ws/out/frames" - static uint frame_number = 0; static std::ofstream exposures_file_; -static std::string output_folder = "/home/arno/sim_ws/out"; namespace event_camera_simulator { @@ -69,7 +67,7 @@ namespace event_camera_simulator { static uint frame_number = 0; std::stringstream ss; - ss << output_folder << "/frames/frame_" << std::setfill('0') + ss << hdr_output_folder << "/frames/frame_" << std::setfill('0') << std::setw(5) << frame_number++ << ".exr"; std::string frame_path = ss.str(); cv::imwrite(frame_path, *camera_image); @@ -80,7 +78,7 @@ namespace event_camera_simulator { // ); exposures_file_.open( - ze::joinPath(output_folder, "exposures.csv"), + ze::joinPath(hdr_output_folder, "exposures.csv"), std::ios::app ); exposures_file_ << time << "," << frame_number << "," diff --git a/event_camera_simulator/esim_common/CMakeLists.txt b/event_camera_simulator/esim_common/CMakeLists.txt index 9a3b486..c608f97 100644 --- a/event_camera_simulator/esim_common/CMakeLists.txt +++ b/event_camera_simulator/esim_common/CMakeLists.txt @@ -9,10 +9,12 @@ catkin_simple() set(HEADERS include/esim/common/types.hpp include/esim/common/utils.hpp + include/esim/common/hdr.hpp ) set(SOURCES src/utils.cpp + src/hdr.cpp ) cs_add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS}) diff --git a/event_camera_simulator/esim_common/include/esim/common/hdr.hpp b/event_camera_simulator/esim_common/include/esim/common/hdr.hpp new file mode 100644 index 0000000..6896b4b --- /dev/null +++ b/event_camera_simulator/esim_common/include/esim/common/hdr.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include + +extern std::string hdr_output_folder; diff --git a/event_camera_simulator/esim_common/src/hdr.cpp b/event_camera_simulator/esim_common/src/hdr.cpp new file mode 100644 index 0000000..8985386 --- /dev/null +++ b/event_camera_simulator/esim_common/src/hdr.cpp @@ -0,0 +1,9 @@ +#include "esim/common/hdr.hpp" + +DEFINE_string( + hdr_output_folder, + "/home/arno/sim_ws/out", + "Folder in which to output the events." +); + +std::string hdr_output_folder = FLAGS_hdr_output_folder; diff --git a/event_camera_simulator/esim_ros/cfg/from_folder.conf b/event_camera_simulator/esim_ros/cfg/from_folder.conf index 7ebb1ad..524d46b 100644 --- a/event_camera_simulator/esim_ros/cfg/from_folder.conf +++ b/event_camera_simulator/esim_ros/cfg/from_folder.conf @@ -2,6 +2,7 @@ --path_to_output_bag=/tmp/out.bag --path_to_data_folder=/tmp/tests/frames + --hdr_output_folder=/home/arno/sim_ws/out --ros_publisher_frame_rate=60 --exposure_time_ms=10.0 diff --git a/event_camera_simulator/esim_visualization/src/hdr_publisher.cpp b/event_camera_simulator/esim_visualization/src/hdr_publisher.cpp index 03f1538..79aa44a 100644 --- a/event_camera_simulator/esim_visualization/src/hdr_publisher.cpp +++ b/event_camera_simulator/esim_visualization/src/hdr_publisher.cpp @@ -1,9 +1,9 @@ #include "esim/common/types.hpp" #include "kindr/minimal/rotation-quaternion.h" +#include #include #include -#include #include #include #include @@ -12,12 +12,6 @@ #include #include -DEFINE_string( - hdr_output_folder, - "/home/arno/sim_ws/out", - "Folder in which to output the events." -); - namespace event_camera_simulator { /** @@ -80,13 +74,13 @@ namespace event_camera_simulator { } Publisher::Ptr HdrPublisher::createFromGflags() { - if (FLAGS_hdr_output_folder == "") { + if (hdr_output_folder == "") { LOG(WARNING) << "Empty output folder string: will not write " "hdr files"; return nullptr; } - return std::make_shared(FLAGS_hdr_output_folder); + return std::make_shared(hdr_output_folder); } HdrPublisher::~HdrPublisher() {