Quick conversion from depth images to PointCloud2 [closed]
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_info
topics 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++
.
Doesn't depth_image_proc/point_cloud_xyz do exactly this?
A similar question was asked in #q261758.
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)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.
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(..).
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)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!
There are a couple Q&As about nodelets specifically here on ROS Answers.
It might be informative to look them up.
Thank you!! As I considered it as answered, I'll close the topic