{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/",
  "atlas": "https://www.pystone.net/?node=pcl-mls-surface-reconstruction#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction.md",
  "context": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:pcl-mls-surface-reconstruction",
  "slug": "pcl-mls-surface-reconstruction",
  "title": "PCL 移动最小二乘法：点云平滑与法线估计",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "PCL 移动最小二乘法：点云平滑与法线估计",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "6a7d7f5ea4634c1d4aeb84f42da73e9b19b09e12cbb49324fc3a8c930ff4d098",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "PCL 移动最小二乘法：点云平滑与法线估计",
      "anchor": "pcl-移动最小二乘法点云平滑与法线估计",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#pcl-%E7%A7%BB%E5%8A%A8%E6%9C%80%E5%B0%8F%E4%BA%8C%E4%B9%98%E6%B3%95%E7%82%B9%E4%BA%91%E5%B9%B3%E6%BB%91%E4%B8%8E%E6%B3%95%E7%BA%BF%E4%BC%B0%E8%AE%A1"
    },
    {
      "depth": 2,
      "text": "MLS 解决什么问题",
      "anchor": "mls-解决什么问题",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#mls-%E8%A7%A3%E5%86%B3%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"
    },
    {
      "depth": 2,
      "text": "基本流程",
      "anchor": "基本流程",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B"
    },
    {
      "depth": 2,
      "text": "参数与边界",
      "anchor": "参数与边界",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#%E5%8F%82%E6%95%B0%E4%B8%8E%E8%BE%B9%E7%95%8C"
    },
    {
      "depth": 2,
      "text": "验证方式",
      "anchor": "验证方式",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#%E9%AA%8C%E8%AF%81%E6%96%B9%E5%BC%8F"
    },
    {
      "depth": 2,
      "text": "参考资料",
      "anchor": "参考资料",
      "citation": "https://www.pystone.net/notes/pcl-mls-surface-reconstruction/#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:graphics-and-3d-reconstruction",
      "title": "图形学与三维重构",
      "url": "https://www.pystone.net/notes/graphics-and-3d-reconstruction/",
      "atlas": "https://www.pystone.net/?node=graphics-and-3d-reconstruction#knowledge-atlas",
      "label": "图形学与三维重构",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "本层中的“PCL移动最小二乘法表面重建（转载）”导航项",
      "citation": "https://www.pystone.net/notes/graphics-and-3d-reconstruction/#%E6%9C%AC%E5%B1%82"
    }
  ],
  "contentMarkdown": "# PCL 移动最小二乘法：点云平滑与法线估计\n\n> [!note] 来源与许可\n> 旧稿是 2014 年 CSDN 文章转载，导出内容未保留明确转载许可，故原转载已移入私有来源归档。本文是依据 PCL 官方教程重新编写的独立摘要；示例接口以 PCL 当前文档为准。PCL 项目使用 BSD 许可证。\n\n## MLS 解决什么问题\n\n移动最小二乘法（Moving Least Squares, MLS）在每个采样点的局部邻域拟合平滑曲面，并把点投影到局部曲面上。它常用于：\n\n- 降低扫描噪声造成的局部起伏；\n- 对点云重采样；\n- 同时估计平滑后的法线；\n- 为后续三角化提供更一致的点和法线。\n\nMLS 输出的核心仍是点云（可包含法线），不会仅凭这一步生成三角网格。\n\n## 基本流程\n\n```cpp\n#include <pcl/point_types.h>\n#include <pcl/search/kdtree.h>\n#include <pcl/surface/mls.h>\n\nusing InputPoint = pcl::PointXYZ;\nusing OutputPoint = pcl::PointNormal;\n\npcl::PointCloud<InputPoint>::Ptr input(new pcl::PointCloud<InputPoint>);\npcl::PointCloud<OutputPoint> output;\n\npcl::search::KdTree<InputPoint>::Ptr tree(\n    new pcl::search::KdTree<InputPoint>);\n\npcl::MovingLeastSquares<InputPoint, OutputPoint> mls;\nmls.setInputCloud(input);\nmls.setSearchMethod(tree);\nmls.setSearchRadius(0.03);  // 应按点间距与几何尺度调参\nmls.setComputeNormals(true);\nmls.process(output);\n```\n\n具体接口会随 PCL 版本变化，编译时应核对当前头文件和官方示例。\n\n## 参数与边界\n\n- **搜索半径**过小：邻域点不足，拟合不稳定或出现空洞。\n- **搜索半径**过大：跨越尖锐边缘或薄壁两侧，细节被抹平。\n- **多项式阶数**越高不等于越准确，噪声、采样密度和计算成本都会影响结果。\n- 离群点会扭曲局部拟合，通常先进行统计或半径离群点过滤。\n- 点云密度变化剧烈、存在大孔洞或薄结构时，应分区调参并与原始数据对照。\n\n## 验证方式\n\n1. 记录点间距分布，以它为搜索半径的尺度依据。\n2. 在平面、曲面、尖锐边缘和稀疏区域分别抽样可视化。\n3. 比较点到原始数据/参考表面的距离，而不只看“更光滑”。\n4. 检查法线方向一致性及后续网格的孔洞、自交和错误连接。\n\n## 参考资料\n\n- [PCL 官方教程：Smoothing and normal estimation based on polynomial reconstruction](https://pointclouds.org/documentation/tutorials/resampling.html)\n- [PCL BSD License](https://github.com/PointCloudLibrary/pcl/blob/master/LICENSE.txt)\n"
}
