news 2026/9/3 1:47:16

IterativeClosestPoints icp配准矩阵

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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()
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/2 8:18:45

LineOnMesh 在三维网格曲面上绘制一条平滑的路径线

一:主要的知识点 1、说明 本文只是教程内容的一小段,因博客字数限制,故进行拆分。主教程链接:vtk教程——逐行解析官网所有Python示例-CSDN博客 2、知识点纪要 本段代码主要涉及的有①vtkLoopSubdivisionFilter上采样&#xf…

作者头像 李华
网站建设 2026/9/2 3:13:39

安卓远程摄像头终极指南:3步实现桌面流媒体和虚拟摄像头

RemoteCam是一个功能强大的开源项目,让你能够将安卓设备的摄像头实时流式传输到桌面电脑。无论你是想为OBS添加高质量的视频源,还是在Linux系统上创建虚拟摄像头,这个免费、无广告的工具都能满足你的需求。本教程将带你从零开始,轻…

作者头像 李华
网站建设 2026/9/3 1:00:12

62、SQL 中集合、数组和集合类型数据的处理

SQL 中集合、数组和集合类型数据的处理 在数据库领域,数据的组织和管理方式至关重要。传统的关系数据库在处理数据集合时存在一定的局限性,而对象 - 关系数据库通过支持集合、数组等数据类型,为数据管理带来了新的解决方案。 关系数据库中数据集合的表示 在关系数据库里,…

作者头像 李华
网站建设 2026/9/2 1:09:17

FaceFusion能否做动漫风格化换脸?二次元适配测试

FaceFusion能否做动漫风格化换脸?二次元适配测试 在短视频平台和虚拟偶像内容井喷的今天,越来越多用户开始尝试“把我的脸放进动漫角色里”——这种跨次元的视觉体验早已不再是小众极客的实验项目,而是普通创作者也能触及的AI应用。然而&…

作者头像 李华
网站建设 2026/9/2 10:34:49

旅游网站|基于springboot +web旅游网站系统(源码+数据库+文档)

旅游网站 目录 基于springboot web旅游网站系统 一、前言 二、系统功能演示 三、技术选型 四、其他项目参考 五、代码参考 六、测试参考 七、最新计算机毕设选题推荐 八、源码获取: 基于springboot web旅游网站系统 一、前言 博主介绍:✌️大…

作者头像 李华
网站建设 2026/9/2 23:43:22

Gotenberg终极指南:5分钟搭建企业级文档转换服务

Gotenberg终极指南:5分钟搭建企业级文档转换服务 【免费下载链接】gotenberg A developer-friendly API for converting numerous document formats into PDF files, and more! 项目地址: https://gitcode.com/gh_mirrors/go/gotenberg 还在为复杂的文档格式…

作者头像 李华