Convert sensor_msgs::PointCloud2ConstPtr to pcl::PointCloud<pcl::PointXYZ>
I am trying to apply a segmentation model to a point cloud. The models on PCL expect a pcl::PointCloud<pcl::PointXYZ>
, I have tried to converting the messages by using the functions suggested in other threads but it wont compile:
int segment_obstacles(const sensor_msgs::PointCloud2ConstPtr& input)
{
pcl::PointCloud<pcl::PointXYZ> cloud (new pcl::PointCloud<pcl::PointXYZ>());
// pcl::fromPCLPointCloud2(*input, *cloud);
pcl::fromROSMsg(*input, *cloud);
I tried both functions. What would be the right way to convert the message point cloud?
I use the same algorithm you are using.
The only difference i see is when you declare a pcl::pointcloud (I have it declared as a pointer). so, your third line should be :
Actually for me makes sense due to the fact that "new" if i am not wrong is used for pointers.
Hope it helps!
Thank you very much, that solved the compilation error.