/rviz2_rotatable_image_plugin

RViz2 plugin to rotate sensor_msgs::msg::Image for visualisation purposes.

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

rviz2_rotatable_image_plugin

RViz2 plugin to rotate sensor_msgs::msg::Image for visualisation purposes in-situ, especially so if camera is mounted at an angle. For avoidance of doubt, note that this plugin does not publish the rotated image.

Alternative topologies include launching an image_rotate node to rotate and publish the rotated image, and then subscribing said rotated image topic on RViz2 with the regular image display plugin.

This plugin works by taking the sensor_msgs::msg::Image before it is rendered, converting it to cv::Mat if rotation is needed for OpenCV to perform the rotation, and converting the rotated image back to sensor_msgs::msg::Image for rendering.

This plugin was created for ROS2 Foxy, on Ubuntu-20.04. For the ROS version of this node, check out rviz_rotatable_image_plugin.

Installation

  1. Install ROS2 Foxy and Rviz2
  2. Clone this repository to your ROS workspace
  3. Build this package
    colcon build --packages-select rviz2_rotatable_image_plugin

Usage

Select this plugin in RViz2 (remember to source):

rviz_rotatable_image_plugin in RViz

Examples

Original 45° Rotation 45° Rotation No Crop
Plugin with no rotation Plugin with rotation Plugin with rotation without crop

Debugging

You may encounter issues like rviz2_rotatable_image_plugin: Cannot locate rosdep definition for [rviz_default_plugins] during rosdep or "rviz_common" provides a separate development package or SDK, be sure it has been installed during build. This can be resolved by using rosdep update --include-eol-distros followed by rebuilding this plugin with colcon build.

Acknowledgments

This plugin would not have been possible if not for the contributions from the following (and contributions therein):

  1. lucasw's answer regarding wrapping Qt headers, with code
  2. Rotating image without crop in C++ OpenCV
  3. The people that contributed to OpenCV and rviz_default_plugins::displays::Image
  4. Mah weekend