根据CGAL4.13.1中的“基本平面形状检测”实例,我尝试使用CGAL的形状检测算法。但是,而不是读取-从文件中的数据
CGAL::read_xyz_points(stream,
std::back_inserter(points),
CGAL::parameters::point_map(Point_map()).
normal_map(Normal_map()))我想将我的观点从一个现有的pcl::PointCloud加载到必要的CGAL类型。我只是不知道如何创建这个CGAL类型。根据例子(节选)
typedef std::pair<Kernel::Point_3, Kernel::Vector_3> Point_with_normal;
typedef std::vector<Point_with_normal> Pwn_vector;
Pwn_vector points;
typedef CGAL::Shape_detection_3::Efficient_RANSAC<Traits> Efficient_ransac;
EfficientRansac.set_input(points);我只需要创建Pwn_vector。所以我的问题是
Pwn_vector中插入点吗?CGAL::jet_estimate_normals吗?Point_map和Normal_map的属性映射吗?我不知道他们是如何被移交给Efficient_ransac的。我从以下代码开始:
// Points with normals.
cgal::Pwn_vector points;
// load points from pcl cloud
for (auto point : cloud.points) {
cgal::Point_with_normal pwn;
pwn.first = cgal::ShapeKernel::Point_3(point.x, point.y, point.z);
points.push_back(pwn);
}(PCL对这个问题并不感兴趣,因为它清楚如何访问单个坐标。)
发布于 2019-06-11 07:26:00
发布于 2019-06-11 08:19:08
要完成mgimeno的答案(这是正确的),您不一定需要复制这些点。属性映射的兴趣在于,您只需要提供一个函数get(),该函数可以动态地将您范围内的value_type转换为CGAL::Point_3 (法线的CGAL::Vector_3)。
例如,对于PCL,我想您会这样做(我不是PCL的用户,所以这可能是不正确的,但这只是给您一个想法):
struct PCL_point_map
{
typedef pcl::PointCloud::value_type key_type;
typedef CGAL::Point_3<Kernel> value_type;
typedef CGAL::Point_3<Kernel> reference;
typedef boost::readable_property_map_tag category;
friend reference get (const PCL_point_map&, const key_type& k)
{
return CGAL::Point_3<Kernel> (k.x, k.y, k.z);
}
};对于法线也有类似之处(需要计算法线才能进行形状检测,CGAL::jet_estimate_normals是一个很好的选择)。然后,如果您只是用自己的地图来模板这些特征,您可以直接调用PCL点云上的RANSAC算法。
https://stackoverflow.com/questions/56495711
复制相似问题