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

IterativeClosestPoints icp配准矩阵

一:主要的知识点

1、说明

本文只是教程内容的一小段,因博客字数限制,故进行拆分。主教程链接:vtk教程——逐行解析官网所有Python示例-CSDN博客

2、知识点纪要

本段代码主要涉及的有①ICP配算法的运用,②运用ICP的配准矩阵


二:代码及注释

import vtkmodules.vtkRenderingOpenGL2 import vtkmodules.vtkInteractionStyle from vtkmodules.vtkCommonCore import vtkPoints from vtkmodules.vtkCommonDataModel import vtkCellArray, vtkPolyData, vtkIterativeClosestPointTransform from vtkmodules.vtkFiltersGeneral import vtkTransformPolyDataFilter # from vtkmodules.vtkFiltersSources import def main(): """ 原文写法 sourcePoints = vtkPoints() sourceVertices = vtkCellArray() sp_id = sourcePoints.InsertNextPoint(1.0, 0.1, 0.0) # 返回为0 sourceVertices.InsertNextCell(1) sourceVertices.InsertCellPoint(sp_id) sp_id = sourcePoints.InsertNextPoint(0.1, 1.1, 0.0) # 返回为1 sourceVertices.InsertNextCell(1) sourceVertices.InsertCellPoint(sp_id) sp_id = sourcePoints.InsertNextPoint(0.0, 0.1, 1.0) # 返回为2 sourceVertices.InsertNextCell(1) sourceVertices.InsertCellPoint(sp_id) source = vtkPolyData() source.SetPoints(sourcePoints) source.SetVerts(sourceVertices) 我觉得这种写法与一般示例的写法出入较大,在这里重写 """ sourcePoints = vtkPoints() sourcePoints.InsertNextPoint(1.0, 0.1, 0.0) sourcePoints.InsertNextPoint(0.1, 1.1, 0.0) sourcePoints.InsertNextPoint(0.0, 0.1, 1.0) sourceCells = vtkCellArray() sourceCells.InsertNextCell(1, [0]) sourceCells.InsertNextCell(1, [1]) sourceCells.InsertNextCell(1, [2]) source = vtkPolyData() source.SetPoints(sourcePoints) source.SetVerts(sourceCells) pointCount = 3 for index in range(pointCount): point = [0, 0, 0] sourcePoints.GetPoint(index, point) print("source point[%s]=%s" % (index, point)) # target_points。目标点位 targetPoints = vtkPoints() targetPoints.InsertNextPoint(1, 0, 0) targetPoints.InsertNextPoint(0, 1, 0) targetPoints.InsertNextPoint(0, 0, 1) targetCells = vtkCellArray() targetCells.InsertNextCell(1, [0]) targetCells.InsertNextCell(1, [1]) targetCells.InsertNextCell(1, [2]) target = vtkPolyData() target.SetPoints(targetPoints) target.SetVerts(targetCells) pointCount = 3 for index in range(pointCount): point = [0, 0, 0] targetPoints.GetPoint(index, point) print("target point[%s]=%s" % (index, point)) # 构建icp icp = vtkIterativeClosestPointTransform() icp.SetSource(source) icp.SetTarget(target) icp.GetLandmarkTransform().SetModeToRigidBody() # 设为刚体,只能旋转和平移,不能缩放 icp.SetMaximumNumberOfIterations(20) # 设置最大迭代次数为20 icp.StartByMatchingCentroidsOn() # 开启ICP算法的质心预匹配步骤,它会在第一次迭代时,先应用一个平移变换,将源点云的质心移动到目标点云的质心位置 icp.Modified() # 通知 VTK 管道,这个对象(icp 变换对象)的参数已被修改 icp.Update() """ vtkTransformPolyDataFilter 将一个 vtkPolyData 数据集应用几何变换,然后生成一个新的、已变换的 vtkPolyData 对象 下面一段代码的含义是指将source乘以ipc得到的4x4配准矩阵 """ icpTransformFilter = vtkTransformPolyDataFilter() icpTransformFilter.SetInputData(source) icpTransformFilter.SetTransform(icp) icpTransformFilter.Update() transformedSource = icpTransformFilter.GetOutput() # ============ display transformed points ============== pointCount = 3 for index in range(pointCount): point = [0, 0, 0] transformedSource.GetPoint(index, point) print("transformed source point[%s]=%s" % (index, point)) if __name__ == '__main__': main()
http://www.cnnetsun.cn/news/143719.html

相关文章:

  • 57、SQL 网络与分布式数据库全解析
  • MeshLabelImageColor 读取医学标签图像数据(MetaImage 格式)
  • 61、SQL 中的抽象数据类型与继承机制
  • 69、SQL 的现状与未来:专业数据库与市场趋势洞察
  • 68、专业数据库:低延迟、内存与流处理的应用与发展
  • eRPC数据中心网络高效RPC终极配置指南
  • 零基础玩转Moondream2:智能看图说话神器快速上手指南
  • Hasklig编程字体:用连字技术彻底改变你的代码阅读体验
  • 深度解析 Redisson:不仅仅是 Redis 客户端,更是分布式协作利器
  • Kubernetes可视化管理新体验:告别命令行,拥抱kubeasz Dashboard
  • 实战指南:构建基于Google API的自动化SEO监控系统
  • Recon-ng数据导出终极指南:5分钟掌握情报呈现技巧
  • PostHog容器化部署终极方案:从业务价值到技术实现的高效配置指南
  • Rust Web开发完整教程:realworld-axum-sqlx实战指南
  • Tuya-Local终极指南:如何快速配置本地涂鸦设备实现全屋智能控制
  • 基于SpringBoot的高校科研工作管理系统(源码+lw+部署文档+讲解等)
  • 基于springboot + vue电影院购票管理系统
  • Hasklig字体:为什么它能让你的代码阅读体验提升300%?
  • Neovim LSP配置终极指南:快速搭建现代化开发环境
  • IT-Tools终极指南:Vue 3 + TypeScript打造开发者效率神器
  • Weylus 终极指南:3步将平板变身手绘板
  • WeasyPrint终极指南:从HTML到PDF的完整解决方案
  • 基于java + vue校园外卖系统(源码+数据库+文档)
  • Flutter炫酷UI设计模板教程:打造专业级移动应用界面
  • 计算机毕业设计|基于springboot + vue作业管理系统(源码+数据库+文档)
  • 终极MCP测试指南:7天掌握协议全功能验证
  • 为什么Vkvg是下一代2D图形渲染的颠覆者?
  • 基于VUE的客房订房系统[VUE]-计算机毕业设计源码+LW文档
  • DiffSynth-Engine终极指南:构建高性能扩散模型推理管道的完整方案
  • 5层防护构建容器运行时安全屏障:从内核隔离到应用沙箱的深度防御实践