0
$\begingroup$

Rosanswers logo

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?


Originally posted by John Doenut on ROS Answers with karma: 13 on 2019-05-19

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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/Releases/Release-Dashing-Diademata/#rosidl-generator-py


Originally posted by Dirk Thomas with karma: 16276 on 2019-05-20

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.