PCL(常用api)

这个博客持续更新啦---------------------------------

另外多参考这个博主的内容:https://www.cnblogs.com/flyinggod/p/9478000.html(写的很好啦)

1.找到目标点云中x,y,z中得最值,以及对应得索引;

		subset1_maxz = cloud_subset1->points[0].z;
		subset2_maxz = cloud_subset2->points[0].z;
		index_maxz1 = 0;
		index_maxz2 = 0;			

for (int l = 0; l < cloud_subset1->points.size(); l++)
		{
			if (subset1_maxz< cloud_subset1->points[l].z)
			{
				subset1_maxz = cloud_subset1->points[l].z;
				index_maxz1 = l;
			}
		}
		cloud_topboundary->push_back(cloud_subset1->points[index_maxz1]);
		

2.还有一种调用api的,但是好像没有返回索引的

	pcl::getMinMax3D(*cloud_final, min, max);
	cout << min.y << endl;
	cout << max.y << endl;

3.获得已知某一点(你想要的,例如点云平面的中心点)的索引的方法

(注意这里不初始化点云,直接赋值会报错)

		   pcl::PointXY dian;	
		   dian.x = (min.x+max.x) / 2;
		   dian.y = (min.y+max.y) / 2;

		   int index;
		   /*报错 原因估计是没有初始化 kk 结构*/
		   pcl::PointCloud<pcl::PointXY>::Ptr kk(new pcl::PointCloud<pcl::PointXY>);
		   kk->resize(cloud_cluster->points.size());
		   for (size_t i = 0; i < cloud_cluster->points.size(); i++)
		   {
			  
			   kk->points[i].x= cloud_cluster->points[i].x;
			   kk->points[i].y = cloud_cluster->points[i].y;

		   }
		   //找到索引啦
		   for (size_t i = 0; i < cloud_cluster->points.size(); i++)
		   {
			   float juli;
			   juli= pcl::squaredEuclideanDistance(dian, kk->points[0]);
			   if (juli < pcl::squaredEuclideanDistance(dian, kk->points[i]))
			   {
				   juli = pcl::squaredEuclideanDistance(dian, kk->points[i]);
				   index = i;

			   }

		   }

4.获得点云normal 值的方法(三种不同的方式)

pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>); 
std::cout<<normals->points[100]<<std::endl;
std::cout<<"["<<normals->points[100].normal_x<<" "
              <<normals->points[100].normal_y<<" "
              <<normals->points[100].normal_z<<" "
              <<normals->points[100].curvature<<"]"<<endl;

std::cout<<"["<<normals->points[100].normal[0]<<" "
              <<normals->points[100].normal[1]<<" "
              <<normals->points[100].normal[2]<<" "
              <<normals->points[100].curvature<<"]"<<endl;

std::cout<<"["<<normals->points[100].data_n[0]<<" "
              <<normals->points[100].data_n[1]<<" "
              <<normals->points[100].data_n[2]<<" "
              <<normals->points[100].curvature<<"]"<<endl;

 

5.时间计算(主要是要计算每一部分计算的时间) 

time_t start, end, diff[5], option;															 //时间变量
	start = time(0);
	printf("开始计时\n");




diff[0] = difftime(end, start);
	PCL_INFO("\ the time of load pointcloud: %d\n", diff[0]);



	diff[1] = difftime(end, start) - diff[0];
	PCL_INFO("\computing Normals takes(seconds): %d\n", diff[1]);

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值