Skip to content

Commit

Permalink
ROS 2: Add option to prepend timestamp to image filename in image_sav…
Browse files Browse the repository at this point in the history
…er node (ros-perception#870)

Related to this PR in ROS 1
https://github.com/ros-perception/image_pipeline/pull/806/files

---------

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde authored and Krzysztof Wojciechowski committed May 27, 2024
1 parent 682fe00 commit af071fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions image_view/src/image_saver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ bool ImageSaverNode::saveImage(
}

if (save_all_image_ || save_image_service_) {
if (stamped_filename_) {
std::stringstream ss;
ss << this->now().nanoseconds();
std::string timestamp_str = ss.str();
filename.insert(0, timestamp_str);
}

if (cv::imwrite(filename, image)) {
RCLCPP_INFO(this->get_logger(), "Saved image %s", filename.c_str());
} else {
Expand Down

0 comments on commit af071fe

Please sign in to comment.