LKSeng / rviz_rotatable_image_plugin

RViz plugin to rotate sensor_msgs::Image for visualisation purposes.
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link
ros ros-noetic rviz-plugin rviz-plugins

rviz_rotatable_image_plugin

RViz plugin to rotate sensor_msgs::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 RViz with the regular image display plugin.

This plugin works by taking the sensor_msgs::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::Image for rendering.

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

Installation

  1. Clone this repository to your ROS workspace
  2. Build this package
    catkin build rviz_rotatable_image_plugin

Usage

Select this plugin in RViz.

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

Check if this plugin is installed properly (remember to source the workspace this plugin is in first):

rospack plugins --attrib=plugin rviz

You should see something like:

rviz_rotatable_image_plugin /home/user/catkin_ws/src/rviz_rotatable_image_plugin/plugin_description.xml
rviz /opt/ros/noetic/share/rviz/plugin_description.xml

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::DisplayImage
  4. Mah weekend