CGAL 点云边界提取

一、算法概述

  使用Voronoi协方差度量检测点云的尖锐边缘特征点。

1、主要函数

头文件

#include <CGAL/vcm_estimate_edges.h>

函数

bool CGAL::vcm_is_on_feature_edge  ( std::array< FT, 6 > &  cov,  
  double  threshold,  
  VCMTraits    
 ) 

  确定一个点是否从计算Voronoi协方差度量的点集上的尖锐特征边缘。利用边缘的锐度阈值参数,根据锐度特征周围的外部角度进行点滤波。

  假设一个点在边缘的外角为: α \alpha α,如果 α \alpha α满足如下公式:
α ≥ 2 3 \alpha\geq\frac{2}{\sqrt{3}} α3 2
则认为该点在一个尖锐特征上。
  这意味着如果输入点云包含外部角度不同的尖锐特征,应该考虑外部角度最小的特征,但这会导致在更尖锐的区域选择更多的点。

2、参考文献

[1] Quentin Merigot, Maks Ovsjanikov, and Leonidas Guibas. Voronoi-based curvature and feature estimation from point clouds. Visualization and Computer Graphics, IEEE Transactions on, 17(6):743–756, 2011.

二、代码实现

#include <utility> // std::pair
#include <vector>
#include <fstream>
#include <CGAL/property_map.h>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/vcm_estimate_edges.h> // 计算vo协方差
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
// Types
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
// 存储点坐标和法向量的pair容器
typedef std::pair<Kernel::Point_3, Kernel::Vector_3> PointVectorPair;
// 数组
typedef std::array<double, 6> Covariance;

int main(int, char**)
{
	const std::string input_filename = CGAL::data_file_path("cgal//fandisk_large.off");
	const char* output_filename("cgal//fandisk_large.xyz");
	// -----------------------从模型数据中读取点坐标和法线-----------------------
	std::list<PointVectorPair> points;
	if (!CGAL::IO::read_points(input_filename, std::back_inserter(points),
		CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>())))
	{
		std::cerr << "Error: cannot read file data/fandisk_large.off" << std::endl;
		return -1;
	}
	// -----------------------------计算每个点的协方差---------------------------
	double R = 0.2,
		r = 0.1;
	std::vector<Covariance> cov;
	CGAL::First_of_pair_property_map<PointVectorPair> point_map;
	CGAL::compute_vcm(points, cov, R, r,
		CGAL::parameters::point_map(point_map).geom_traits(Kernel()));

	// ------------------------------找到边缘上的点------------------------------
	// 这个步骤可以多执行几次,以获取更好的结果
	double threshold = 0.16;
	std::ofstream output("cgal//points_on_edges.xyz");
	int i = 0;
	for (auto& p : points)
	{
		if (CGAL::vcm_is_on_feature_edge(cov[i], threshold))
			output << p.first << "\n";
		++i;
	}
	output.close();

	return 0;
}

三、结果展示

在这里插入图片描述

  • 5
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
CGAL(Computational Geometry Algorithms Library)是一个用于计算几何算法的开源库。它提供了许多用于生成和操作点云、线段、多边形等几何实体的功能。 要使用CGAL生成Delaunay三角形,首先需要将点云导入CGAL中。可以通过读取文件或手动输入点的坐标来表示点云。然后,使用CGAL中的Delaunay三角形算法构建三角剖分。 Delaunay三角形是一种无重叠的三角剖分,它满足一个性质:对于任何在点云中不属于三角形内部的点,其到三角形的最近点是唯一的。CGAL库中实现了各种用于创建Delaunay三角形的算法,包括增量构建和依据递归细分的方法。 使用CGAL生成Delaunay三角形的步骤如下: 1. 创建一个点云对象,并将点云中的点添加到该对象中。 2. 根据点云数据构建一个Delaunay三角形数据结构,例如使用CGAL中的Delaunay_triangulation_2类。 3. 调用Delaunay三角形数据结构对象的构建方法,如insert()或triangulate(),将点云中的点添加到三角形中,并进行三角形的构建。 4. 可选步骤,根据实际需求对三角形进行修改、优化或筛选处理。 5. 根据需要,可以将Delaunay三角形导出到文件或进行可视化展示。 总之,CGAL库提供了方便易用的功能,能够实现从点云数据生成Delaunay三角形的任务。使用CGAL可以快速准确地生成Delaunay三角形,为计算几何问题提供了强大的支持。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

点云侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值