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.
- Install ROS2 Foxy and Rviz2
- Clone this repository to your ROS workspace
- Build this package
colcon build --packages-select rviz2_rotatable_image_plugin
Select this plugin in RViz2 (remember to source):
Original | 45° Rotation | 45° Rotation No Crop |
---|---|---|
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
.
This plugin would not have been possible if not for the contributions from the following (and contributions therein):
- lucasw's answer regarding wrapping Qt headers, with code
- Rotating image without crop in C++ OpenCV
- The people that contributed to OpenCV and
rviz_default_plugins::displays::Image
- Mah weekend