【发布时间】:2015-07-17 17:19:30
【问题描述】:
假设我有两个不同的pcl::PointCloud<pcl::PointXYZL>(尽管点类型并不重要),c1 和 c2。
我想找到这两个点云的交集。
通过交集,我的意思是点云inter 的构造使得来自c1 的点pi 插入inter,如果(且仅当)pj 存在于c2 中并且
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;
}
我想知道是否有标准(并且可能更有效)的方法来做到这一点?
我在official documentation 中没有找到任何关于此的信息,但也许我遗漏了一些东西。
谢谢。
【问题讨论】:
标签: c++ point-cloud-library point-clouds