Quick conversion from depth images to PointCloud2 [closed]

asked 2021-06-01 05:03:15 -0500

drodgu gravatar image

Hi everyone,

I'm developing a vision algorithm based in PointCloud. After an intensive search through the internet, I couldn't found any quick and handy way to transform the information from depth images in ROS to PointCloud2 messages. I'm developing my algorithm in OpenCV to filter out of the scene everything I do not need. My code uses the camera_infotopics to obtain camera extrinsics parameters and process the position of each of the points to generate a cloud. It works great, but I'm just wondering if there's any quick method/class which already implements this transformation automatically, which could make it more efficient than my code.

I'm developing my algorithm in ROS Melodic using C++.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by drodgu
close date 2021-06-01 08:10:52.148077

Comments

After an intensive search through the internet, I couldn't found any quick and handy way to transform the information from depth images in ROS to PointCloud2 messages

Doesn't depth_image_proc/point_cloud_xyz do exactly this?

A similar question was asked in #q261758.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-01 07:10:30 -0500 )edit

In fact, it does so, and I knew the package. But I was looking if there's an already developed API for its direct use while coding in C++ instead of a nodelet which uses another middlenode to publish the point cloud (which is how I think that this nodelet works)

drodgu gravatar image drodgu  ( 2021-06-01 07:23:42 -0500 )edit

In fact, it does so, and I knew the package.

it would have been good to mention that fact. Your current question reads as-if you didn't find it, even after an extensive search.

But I was looking if there's an already developed API for its direct use while coding in C++ instead of a nodelet which uses another middlenode to publish the point cloud (which is how I think that this nodelet works)

I'm not sure I understand what you mean by this, but in the end it's all just C++.

The convert(..) template function is responsible for conversion. You should be able to reuse it.

It's used by PointCloudXyzNodelet::depthCb(..).

gvdhoorn gravatar image gvdhoorn  ( 2021-06-01 07:31:08 -0500 )edit
1

But I was looking if there's an already developed API for its direct use while coding in C++ instead of a nodelet which uses another middlenode to publish the point cloud (which is how I think that this nodelet works)

do you perhaps mean you believe you have to write a separate node to subscribe to the pointcloud?

That's not how nodelets work.

If you'd implement your own algorithm as a nodelet, you'd be able to consume the result of the conversion by simply subscribe(..)ing to the output topic the conversion nodelet, and it would be delivered to you zero-copy, as a pointer-to-the-msg.

(this also requires the node (driver?) producing the depth images to be a nodelet, and be hosted by the same nodelet_manager, which may not be true)

gvdhoorn gravatar image gvdhoorn  ( 2021-06-01 07:32:59 -0500 )edit

First of all, I'm sorry for not commenting the fact before. But with you last answer, I see that I've totally missundertood how a nodelet works. But now it seems clear to me. It also seems that is exactly what I need. I'm not sure on how to apply it, yet, but your answers were really inspiring. Thank you so much @gvdhoorn!

drodgu gravatar image drodgu  ( 2021-06-01 07:53:49 -0500 )edit

There are a couple Q&As about nodelets specifically here on ROS Answers.

It might be informative to look them up.

gvdhoorn gravatar image gvdhoorn  ( 2021-06-01 08:06:04 -0500 )edit

Thank you!! As I considered it as answered, I'll close the topic

drodgu gravatar image drodgu  ( 2021-06-01 08:10:15 -0500 )edit