PCL复制点云

可以不同类型,但是目标点云必须含有源点云的字段。
代码如下:

// STL
#include <iostream>

// PCL
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/common/io.h>

static void
sameType ();

static void
differenceType ();

// We show this function as an example of what you cannot do.
// static void
// badConversion ();

int
main ()
{
  sameType();
  differenceType();
  // badConversion();
  return 0;
}

void
sameType ()
{
  typedef pcl::PointCloud<pcl::PointXYZ> CloudType;
  CloudType::Ptr cloud (new CloudType);

  CloudType::PointType p;
  p.x = 1; p.y = 2; p.z = 3;
  cloud->push_back(p);
  std::cout << p.x << " " << p.y << " " << p.z << std::endl;

  CloudType::Ptr cloud2(new CloudType);
  copyPointCloud(*cloud, *cloud2);

  CloudType::PointType p_retrieved = cloud2->points[0];
  std::cout << p_retrieved.x << " " << p_retrieved.y << " " << p_retrieved.z << std::endl;
}

void
differenceType ()
{
  typedef pcl::PointCloud<pcl::PointXYZ> CloudType;
  CloudType::Ptr cloud (new CloudType);

  CloudType::PointType p;
  p.x = 1; p.y = 2; p.z = 3;
  cloud->push_back(p);
  std::cout << p.x << " " << p.y << " " << p.z << std::endl;

  typedef pcl::PointCloud<pcl::PointNormal> CloudType2;
  CloudType2::Ptr cloud2(new CloudType2);
  copyPointCloud(*cloud, *cloud2);

  CloudType2::PointType p_retrieved = cloud2->points[0];
  std::cout << p_retrieved.x << " " << p_retrieved.y << " " << p_retrieved.z << std::endl;
}

来源:PCL官方示例

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值