python VTK(二十六) ----图形基本操作 点云配准技术 ICP点云配准

本文介绍了使用Python和VTK进行点云配准的技术,特别是ICP(Iterative Closest Point)算法的应用。通过展示配准前后的点集对比,展示从黄色原标记点到红色目标标记点,最终转换为蓝色配准后点集的过程。
摘要由CSDN通过智能技术生成
#!/usr/bin/env python 
# -*- coding:utf-8 -*-
import vtk
# 原标记点
sourcePoints = vtk.vtkPoints()
sourcePoint1 = [0.5, 0.0, 0.0]
sourcePoints.InsertNextPoint(sourcePoint1)
sourcePoint2 = [0.0, 0.5, 0.0]
sourcePoints.InsertNextPoint(sourcePoint2)
sourcePoint3 = [0.0, 0.0, 0.5]
sourcePoints.InsertNextPoint(sourcePoint3)
# 目标标记点
targetPoints = vtk.vtkPoints()
targetPoint1 = [0.0, 0.0, 0.55]
targetPoints.InsertNextPoint(targetPoint1)
targetPoint2 = [0.0, 0.55, 0.0]
targetPoints.InsertNextPoint(targetPoint2)
targetPoint3 = [-0.55, 0.0, 0.0]
targetPoints.InsertNextPoint(targetPoint3)

landmarkTransform = vtk.vtkLandmarkTransform()  # 利用Landmark算法求变换矩阵,只需设置原标记点和目标标记点
landmarkTransform.SetSourceLandmarks(sourcePoints)
landmarkTransform.SetTargetLandmarks(targetPoints)
landmarkTransform.SetModeToRigidBody()  # 执行刚体配准,只有平移和旋转
landmarkTransform.Update()
# 进行可视化
source = vtk.vtkPolyData()
source.SetPoints(sourcePoints)

target = vtk.vtkPolyData()
target.SetPoints(targetPoints)

sourceGlyphFilter = vtk.vtkVertexGlyphFilter()   # 显示点集
sourceGlyphFilter.SetInputData(source)
sourceGlyphFilter.Update()

targetGlyphFilter = vtk.vtkVertexGlyphFilter()
targetGlyphFilter.SetInputData(target)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值