I went to calculater a transform between two models.
Then I searched and found such module :https://github.com/SlicerIGT/SlicerIGT/blob/master/ModelRegistration/ModelRegistration.py
but when I run this code in python cli, I get an error just like the post title.
def MR(inputSourceModel, inputTargetModel, outputSourceToTargetTransform, transformType=0, numIterations=100 ):
delayDisplay('Running iterative closest point registration')
icpTransform = vtk.vtkIterativeClosestPointTransform()
icpTransform.SetSource(inputSourceModel.GetPolyData() )
icpTransform.SetTarget(inputTargetModel.GetPolyData() )
icpTransform.GetLandmarkTransform().SetModeToRigidBody()
if transformType == 1:
icpTransform.GetLandmarkTransform().SetModeToSimilarity()
if transformType == 2:
icpTransform.GetLandmarkTransform().SetModeToAffine()
icpTransform.SetMaximumNumberOfIterations( numIterations )
icpTransform.Modified()
icpTransform.Update()
outputSourceToTargetTransform.SetAndObserveMatrixTransformToParent(vtk.vtkMatrix4x4())
if slicer.app.majorVersion >= 5 or (slicer.app.majorVersion >= 4 and slicer.app.minorVersion >= 11):
outputSourceToTargetTransform.AddNodeReferenceID(slicer.vtkMRMLTransformNode.GetMovingNodeReferenceRole(), inputSourceModel.GetID())
outputSourceToTargetTransform.AddNodeReferenceID(slicer.vtkMRMLTransformNode.GetFixedNodeReferenceRole(), inputTargetModel.GetID())
return True
inputSourceModel = getNode("a")
inputTargetModel = getNode("b")
MR(inputSourceModel, inputTargetModel, "aTob", transformType=0, numIterations=100)
If I went to calculate a transform between two models, and which code is right?
Thanks.