假设我有两个不同的>(尽管点类型并不重要),c1和c2。
我想找到这两个点云的交集。通过交集,我指的是构建点云inter,使得从c1中插入一个点pi到inter中,当且仅当在c2中存在一个点pj且
我想找到这两个点云的交集。通过交集,我指的是构建点云inter,使得从c1中插入一个点pi到inter中,当且仅当在c2中存在一个点pj且
pi.x == pj.x && pi.y == pj.y && pi.z == pj.z
目前,我正在使用以下功能来实现此目的:
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
using namespace pcl;
typedef PointXYZL PointLT;
typedef PointCloud<PointLT> PointLCloudT;
bool contains(PointLCloudT::Ptr c, PointLT p) {
PointLCloudT::iterator it = c->begin();
for (; it != c->end(); ++it) {
if (it->x == p.x && it->y == p.y && it->z == p.z)
return true;
}
return false;
}
PointLCloudT::Ptr intersection(PointLCloudT::Ptr c1,
PointLCloudT::Ptr c2) {
PointLCloudT::Ptr inter;
PointLCloudT::iterator it = c1->begin();
for (; it != c1->end(); ++it) {
if (contains(c2, *it))
inter->push_back(*it);
}
return inter;
}
我想知道是否有一种标准(可能更有效)的方法来做到这一点?
在官方文档中我没有找到相关内容,但也许我错过了什么。
谢谢。