Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Merging: Setting up ImageSaverNode #944

Open
wants to merge 12 commits into
base: rolling
Choose a base branch
from
Open
12 changes: 0 additions & 12 deletions image_view/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ endif()

ament_auto_add_library(${PROJECT_NAME}_nodes SHARED
src/disparity_view_node.cpp
src/extract_images_node.cpp
src/image_view_node.cpp
src/image_saver_node.cpp
src/stereo_view_node.cpp
Expand All @@ -35,7 +34,6 @@ target_compile_definitions(${PROJECT_NAME}_nodes
)
rclcpp_components_register_nodes(${PROJECT_NAME}_nodes
"${PROJECT_NAME}::DisparityViewNode"
"${PROJECT_NAME}::ExtractImagesNode"
"${PROJECT_NAME}::ImageViewNode"
"${PROJECT_NAME}::ImageSaverNode"
"${PROJECT_NAME}::StereoViewNode"
Expand Down Expand Up @@ -74,16 +72,6 @@ add_dependencies(stereo_view
)

# Other Tools
ament_auto_add_executable(extract_images
src/extract_images.cpp
)
target_link_libraries(extract_images
${PROJECT_NAME}_nodes
)
add_dependencies(extract_images
${PROJECT_NAME}_nodes
)

ament_auto_add_executable(image_saver
src/image_saver.cpp
)
Expand Down
34 changes: 3 additions & 31 deletions image_view/doc/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,6 @@ Parameters
* **window_name** (string, default: name of the image topic):
The name of the display window.

image_view::ExtractImagesNode
-----------------------------
This tool also allows you to save images as jpg/png file from
streaming (ROS sensor_msgs/Image topic) to a file.
``image_saver`` node provide very similar functionalities,
such as providing service call to trigger the node to save
images, save images other than JPEG format, etc.

This tool allows you to save images as jpg/png file from streaming
(ROS sensor_msgs/Image topic) to a file. From command line, you
can run with:

.. code-block:: bash

ros2 run image_view image_saver --ros-args -r image:=[your topic]

or see this answer to control the timing of capture.

Subscribed Topics
^^^^^^^^^^^^^^^^^
* **image** (sensor_msgs/Image): Image topic to visualize.

Parameters
----------
* **filename_format** (string, default: "frame%04i.jpg"): File name for
saved images, you must add use '%04i' for sequence number.
* **image_transport** (string, default: raw): Image transport to use.
* **sec_per_frame** (double, default: 0.1): Seconds between saved frames.

image_view::ImageViewNode
-------------------------
Simple image viewer for ROS sensor_msgs/Image topics. Node name
Expand Down Expand Up @@ -74,7 +45,7 @@ This tool allows you to save images as jpg/png file from streaming
can run with:

.. code-block:: bash

ros2 run image_view image_saver --ros-args -r image:=[your topic]

or see this answer to control the timing of capture.
Expand All @@ -93,7 +64,8 @@ Services
Parameters
----------
* **encoding** (string, default:"bgr8"): Encoding type of input image topic.
* **filename_format** (string, default: "left%04i.jpg"): File name for
* **fps** (int, default:"0"): Seconds between saved frames.
* **filename_format** (string, default: "frame%04i.jpg"): File name for
saved images, you can use '%04i' for sequence number, and '%s' for default
file format, you can use 'jpg' ,'png', 'pgm' as filename suffixes.
* **image_transport** (string, default: raw): Image transport to use.
Expand Down
85 changes: 0 additions & 85 deletions image_view/include/image_view/extract_images_node.hpp

This file was deleted.

5 changes: 5 additions & 0 deletions image_view/include/image_view/image_saver_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ImageSaverNode

private:
std::string g_format;
int fps_;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave fps_ as an int since there's no weird math similar to what was happening in secs_per_frame, right?

bool stamped_filename_;
bool save_all_image_{false};
bool save_image_service_{false};
Expand All @@ -76,6 +77,9 @@ class ImageSaverNode
bool is_first_image_{true};
bool has_camera_info_{false};
size_t count_{0u};
sensor_msgs::msg::Image::ConstSharedPtr latest_image_;
std::mutex image_save_mutex_;
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Time start_time_;
rclcpp::Time end_time_;
image_transport::CameraSubscriber cam_sub_;
Expand All @@ -84,6 +88,7 @@ class ImageSaverNode
rclcpp::Service<std_srvs::srv::Trigger>::SharedPtr start_srv_;
rclcpp::Service<std_srvs::srv::Trigger>::SharedPtr end_srv_;

void timerCallback();
bool saveImage(const sensor_msgs::msg::Image::ConstSharedPtr & image_msg, std::string & filename);
bool service(
const std::shared_ptr<rmw_request_id_t> request_header,
Expand Down
67 changes: 0 additions & 67 deletions image_view/src/extract_images.cpp

This file was deleted.

Loading