点云配准

using PointType = pcl::PointCloud<pcl::PointXYZ>;

int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	PointType::Ptr cloud_in(new PointType);
	cloud_in->width = 5;
	cloud_in->height = 1;
	cloud_in->is_dense = false;
	cloud_in->points.resize(cloud_in->width * cloud_in->height);
	for (size_t t = 0; t < cloud_in->points.size(); ++t)
	{
		cloud_in->points[t].x = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud_in->points[t].y = 1024 * rand() / (RAND_MAX + 1.0f);
		cloud_in->points[t].z = 1024 * rand() / (RAND_MAX + 1.0f);
	}


	PointType::Ptr cloud_out(new PointType);
	*cloud_out = *cloud_in;
	//实现一个简单的点云刚体变换,以构造目标点云
	for (size_t i = 0; i < cloud_in->points.size(); ++i)
		cloud_out->points[i].x = cloud_in->points[i].x + 0.7f;

	pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
	icp.setInputCloud(cloud_in);                 //cloud_in设置为点云的源点
	icp.setInputTarget(cloud_out);               //cloud_out设置为与cloud_in对应的匹配目标
	PointType Final;         //存储经过配准变换点云后的点云
	icp.align(Final);         //打印配准相关输入信息

	std::cout << "has converged:" << icp.hasConverged() << endl << \
		" score: " << icp.getFitnessScore() << std::endl;


	std::cout << icp.getFinalTransformation() << std::endl;


	return a.exec();
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值