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
6 changes: 3 additions & 3 deletions image_view/doc/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 Down Expand Up @@ -74,7 +74,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 +93,7 @@ Services
Parameters
----------
* **encoding** (string, default:"bgr8"): Encoding type of input image topic.
* **filename_format** (string, default: "left%04i.jpg"): File name for
* **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
1 change: 1 addition & 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;
double fps_;
bool stamped_filename_;
bool save_all_image_{false};
bool save_image_service_{false};
Expand Down
4 changes: 3 additions & 1 deletion image_view/src/image_saver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ ImageSaverNode::ImageSaverNode(const rclcpp::NodeOptions & options)
&ImageSaverNode::callbackWithoutCameraInfo, this, std::placeholders::_1),
hints.getTransport());

g_format = this->declare_parameter("filename_format", std::string("left%04i.%s"));
g_format = this->declare_parameter("filename_format", std::string("frame%04i.%s"));
fps_ = this->declare_parameter("fps", 0.1);
mikeferguson marked this conversation as resolved.
Show resolved Hide resolved
encoding_ = this->declare_parameter("encoding", std::string("bgr8"));
save_all_image_ = this->declare_parameter("save_all_image", true);
stamped_filename_ = this->declare_parameter("stamped_filename", false);
Expand Down Expand Up @@ -125,6 +126,7 @@ bool ImageSaverNode::saveImage(
{
cv::Mat image;
try {
encoding_ = image_msg->encoding;
image = cv_bridge::toCvShare(image_msg, encoding_)->image;
mikeferguson marked this conversation as resolved.
Show resolved Hide resolved
} catch (const cv_bridge::Exception &) {
RCLCPP_ERROR(
Expand Down
Loading