当前位置: 首页 > 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.dtcms.com/a/329848.html

相关文章:

  • 不止于GET:掌握POST报错注入的精髓
  • HTML第二次作业
  • wandb: Network error (SSLError), entering retry loop
  • JavaWeb-XML、HTTP协议和Tomcat服务器
  • TF - IDF算法面试与工作常见问题全解析
  • 51单片机-51单片机最小系统
  • 基于大模型增强的知识图谱的嵌入学习模型的研究
  • 人工智能——CNN基础:卷积和池化
  • 【DL】最优化理论和深度学习
  • nginx匹配规则
  • 2023 年全国硕士研究生招生考试真题笔记
  • 部署在linux上的java服务老是挂掉[排查日志]
  • Spring Boot调用优化版AI推理微服务 集成 NVIDIA NIM指南
  • 部署 Docker 应用详解(MySQL + Tomcat + Nginx + Redis)
  • mysql binlog常用命令
  • 2.从零开始写LINUX内核—导扇区与 Setup 程序开发
  • 充电宝频频自燃?PA300功率计来“把关”
  • robot framework
  • 选择gpt-5还是claude-4-sonnect
  • GPT-o3回归Plus用户,GPT5拆分三种模式,对标Grok
  • 深度学习·ExCEL
  • 在Ubuntu24.04中使用ssh连接本地git仓库到github远程仓库
  • [前端算法]排序算法
  • 用vscode开发和调试golang超简单教程
  • net/dial.go
  • QT之设计器组件功能(8大类55个组件)
  • 机器学习阶段性总结:对深度学习本质的回顾 20250813
  • Java 大视界 -- Java 大数据机器学习模型在金融资产配置优化与风险收益平衡中的应用(395)
  • golang语言和JAVA对比
  • Python 迭代协议与迭代器