当前位置: 首页 > news >正文

Open3d:从mesh中采样点云的两个函数

1.均匀采样:sample_points_uniformly

    def sample_points_uniformly(self, number_of_points=100, use_triangle_normal=False): # real signature unknown; restored from __doc__"""sample_points_uniformly(self, number_of_points=100, use_triangle_normal=False)Function to uniformly sample points from the mesh.Args:number_of_points (int, optional, default=100): Number of points that should be uniformly sampled.use_triangle_normal (bool, optional, default=False): If True assigns the triangle normals instead of the interpolated vertex normals to the returned points. The triangle normals will be computed and added to the mesh if necessary.Returns:open3d.geometry.PointCloud"""pass

功能描述

该方法通过基于面积的均匀采样从网格表面生成点云,不考虑点间距约束。

参数说明

参数

类型

默认值

描述

number_of_points

int

100

要采样的点数

use_triangle_normal

bool

False

是否使用三角形面法线而非插值顶点法线

算法流程

  1. 三角形面积计算

    • 计算每个三角形的面积

    • 计算总面积和每个三角形的采样权重

  2. 点分配

    • 按面积比例分配采样点到各三角形

    • n_points_for_triangle = round(area_triangle / total_area * number_of_points)

  3. 三角形内采样

    • 对每个三角形:

    • 生成重心坐标随机点:P = α·A + β·B + γ·C

    • 其中 α + β + γ = 1 (随机生成)

  4. 法线处理

    • 同泊松圆盘采样

特点与注意

  • 简单快速:计算复杂度低

  • 面积加权:大三角形获得更多采样点

  • 无间距约束:点可能聚集在小三角形区域

  • 随机分布:每次采样结果不同

  • 数量近似:实际点数可能略有偏差(四舍五入导致)

适用场景

  • 快速网格简化

  • 实时应用

  • 机器学习数据准备

  • 基础几何处理

2.泊松圆盘采样-sample_points_poisson_disk 

   def sample_points_poisson_disk(self, number_of_points, init_factor=5, pcl=None, use_triangle_normal=False): # real signature unknown; restored from __doc__"""sample_points_poisson_disk(self, number_of_points, init_factor=5, pcl=None, use_triangle_normal=False)Function to sample points from the mesh, where each point has approximately the same distance to the neighbouring points (blue noise). Method is based on Yuksel, "Sample Elimination for Generating Poisson Disk Sample Sets", EUROGRAPHICS, 2015.Args:number_of_points (int): Number of points that should be sampled.init_factor (float, optional, default=5): Factor for the initial uniformly sampled PointCloud. This init PointCloud is used for sample elimination.pcl (open3d.geometry.PointCloud, optional, default=None): Initial PointCloud that is used for sample elimination. If this parameter is provided the init_factor is ignored.use_triangle_normal (bool, optional, default=False): If True assigns the triangle normals instead of the interpolated vertex normals to the returned points. The triangle normals will be computed and added to the mesh if necessary.Returns:open3d.geometry.PointCloud"""pass

 

功能描述

该方法使用泊松圆盘采样算法从网格表面生成点云,确保采样点之间保持近似均匀的距离(蓝噪声分布)。其实现基于 Yuksel 2015 年的论文《Sample Elimination for Generating Poisson Disk Sample Sets》。

参数说明

