点云学习3:两个点云连接

#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/point_types.h>
int main(int argc,char** argv)
{
 //定义了cloud_a cloud_b cloud_c三个对象
 pcl::PointCloud<pcl::PointXYZ> cloud_a, cloud_b, cloud_c;
 pcl::PointCloud<pcl::Normal> n_cloud_b;
 pcl::PointCloud<pcl::PointNormal> p_n_cloud_c;
 cloud_a.width = 5;
 cloud_a.height = cloud_b.height = n_cloud_b.height = 1;
 cloud_a.points.resize(cloud_a.width*cloud_a.height);
 cloud_b.width = 3;
 cloud_b.points.resize(cloud_b.width*cloud_b.height);
 for (size_t i = 0; i < cloud_a.points.size(); ++i)
 {
  cloud_a.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
  cloud_a.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
  cloud_a.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
 }
 for (size_t i = 0; i < cloud_b.points.size(); ++i)
 {
  cloud_b.points[i].x = 1024 * rand() / (RAND_MAX + 1.0f);
  cloud_b.points[i].y = 1024 * rand() / (RAND_MAX + 1.0f);
  cloud_b.points[i].z = 1024 * rand() / (RAND_MAX + 1.0f);
 }
 std::cerr << "Cloud A: " << std::endl;
 for (size_t i = 0; i < cloud_a.points.size(); ++i)
  std::cerr << "    " << cloud_a.points[i].x << " " << cloud_a.points[i].y << " " << cloud_a.points[i].z << std::endl;
 std::cerr << "Cloud B: " << std::endl;
 for (size_t i = 0; i < cloud_b.points.size(); ++i)
   std::cerr << "    " << cloud_b.points[i].x << " " << cloud_b.points[i].y << " " << cloud_b.points[i].z << std::endl;
 //拷贝点云数据
 cloud_c = cloud_a;
 cloud_c += cloud_b;
 std::cerr << "Cloud C: " << std::endl;
  for (size_t i = 0; i < cloud_c.points.size(); ++i)
   std::cerr << "    " << cloud_c.points[i].x << " " << cloud_c.points[i].y << " " << cloud_c.points[i].z << " " << std::endl;
 system("pause");
 return(0);
}

在上面学习的基础上,首先生成了两个随机的点云,需要注意的是进行连接的点云的数据格式得是一样的
所谓的“连接”,就像是字符串直接相加就可以了

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值