Ros2 : how to process stereo images (stereo_image_proc?)

asked 2022-05-12 11:07:16 -0500

felixn gravatar image

Hi,

I'm trying to do the basic stereo image preprocessing in ROS2 : undistorting the images and doing rectification (and if possible go to monocrom in the process). Afterwards, I'm planing to process the undistorted-rectified-monochrome image pairs in opencv (nb : if need be, I can start with image colors and pass to monochrome in opencv)

If I'm not mistaken, in ROS1, this could be easely done with the stereo_image_proc package.

But how to do so in ROS2? I have seen that there is still a stereo_image_proc package in ROS2, but I haven't found any documentation/tutorials/examples yet.

Is this package ready to use yet? If so, do you have any ressources on how to use it? Or can you suggest any better alternative (if needed, I can update to galactic or rolling)?

What I have tried so far :

So far, I have the sensor_msgs/Image and the sensor_msgs/CameraInfo for left and right from an old (ie ROS1) bag file read with:

ros2 bag play -s rosbag_v2 ./pyramide2_indexed.bag

when doing a rostopic list, I get (restricted to relevant topics) :

$ ros2 topic list -t
/stereo/left/camera_info [sensor_msgs/msg/CameraInfo]
/stereo/left/image_raw [sensor_msgs/msg/Image]
/stereo/right/camera_info [sensor_msgs/msg/CameraInfo]
/stereo/right/image_raw [sensor_msgs/msg/Image]

then I try to launch the stereo_image_proc inspiring myself from http://wiki.ros.org/stereo_image_proc... :

$ ROS_NAMESPACE=stereo ros2  run stereo_image_proc disparity_node

NB : the stereo_image_proc node seems to have disappeared, so I try with disparity_node (and with point_cloud_node), the only two nodes available. I also tried by removing "ROS_NAMESPACE=stereo".

When I then run rostopic list again, I get (limited to relevant topics) :

ros2 topic list -t
/disparity [stereo_msgs/msg/DisparityImage]
/imu/data [sensor_msgs/msg/Imu]
/imu/mag [sensor_msgs/msg/MagneticField]
/left/camera_info [sensor_msgs/msg/CameraInfo]
/left/image_rect [sensor_msgs/msg/Image]
/parameter_events [rcl_interfaces/msg/ParameterEvent]
/right/camera_info [sensor_msgs/msg/CameraInfo]
/right/image_rect [sensor_msgs/msg/Image]
/rosout [rcl_interfaces/msg/Log]
/stereo/left/camera_info [sensor_msgs/msg/CameraInfo]
/stereo/left/image_raw [sensor_msgs/msg/Image]
/stereo/right/camera_info [sensor_msgs/msg/CameraInfo]
/stereo/right/image_raw [sensor_msgs/msg/Image]

However, when I try to run image_view (or rostopic hz) on any of the resulting images/topics, I get no result (and I would expect the resulting topics to be in /stereo/*).

So I'm using it wrong?

Or should I use a core node ("stereo_image_proc") that is not yet ported to foxy? Or might it be a problem with using messages coming from a ros1 bag?

Do you have any alternatives to suggest to do the stereo processing?

If it helps, I can upgrade to galactic or to rolling (I was planning to wait for 2 more weeks to install Humble when it is released, but I can already update if it helps)

EDIT :

after more digging arround,it seems that in ROS1, there was an "stereo_image_proc" node in stereo_image_proc package that did what I wanted (at least the undistortion part, I'm not 100% sure about the stereo rectification part), but this node has ... (more)

edit retag flag offensive close merge delete