基础知识3:PCL中 copyPointCloud的使用

本文就自己在pcl中碰到过的copyPointCloud两种使用方法进行了总结:

Part 1:完全拷贝到新的点云之中:pcl::copyPointCloud (const pcl::PointCloud &cloud_in,pcl::PointCloud &cloud_out)

pcl::PointCloud<pcl::PointXYZ>::Ptr src(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointNormal>::Ptr src_PN(new pcl::PointCloud<pcl::PointNormal>);

pcl::io::loadPCDFile("src.pcd",*src);//载入原数据
pcl::io::loadPCDFile("src_pn.pcd", *src_PN);//载入原数据

pcl::copyPointCloud(*src, *src_PN);//src中的xyz覆盖掉src_PN中的xyz值,然后把xyz+normal的信息给src_PN

pcl::io::savePCDFile("src_with_normal.pcd", *src_PN);

运行结果:
src
src_pn
copyPointCloud后结果

Part 2:部分索引的使用:pcl::copyPointCloud (const pcl::PointCloud &cloud_in, const std::vector &indices,pcl::PointCloud &cloud_out)

pcl::PointCloud<pcl::PointXYZ>::Ptr src(new pcl::PointCloud<pcl::PointXYZ>);
pcl::io::loadPCDFile("src.pcd",*src);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudout(new pcl::PointCloud<pcl::PointXYZ>);
std::vector<int>indexs = { 0,2,6 };//索引
pcl::copyPointCloud(*src, indexs, *cloudout);
pcl::io::savePCDFile("cloud_out.pcd", *cloudout);//只取src中的第1,第3个,第7个点赋值到新的cloudout中。

程序输出结果:
cloudout

Part 3:其余的重载函数:PCL中还有很多,但是自己暂时未用到,见下图。后面用到了在补充。
这里写图片描述
具体详情可见:http://docs.pointclouds.org/1.8.1/group__common.html#gab99511f54b952b8a5608e4ed7f41a68d

  • 10
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值