isaac_ros_dnn_image_encoder #
Source code available on GitHub.
Note
This package is launch-only. We recommend including only the preprocessing nodes required by your application.
Examples are available in the Isaac ROS RT-DETR launch files.
For convenience, dnn_image_encoder.launch.py combines the nodes commonly used in an image-preprocessing
pipeline.
Using the Launch Graph#
dnn_image_encoder.launch.py represents a typical sequence of image-preprocessing operations used by many vision
networks. For example, one model may require resizing and normalization, whereas another may require only resizing.
This tutorial shows how to include the launch graph in your own launch description.
Import the
launchlibraries required to includednn_image_encoder.launch.py:from ament_index_python.packages import get_package_share_directory from launch.actions import IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSourceInclude the launch graph and configure its inputs, output, namespace, and component-container behavior:
encoder_dir = get_package_share_directory('isaac_ros_dnn_image_encoder') encoder_launch = IncludeLaunchDescription( PythonLaunchDescriptionSource( [os.path.join(encoder_dir, 'launch', 'dnn_image_encoder.launch.py')] ), launch_arguments={ 'input_image_width': input_image_width, 'input_image_height': input_image_height, 'network_image_width': network_image_width, 'network_image_height': network_image_height, 'image_mean': encoder_image_mean, 'image_stddev': encoder_image_stddev, 'attach_to_shared_component_container': 'True', 'component_container_name': 'my_container', 'dnn_image_encoder_namespace': 'my_encoder_namespace', 'image_input_topic': '/image', 'camera_info_input_topic': '/camera_info', 'tensor_output_topic': '/tensor_pub', }.items(), )The leading
/in each topic name ensures that the topic is not part of the configured namespace. This example attaches the graph to a shared component container namedmy_container. Pass the container’s global name tocomponent_container_name; otherwise, the launch will silently fail.
Add the included launch description to your launch description:
final_launch_container = launch_args + [rclcpp_container, encoder_launch] return LaunchDescription(final_launch_container)
Note
The launch graph expects to subscribe to a CameraInfo topic in addition to an Image topic.
API#
dnn_image_encoder.launch.py#
Launch Arguments#
Launch Argument |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
The input image width. |
|
|
|
The input image height. |
|
|
|
The image width that the network expects. This will be used to crop the input |
|
|
|
The image height that the network expects. This will be used to crop the input |
|
|
|
The mean of the images per channel that will be used for normalization. |
|
|
|
The standard deviation of the images per channel that will be used for normalization. |
|
|
|
The number of pre-allocated GPU memory blocks |
|
|
|
Whether to enable padding or not |
|
|
|
Whether to maintain the aspect ratio or not while resizing |
|
|
|
The crop mode to crop the image using |
|
|
|
The tensor image encoding. |
|
|
|
The desired input image encoding. |
|
|
|
The tensor name of the output of the image encoder. |
|
|
|
Alias for |
|
|
|
The namespace to launch the DNN image encoder under |
Launch Configuration Arguments#
Launch Configuration |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
The input image topic that the encoder will subscribe to. By default, this will
be under the |
|
|
|
The input camera_info topic that the encoder will subscribe to. By default, this will
be under the |
|
|
|
The output tensor topic that the encoder will publish to. By default, this will
be under the |
|
|
|
Whether to attach to an existing shared container or not |
|
|
|
If |