diff --git a/.gitignore b/.gitignore index e347708b0..9d93f2973 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *pyc .vscode/settings.json +*/doc/generated diff --git a/depth_image_proc/doc/changes.rst b/depth_image_proc/doc/changes.rst new file mode 100644 index 000000000..852ee4122 --- /dev/null +++ b/depth_image_proc/doc/changes.rst @@ -0,0 +1,18 @@ +Changelog Notes +=============== + +Jazzy Jalisco +------------- +There are several major change between ``Iron`` and ``Jazzy``: + + * All components now properly support ``image_transport`` parameter, or + ``depth_image_transport`` if the topic is a depth image. + * All components now properly support remapping the ``camera_info`` topic + for an associated ``image`` topic. For instance, if you remap ``image`` + to ``my/image`` then ``my/camera_info`` will be used. Previously you + would have to manually remap the ``camera_info`` topic. + * The input of ``point_cloud_xyz_radial`` is renamed from ``image_raw`` + to ``depth/image_raw`` for consistency. + * The input of ``point_cloud_xyzrgb_radial`` is renamed from + ``depth_registered/image_rect`` to ``depth/image_raw`` and + ``rgb/image_rect_color`` to ``rgb/image_raw``. diff --git a/depth_image_proc/doc/components.rst b/depth_image_proc/doc/components.rst new file mode 100644 index 000000000..c0a783c60 --- /dev/null +++ b/depth_image_proc/doc/components.rst @@ -0,0 +1,301 @@ +Nodes and Components +==================== + +This package includes a number of ROS 2 components that can be assembled +into depth image processing pipelines. +See the tutorial :ref:`Launch depth_image_proc Components`. + +Alternatively, each component can be run as a standalone node. + +depth_image_proc::ConvertMetricNode +----------------------------------- +Component to convert raw uint16 depth image in millimeters to +float depth image in meters. +Also available as a standalone node with the name ``convert_metric_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **image_raw** (sensor_msgs/Image): ``uint16`` depth image in millimeters, + the native OpenNI format. + +Published Topics +^^^^^^^^^^^^^^^^ + * **image** (sensor_msgs/Image): ``float`` depth image in meters, the + recommended format for processing in ROS 2. + +Parameters +^^^^^^^^^^ + * **image_transport** (string, default: raw): Image transport to use. + +depth_image_proc::CropForemostNode +---------------------------------- +Takes a depth image and crops the closest element. The node will find the +minimum depth value in the image and then set all pixels farther than +``min + distance`` to 0. Also available as a standalone node +``crop_foremost_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **image_raw** (sensor_msgs/Image): Must be a depth (single channel) image. + +Published Topics +^^^^^^^^^^^^^^^^ + * **image** (sensor_msgs/Image): Cropped image. + +Parameters +^^^^^^^^^^ + * **distance** (float, default: 0.0): The depth tolerance to use when + thresholding the image. Pixels farther than ``min + distance`` will be + set to 0. + * **image_transport** (string, default: raw): Image transport to use. + +depth_image_proc::DisparityNode +------------------------------- +Converts a depth image to disparity image. Also available as a standalone +node ``disparity_node``. +The images below show the raw depth image, and the output disparity image. +The output disparity image is being colorized using the ``disparity_view`` +node from the ``image_view`` package. + +|depth| |disparity| + +.. |depth| image:: images/depth.png + :width: 49% + +.. |disparity| image:: images/disparity.png + :width: 49% + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **left/image_rect** (sensor_msgs/Image): Rectified depth image. + * **right/camera_info** (sensor_msgs/CameraInfo): Camera calibration and + metadata. Must contain the baseline, which conventionally is encoded in + the right camera P matrix. + +Published Topics +^^^^^^^^^^^^^^^^ + * **left/disparity** (stereo_msgs/DisparityImage): Disparity image + (inversely related to depth), for interop with stereo processing nodes. + For all other purposes use depth images instead. + +Parameters +^^^^^^^^^^ + * **delta_d** (double, default: 0.125): Smallest allowed disparity increment, + which relates to the achievable depth range resolution. Defaults to 1/8 pixel. + * **image_transport** (string, default: raw): Image transport to use. + * **min_range** (double, default: 0.0): Minimum detectable distance. + * **max_range** (double, default: +Inf): Maximum detectable distance. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyzNode +----------------------------------- +Converts a depth image to XYZ point cloud. Also available as a standalone +node ``point_cloud_xyz_node``. +The images below show the raw depth image, and the output point cloud, +colorized along the Z-axis. + +|depth| |cloud_xyz| + +.. |cloud_xyz| image:: images/rviz_xyz.png + :width: 49% + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **image_rect** (sensor_msgs/Image): Rectified depth image. + * **camera_info** (sensor_msgs/CameraInfo): Camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZ point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for the depth topic subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyzRadialNode +----------------------------------------- +Converts a radial depth image to an XYZ point cloud. Note that radial nodes +assume an unrectified radial image, and therefore use the K and D matrices +of the camera info message, rather than the P matrix. Also available as a +standalone node ``point_cloud_xyz_radial_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth/image_raw** (sensor_msgs/Image): Unrectified radial depth image. + * **depth/camera_info** (sensor_msgs/CameraInfo): Camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZ point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for the depth topic subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyziNode +------------------------------------ +Component to convert depth image to XYZI point cloud. Also available as a +standalone node ``point_cloud_xyzi_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth/image_rect** (sensor_msgs/Image): Rectified depth image. + * **intensity/image_rect** (sensor_msgs/Image): Rectified intensity image. + * **intensity/camera_info** (sensor_msgs/CameraInfo): Camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZ point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for the depth topic subscriber. + * **image_transport** (string, default: raw): Image transport to use for + the intensity image subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyziRadialNode +------------------------------------------ +Converts a radial depth image and an intensity image to an XYZI point cloud. +Note that radial nodes assume an unrectified radial image, and therefore +use the K and D matrices of the camera info message, rather than the P matrix. +Also available as a standalone node ``point_cloud_xyzi_radial_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth/image_raw** (sensor_msgs/Image): Unrectified radial depth image. + * **intensity/image_raw** (sensor_msgs/Image): Unrectified intensity image. + * **intensity/camera_info** (sensor_msgs/CameraInfo): Camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZI point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for the depth topic subscriber. + * **image_transport** (string, default: raw): Image transport to use for + the intensity image subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyzrgbNode +-------------------------------------- +Combines a registered depth image and an RGB image into XYZRGB point cloud. +Also available as a standalone node ``point_cloud_xyzrgb_node``. + +|depth_reg| |rgb| + +.. |depth_reg| image:: images/depth_reg.png + :width: 49% + +.. |rgb| image:: images/rgb.jpg + :width: 49% + +The node can convert the registered depth and rgb images (above) into a colorized +point cloud (below): + +|cloud_xyzrgb| + +.. |cloud_xyzrgb| image:: images/rviz_xyzrgb.png + :width: 60% + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth_registered/image_rect** (sensor_msgs/Image): Rectified depth image, + registered to the RGB camera + * **rgb/image_rect_color** (sensor_msgs/Image): Rectified color image. + * **rgb/camera_info** (sensor_msgs/CameraInfo): RGB camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZ point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for depth_registered subscriber. + * **image_transport** (string, default: raw): Image transport to use for + rgb/image_rect_color subscriber. + * **exact_sync** (bool, default: False): Whether to use exact synchronizer. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::PointCloudXyzrgbRadialNode +-------------------------------------------- +Converts a radial depth image and an rgb image to an XYZRGB point cloud. +Note that radial nodes assume an unrectified radial image, and therefore +use the K and D matrices of the camera info message, rather than the P matrix. +Also available as a standalone node ``point_cloud_xyzrgb_radial_node``. + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth/image_raw** (sensor_msgs/Image): Unrectified radial depth image. + * **rgb/image_raw** (sensor_msgs/Image): Unrectified rgb image. + * **rgb/camera_info** (sensor_msgs/CameraInfo): Camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **points** (sensor_msgs/PointCloud2): XYZRGB point cloud. If using PCL, + subscribe as PointCloud. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for the depth topic subscriber. + * **image_transport** (string, default: raw): Image transport to use for + the rgb image subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +depth_image_proc::RegisterNode +------------------------------ +Component to "register" a depth image to another camera frame. Reprojecting the +depths requires the calibration parameters of both cameras and, from tf, and the +extrinsic transform between them. The images below show the depth image before +and after apply registration: + +|depth| |depth_reg| + +Subscribed Topics +^^^^^^^^^^^^^^^^^ + * **depth/image_rect** (sensor_msgs/Image): Rectified depth image. The image should + be either 16UC1 (which is interpreted as millimeters) or 32FC1 (which is interpreted + as meters). + * **depth/camera_info** (sensor_msgs/CameraInfo): Depth camera calibration and metadata. + * **rgb/camera_info** (sensor_msgs/CameraInfo): RGB camera calibration and metadata. + +Published Topics +^^^^^^^^^^^^^^^^ + * **depth_registered/camera_info** (sensor_msgs/CameraInfo): Camera calibration and + metadata. Same as rgb/camera_info but time-synced to depth_registered/image_rect. + * **depth_registered/image_rect** (sensor_msgs/Image): Reprojected depth image in the + RGB camera frame. + +Parameters +^^^^^^^^^^ + * **depth_image_transport** (string, default: raw): Image transport to use + for depth subscriber. + * **queue_size** (int, default: 5): Size of message queue for synchronizing + subscribed topics. + +Required TF Transforms +^^^^^^^^^^^^^^^^^^^^^^ + * /depth_optical_frame → /rgb_optical_frame: The transform between the depth and + RGB camera optical frames as specified in the headers of the subscribed topics + (rendered here as /depth_optical_frame and /rgb_optical_frame). diff --git a/depth_image_proc/doc/conf.py b/depth_image_proc/doc/conf.py new file mode 100644 index 000000000..a69b4b083 --- /dev/null +++ b/depth_image_proc/doc/conf.py @@ -0,0 +1,194 @@ +# Copyright 2019 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'depth_image_proc' +copyright = '2008-2024, Open Source Robotics Foundation, Inc.' # noqa +author = 'Open Source Robotics Foundation, Inc.' + +# The short X.Y version +version = '' +# The full version, including alpha/beta/rc tags +release = '3.2.1' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', + 'sphinx_rtd_theme', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'depth_image_proc_doc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'depth_image_proc', 'depth_image_proc Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'depth_image_proc', 'depth_image_proc Documentation', + author, 'depth_image_proc', 'ROS 2 components for depth image processing.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + + +# -- Extension configuration ------------------------------------------------- + +autoclass_content = 'both' + +autodoc_default_options = { + 'members': True, # document members + 'undoc-members': True, # also document members without documentation +} diff --git a/depth_image_proc/doc/images/depth.png b/depth_image_proc/doc/images/depth.png new file mode 100644 index 000000000..fbb22d303 Binary files /dev/null and b/depth_image_proc/doc/images/depth.png differ diff --git a/depth_image_proc/doc/images/depth_reg.png b/depth_image_proc/doc/images/depth_reg.png new file mode 100644 index 000000000..7963a7c14 Binary files /dev/null and b/depth_image_proc/doc/images/depth_reg.png differ diff --git a/depth_image_proc/doc/images/disparity.png b/depth_image_proc/doc/images/disparity.png new file mode 100644 index 000000000..aea24d98e Binary files /dev/null and b/depth_image_proc/doc/images/disparity.png differ diff --git a/depth_image_proc/doc/images/rgb.jpg b/depth_image_proc/doc/images/rgb.jpg new file mode 100644 index 000000000..30c7c294a Binary files /dev/null and b/depth_image_proc/doc/images/rgb.jpg differ diff --git a/depth_image_proc/doc/images/rviz_xyz.png b/depth_image_proc/doc/images/rviz_xyz.png new file mode 100644 index 000000000..c7972ebd3 Binary files /dev/null and b/depth_image_proc/doc/images/rviz_xyz.png differ diff --git a/depth_image_proc/doc/images/rviz_xyzrgb.png b/depth_image_proc/doc/images/rviz_xyzrgb.png new file mode 100644 index 000000000..7dd970877 Binary files /dev/null and b/depth_image_proc/doc/images/rviz_xyzrgb.png differ diff --git a/depth_image_proc/doc/index.rst b/depth_image_proc/doc/index.rst new file mode 100644 index 000000000..dd83269cc --- /dev/null +++ b/depth_image_proc/doc/index.rst @@ -0,0 +1,40 @@ +depth_image_proc +================ + +``depth_image_proc`` provides basic processing for depth images, much as +``image_proc`` does for traditional 2D images. The two packages are +complementary; for example, you can (and should!) rectify your depth +image before converting it to a point cloud. + +A variety of camera technologies can produce depth images: + + * The Kinect and related devices + * Traditional stereo cameras + * Time-of-flight cameras + +See REP 118 for details on depth image representation. The REP recommends +that, wherever possible, producers and consumers of depth data use depth +images (of type sensor_msgs/Image) instead of sensor_msgs/DisparityImage. + +All ROS 2 components (besides ``ConvertMetricNode``) in this package support +both standard floating point depth images and OpenNI-specific uint16 depth +images. Thus when working with OpenNI cameras (e.g. the Kinect), you can +save a few CPU cycles by using the uint16 raw topics instead of the float +topics. + +For an example of ``depth_image_proc`` in practice, examine the contents of +``openni2_launch``. + +.. toctree:: + :maxdepth: 2 + + components + tutorials + changes + image_proc + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` diff --git a/depth_image_proc/doc/tutorials.rst b/depth_image_proc/doc/tutorials.rst new file mode 100644 index 000000000..f6f986f1c --- /dev/null +++ b/depth_image_proc/doc/tutorials.rst @@ -0,0 +1,77 @@ +Tutorials +========= + +.. _Launch depth_image_proc Components: + +Launching depth_image_proc Components +------------------------------------- +While each of the components is available as a ROS 2 node, the +recommended way to build pipelines is using the components as +this will save overhead by not having to serialize messages +between components. + +.. code-block:: python + + from launch import LaunchDescription + from launch_ros.actions import ComposableNodeContainer + from launch_ros.descriptions import ComposableNode + + def generate_launch_description(): + + container = ComposableNodeContainer( + name='depth_image_proc_container', + package='rclcpp_components', + executable='component_container', + composable_node_descriptions=[ + ComposableNode( + package='depth_image_proc', + plugin='depth_image_proc::PointCloudXyzrgbNode', + name='point_cloud_xyzrgb_node', + remappings=[ + ('rgb/image_rect_color', 'rgb/image'), + ('depth_registered/image_rect', 'depth_registered/image'), + ('points', 'depth_registered/points'), + ], + ), + ] + ) + + return LaunchDescription([container]) + +Using Compressed Image Transport +-------------------------------- +All of the components and nodes in ``depth_image_proc`` support +``image_transport``. This allows a subscriber to specify the transport to +be used. By default, this is ``raw``, which means an uncompressed +``sensor_msgs/Image``. When transmitting images over limited bandwidth +networks, such as WiFi, it can be helpful to use ``compressed`` format. + +For the depth images, use the ``depth_image_transport`` parameter. For +setting the transport for intensity or rgb images, the ``image_transport`` +parameter is used: + +.. code-block:: bash + + $ ros2 run depth_image_proc point_cloud_xyz_node --ros-args -p depth_image_transport:=compressed + +Remapping camera_info Topics +---------------------------- +When a ``camera_info`` topic is needed, an image_transport camera subscriber +is typically used. ROS 2 convention for naming ``camera_info`` topics is: + + * camera/image - an image in namespace ``camera``. + * camera/camera_info - the associated camera info + +So if a node subscribes to a topic called ``image``, and the user remaps this +to ``my_camera/image``, then the associated camera info will be automatically +remapped to ``mycamera/camera_info``. + +Most ROS 2 camera drivers will follow the convention, but occasionally they do +not. In this case, you will have to manually remap the camera_info - but due +to the way that ROS 2 remapping works you have to use the fully resolved +camera info topic. An example: + + * ``image`` is remapped to ``my_camera/image``. + * The fully resolved name for the camera info is now ``my_camera/camera_info``. + * If your camera driver actually publishes ``another_ns/camera_info``, then + you would have to remap ``my_camera/camera_info`` to ``another_ns/camera_info``. diff --git a/depth_image_proc/mainpage.dox b/depth_image_proc/mainpage.dox deleted file mode 100644 index 6b0414bd0..000000000 --- a/depth_image_proc/mainpage.dox +++ /dev/null @@ -1,26 +0,0 @@ -/** -\mainpage -\htmlinclude manifest.html - -\b depth_image_proc is ... - - - - -\section codeapi Code API - - - - -*/ diff --git a/depth_image_proc/src/register.cpp b/depth_image_proc/src/register.cpp index 8a44136ec..b6cde396f 100644 --- a/depth_image_proc/src/register.cpp +++ b/depth_image_proc/src/register.cpp @@ -100,7 +100,7 @@ RegisterNode::RegisterNode(const rclcpp::NodeOptions & options) : rclcpp::Node("RegisterNode", options) { // TransportHints does not actually declare the parameter - this->declare_parameter("image_transport", "raw"); + this->declare_parameter("depth_image_transport", "raw"); rclcpp::Clock::SharedPtr clock = this->get_clock(); tf_buffer_ = std::make_shared(clock); @@ -137,7 +137,7 @@ RegisterNode::RegisterNode(const rclcpp::NodeOptions & options) // fully expanded and remapped topic name to image_transport auto node_base = this->get_node_base_interface(); std::string topic = node_base->resolve_topic_or_service_name("depth/image_rect", false); - image_transport::TransportHints hints(this); + image_transport::TransportHints hints(this, "raw", "depth_image_transport"); sub_depth_image_.subscribe(this, topic, hints.getTransport()); sub_depth_info_.subscribe(this, "depth/camera_info"); sub_rgb_info_.subscribe(this, "rgb/camera_info"); diff --git a/image_proc/doc/images/left_raw.png b/image_proc/doc/images/left_raw.png new file mode 100644 index 000000000..0e8b2af64 Binary files /dev/null and b/image_proc/doc/images/left_raw.png differ diff --git a/image_proc/doc/images/left_rect_color.png b/image_proc/doc/images/left_rect_color.png new file mode 100644 index 000000000..e41bedd45 Binary files /dev/null and b/image_proc/doc/images/left_rect_color.png differ diff --git a/image_proc/doc/index.rst b/image_proc/doc/index.rst index 77507e340..139100e77 100644 --- a/image_proc/doc/index.rst +++ b/image_proc/doc/index.rst @@ -3,6 +3,21 @@ image_proc This package contains a number of ROS 2 components and nodes for image processing. +An example of what ``image_proc`` components can do is taking an original +camera image, which is Bayered and distorted, and transforming it into a +rectified image, de-Bayered and undistorted (amount of black border may +vary depending on calibration): + +|raw| |color| + +.. |raw| image:: images/left_raw.png + :width: 49% + +.. |color| image:: images/left_rect_color.png + :width: 49% + +The images above were produced using the tutorial :ref:`Using image_proc Launch File`. + .. toctree:: :maxdepth: 2 diff --git a/image_proc/doc/tutorials.rst b/image_proc/doc/tutorials.rst index 8708b0d0b..b787c6ce9 100644 --- a/image_proc/doc/tutorials.rst +++ b/image_proc/doc/tutorials.rst @@ -59,6 +59,42 @@ The example below creates two composable nodes: return LaunchDescription([container]) +Using Compressed Image Transport +-------------------------------- +All of the components and nodes in ``image_proc`` support ``image_transport``. +This allows a subscriber to specify the transport to +be used. By default, this is ``raw``, which means an uncompressed +``sensor_msgs/Image``. When transmitting images over limited bandwidth +networks, such as WiFi, it can be helpful to use ``compressed`` format. + +.. code-block:: bash + + $ ros2 run image_proc rectify_node --ros-args -p image_transport:=compressed + +Remapping camera_info Topics +---------------------------- +When a ``camera_info`` topic is needed, an image_transport camera subscriber +is typically used. ROS 2 convention for naming ``camera_info`` topics is: + + * camera/image - an image in namespace ``camera``. + * camera/camera_info - the associated camera info + +So if a node subscribes to a topic called ``image``, and the user remaps this +to ``my_camera/image``, then the associated camera info will be automatically +remapped to ``mycamera/camera_info``. + +Most ROS 2 camera drivers will follow the convention, but occasionally they do +not. In this case, you will have to manually remap the camera_info - but due +to the way that ROS 2 remapping works you have to use the fully resolved +camera info topic. An example: + + * ``image`` is remapped to ``my_camera/image``. + * The fully resolved name for the camera info is now ``my_camera/camera_info``. + * If your camera driver actually publishes ``another_ns/camera_info``, then + you would have to remap ``my_camera/camera_info`` to ``another_ns/camera_info``. + +.. _Using image_proc Launch File: + Using image_proc Launch File ---------------------------- Make sure your camera driver is running. To see the available raw