#!/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)
python VTK(二十六) ----图形基本操作 点云配准技术 ICP点云配准
最新推荐文章于 2024-08-31 07:30:00 发布
本文介绍了使用Python和VTK进行点云配准的技术,特别是ICP(Iterative Closest Point)算法的应用。通过展示配准前后的点集对比,展示从黄色原标记点到红色目标标记点,最终转换为蓝色配准后点集的过程。
摘要由CSDN通过智能技术生成