PCL学习笔记——getApproximateIndices()函数的调用

getApproximateIndices():得到给定点云的一组近似索引到参考点云

void pcl::getApproximateIndices (const typename pcl::PointCloud< PointT >::ConstPtr & cloud_in,const typename pcl::PointCloud< PointT>::ConstPtr & cloud_ref,std::vector< int > & indices )
Get a set of approximate indices for a given point cloud into a reference point cloud.
The coordinates of the two point clouds can differ. The method uses an internal KdTree for finding the closest neighbors from cloud_in in cloud_ref.

Parameters:

[in] cloud_in :the input point cloud dataset;
[in] cloud_ref :the reference point cloud dataset;
[out] indices :the resultant set of nearest neighbor indices of cloud_in in cloud_ref.

code:
// get_index_of_overlap.cpp: 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "stdafx.h"
#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/point_types.h>
#include<pcl/point_cloud.h>
#include<pcl/kdtree/kdtree_flann.h>
#include<pcl/kdtree/io.h>
#include<vector>
#include<fstream>


using namespace std;


int main()
{
	ofstream test;
	test.open("test.txt");
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloudA(new pcl::PointCloud<pcl::PointXYZ>);
	pcl::PointCloud<pcl::PointXYZ>::Ptr cloudB(new pcl::PointCloud<pcl::PointXYZ>);

	//读取pcd文档
	if (pcl::io::loadPCDFile<pcl::PointXYZ>("pointA.pcd", *cloudA) == -1)
	{
		PCL_ERROR("Couldn't read file cloudA.pcd\n");
		return -1;
	}
	if (pcl::io::loadPCDFile<pcl::PointXYZ>("pointB.pcd", *cloudB) == -1)
	{
		PCL_ERROR("Couldn't read file cloudB.pcd\n");
		return -1;
	}
	//为点云A中的每个点在点云B中找到一个最邻近点,但是无法设置阈值
	vector<int>vec;
	pcl::getApproximateIndices<pcl::PointXYZ>(cloudA, cloudB, vec);

	test.close();
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值