PCL学习笔记——利⽤点云配准CorrespondenceEstimationBa()。。。主要类:
pcl::registration::CorrespondenceEstimation< PointSource, PointTarget, Scalar > Class Template Reference
声卡驱动更新
主要函数:
template<typename PointSource , typename PointTarget , typename Scalar = float>
virtual void pcl::registration::CorrespondenceEstimationBa< PointSource, PointTarget, Scalar
>::determineReciprocalCorrespondences (pcl::Correspondences & correspondences,double max_distance =
std::numeric_limits< double >::max() )
Parameters:
[out] correspondences:the found correspondences (index of query and target point, distance)定势效应
[in] max_distance:maximum allowed distance between correspondences (对应点最⼤距离)
确定输⼊和⽬标点云之间的相互对应关系
code:
// correspondence_points_registraction.cpp: 定义控制台应⽤程序的⼊⼝点。
//
#include "stdafx.h"
#include<pcl/registration/correspondence_estimation.h>
假如我是孙悟空
#include<pcl/io/pcd_io.h>
#include<pcl/kdtree/io.h>
那个男人的谎言
刘胄#include<vector>
#include<fstream>
using namespace std;
int main()
{
ofstream oa, ob;
oa.open("");
ob.open("");
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudA(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudB(new pcl::PointCloud<pcl::PointXYZ>);
//读取PCD点云⽂件
pcl::io::loadPCDFile<pcl::PointXYZ>("pointA.pcd", *cloudA);
pcl::io::loadPCDFile<pcl::PointXYZ>("pointB.pcd", *cloudB);
pcl::registration::CorrespondenceEstimation<pcl::PointXYZ, pcl::PointXYZ>core;
core.tInputSource(cloudA);
core.tInputTarget(cloudB);
boost::shared_ptr<pcl::Correspondences> cor(new pcl::Correspondences); //共享所有权的智能指针,以kdtree做索引
core.determineReciprocalCorrespondences(*cor, 0.25); //点之间的最⼤距离,cor对应索引
//构造重叠点云的PCD格式⽂件
pcl::PointCloud<pcl::PointXYZ>overlapA;
pcl::PointCloud<pcl::PointXYZ>overlapB;
overlapA.width = cor->size();
overlapA.height = 1;
overlapA.is_den = fal;
陂组词
size(overlapA.width*overlapA.height);
overlapB.width = cor->size();
overlapB.height = 1;
overlapB.is_den = fal;
size(overlapB.width*overlapB.height);
for (size_t i = 0; i < cor->size(); i++) {
//overlapA写⼊txt⽂件
oa << cloudA->points[cor->at(i).index_query].x<<" "<< cloudA->points[cor->at(i).index_query].y<<" " //cor->at(i).index_query]对应点的索引 << cloudA->points[cor->at(i).index_query].z<<endl;
//overlapA写⼊pcd⽂件
overlapA.points[i].x = cloudA->points[cor->at(i).index_query].x;
overlapA.points[i].y = cloudA->points[cor->at(i).index_query].y;
overlapA.points[i].z = cloudA->points[cor->at(i).index_query].z;
//overlapB写⼊txt⽂件
ob << cloudB->points[cor->at(i).index_match].x << " " << cloudB->points[cor->at(i).index_match].y<<" "
<< cloudB->points[cor->at(i).index_match].z << endl;
//overlapB写⼊pcd⽂件
overlapB.points[i].x = cloudB->points[cor->at(i).index_match].x;
overlapB.points[i].y = cloudB->points[cor->at(i).index_match].y;
overlapB.points[i].z = cloudB->points[cor->at(i).index_match].z;
}
//存储pcd⽂件
pcl::io::savePCDFileASCII("overlapA.pcd", overlapA);
pcl::io::savePCDFileASCII("overlapB.pcd", overlapB);谁说青春不能错
oa, ob.clo();
return 0;
徒步口号
}
//2'04
results: