Ros点云格式转换总结

Ros点云格式转换总结

三种格式:

sensor_msgs::PointCloud
sensor_msgs::PointCloud2
pcl::PointCloud<T>

其中,PointCloud2和pcl::PointCloud可以相互转换,PointCloud和PointCloud2可以相互转换,PointCloud和pcl::PointCloud的转换需要使用PointCloud2中转。

PointCloud⟺PointCloud2⟺pcl::PointCloud<T>PointCloud \Longleftrightarrow PointCloud2 \Longleftrightarrow pcl::PointCloud<T>PointCloudPointCloud2pcl::PointCloud<T>

PointCloud2 to PointCloud

#include "sensor_msgs/point_cloud_conversion.h"
static inline bool convertPointCloud2ToPointCloud (
		const sensor_msgs::PointCloud2 &input, sensor_msgs::PointCloud &output);

PointCloud to PointCloud2

#include "sensor_msgs/point_cloud_conversion.h"
static inline bool convertPointCloudToPointCloud2 (
		const sensor_msgs::PointCloud &input, sensor_msgs::PointCloud2 &output)

pcl::PointCloud< T > to PointCloud2

#include "pcl_conversions/pcl_conversions.h"
template<typename T>
  void toROSMsg(const pcl::PointCloud<T> &pcl_cloud, sensor_msgs::PointCloud2 &cloud)
  {
    pcl::PCLPointCloud2 pcl_pc2;
    pcl::toPCLPointCloud2(pcl_cloud, pcl_pc2);
    pcl_conversions::moveFromPCL(pcl_pc2, cloud);
  }

PointCloud2 to pcl::PointCloud< T >

#include "pcl_conversions/pcl_conversions.h"
  template<typename T>
  void fromROSMsg(const sensor_msgs::PointCloud2 &cloud, pcl::PointCloud<T> &pcl_cloud)
  {
    pcl::PCLPointCloud2 pcl_pc2;
    pcl_conversions::toPCL(cloud, pcl_pc2);
    pcl::fromPCLPointCloud2(pcl_pc2, pcl_cloud);
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值