参数类型默认值描述
number_of_pointsint必填最终要采样的目标点数
init_factorfloat5初始采样因子。初始采样点数为 init_factor × number_of_points
pclPointCloudNone可选的初始点云(若提供则忽略 init_factor
use_triangle_normalboolFalse是否使用三角形面法线而非插值顶点法线

算法流程

  1. 初始采样

    • 如果没有提供初始点云 (pcl=None)

    • 生成 init_factor × number_of_points 个均匀采样点

  2. 样本消除

    • 基于论文中的优化算法

    • 逐步消除过于密集的点

    • 保留 number_of_points 个满足最小距离约束的点

  3. 法线处理

    • 若 use_triangle_normal=True:直接使用三角形面法线

    • 否则:通过顶点法线插值得出采样点法线

特点与优势

  • 蓝噪声特性:生成的点分布均匀,无聚集现象

  • 距离约束:任意两点间保持最小距离

  • 高质量采样:适用于需要均匀分布的视觉应用

  • 效率优化:通过样本消除避免昂贵的直接计算

适用场景

  • 3D打印表面准备

  • 物理仿真输入

  • 高质量渲染

  • 表面重建的预处理

两种方法对比

特性泊松圆盘采样均匀采样
点分布均匀,蓝噪声随机,面积加权
点间距有最小距离约束无约束
计算复杂度较高 (O(n log n))较低 (O(n))
采样质量高质量,视觉愉悦基础质量
参数控制精细 (init_factor)简单
速度较慢很快
应用场景高质量渲染/打印快速处理/ML
论文依据Yuksel 2015经典方法

性能注意事项

  1. 泊松圆盘采样

    • init_factor 显著影响性能(5-10 是合理范围)

    • 复杂网格建议使用预计算点云

  2. 均匀采样

    • 对超大数据集考虑分块处理

    • 多次采样取平均可改善分布

高级使用技巧

泊松圆盘采样的优化

# 使用预计算点云加速
init_pcd = mesh.sample_points_uniformly(5000)
result_pcd = mesh.sample_points_poisson_disk(number_of_points=1000,pcl=init_pcd  # 跳过初始采样阶段
)

法线处理建议

# 需要精确法线时
mesh.compute_vertex_normals()  # 确保顶点法线存在
mesh.compute_triangle_normals()  # 确保面法线存在# 根据需求选择法线类型
if need_precise_normals:pcd = mesh.sample_points_uniformly(1000, use_triangle_normal=True)
else:pcd = mesh.sample_points_uniformly(1000, use_triangle_normal=False)

参考资料:

1.Open3D 从mesh中采样点云【2025最新版】_mesh采样点云-CSDN博客

2.deepseek.ai

http://www.lryc.cn/news/620037.html

相关文章:

  • round robin轮询仲裁器
  • 2025 开源语音合成模型全景解析:从工业级性能到创新架构的技术图谱
  • hutool 作为http 客户端工具调用的一点点总结
  • 理解RESTful架构:构建优雅高效的Web服务
  • 《Unity Shader入门精要》学习笔记一
  • Dimensional Analysis量纲分析入门
  • 【Excel】被保护的文档如何显示隐藏的行或列
  • MongoDB 入门指南二:索引 —— 让查询速度飞起来
  • 随想记-excel报表美化
  • 选择排序专栏
  • 使用 6 种方法将文件从 Android 无缝传输到iPad
  • C# 反射和特性(获取Type对象)
  • 攒钱学概论:5、创业术
  • window显示驱动开发—DirectX 9 资源创建
  • 《AVL树的原理与C++实现:详解平衡二叉搜索树的高效构建与操作》
  • 【自动化运维神器Ansible】playbook主机清单变量深度解析:主机变量与组变量的实战应用
  • JavaWeb-Servlet基础
  • CodeBuddy在AI开发方面的一些特色
  • 1.Cursor快速入门与配置
  • PyTorch Tensor完全指南:深度学习数据操作的核心艺术
  • Matlab(4)
  • C++ stack and queue
  • 【OSPP 开源之夏】Good First issue 第一步—— openEuler Embedded 计划
  • 机器视觉的零件误差检测系统:基于多角度点云融合的圆柱体零件尺寸测量
  • 5. synchronized 关键字 - 监视器锁 monitor lock
  • InnoDB如何解决脏读、不可重复读和幻读的?
  • mysql - 查询重复数据,不区分大小重复问题解决
  • 服务器查看 GPU 占用情况的方法
  • 安全点(Safepoint)完成后唤醒暂停线程的过程
  • 响应式对象的类型及其使用场景