Ask Your Question
0

Publishing CV2 image message in ROS2 rclpy

asked 2019-05-19 16:05:40 -0600

John Doenut gravatar image

I have an image matrix in python3 CV2, which is actually just a numpy ndarray message in the shape of (width, height, rgb channels) that I want to publish as a message. In ROS1, there are standard message such as Image, compressed image and even variable arrays that can accomplish this. There are some example like ros2/demo git that shows cam2img but this is for cpp rclcpp. This seems like the simplest example but I cannot find any example, documentation on sending images in ROS2 python3 rclpy environment. I was actually able to turn the entire array into string and send it but this is nasty and the parsing done are unnecessary. How can I send three dimensional ndarray in rclpy in a "clean" fashion?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-05-20 11:12:29 -0600

Dirk Thomas gravatar image

As of the upcoming Dashing release the field in the Python messages will use numpy.ndarray to store image arrays of numeric values. That should avoid the conversion between your data and strings (as it was necessary in Crystal and earlier).

The draft of the Dashing release page mentions this change: https://index.ros.org/doc/ros2/Releas...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-05-19 16:05:40 -0600

Seen: 145 times

Last updated: May 20 '19