Skip to content

Commit

Permalink
Initial Merging: Setting up ImageSaverNode
Browse files Browse the repository at this point in the history
Signed-off-by: CursedRock17 <mtglucas1@gmail.com>
  • Loading branch information
CursedRock17 committed Feb 18, 2024
1 parent 14f604a commit 4534c95
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
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);
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;
} catch (const cv_bridge::Exception &) {
RCLCPP_ERROR(
Expand Down

0 comments on commit 4534c95

Please sign in to comment.