[vtkusers] ICP algorithm giving eigenfunctions errors
Sean Snyders
ssnyders at wetafx.co.nz
Mon Jun 15 03:08:36 EDT 2009
Hi,
I use the example from:
http://www.vtk.org/Wiki/Iterative_Closest_Points_(ICP)_Transform
and do a direct translation thereof in python (see code listed below).
When I run the code, I get this warning:
--------------
Generic Warning: In ........./Common/vtkMath.cxx, line 758
vtkMath::Jacobi: Error extracting eigenfunctions
------------
and my output transformed points are then:
------------------
xformed source point[0]=[nan, nan, nan]
xformed source point[1]=[nan, nan, nan]
xformed source point[2]=[nan, nan, nan]
-----------------
Should this example not work? I have not tested this with the c++
implementation, but surely it should work.
Thanks!
Sean.
#--------------------------------------------------------------------------------------------------------------
def initData(self):
# ============ source points ==============
sourcePoints = vtk.vtkPoints()
sourceVertices = vtk.vtkCellArray()
id = sourcePoints.InsertNextPoint(1.0, 0.1, 0.0)
sourceVertices.InsertNextCell(id)
id = sourcePoints.InsertNextPoint(0.1, 1.1, 0.0)
sourceVertices.InsertNextCell(id)
id = sourcePoints.InsertNextPoint(0.0, 0.1, 1.0)
sourceVertices.InsertNextCell(id)
self.source = vtk.vtkPolyData()
self.source.SetPoints(sourcePoints)
self.source.SetVerts(sourceVertices)
pointCount = 3
index = 0
while index < pointCount:
point = [0,0,0]
sourcePoints.GetPoint(index, point)
print "source point[%s]=%s" % (index,point)
index += 1
#============ target points ==============
targetPoints = vtk.vtkPoints()
targetVertices = vtk.vtkCellArray()
id = targetPoints.InsertNextPoint(1.0, 0.0, 0.0)
targetVertices.InsertNextCell(id)
id = targetPoints.InsertNextPoint(0.1, 1.0, 0.0)
targetVertices.InsertNextCell(id)
id = targetPoints.InsertNextPoint(0.0, 0.0, 1.0)
targetVertices.InsertNextCell(id)
self.target = vtk.vtkPolyData()
self.target.SetPoints(targetPoints)
self.target.SetVerts(targetVertices)
icp = vtk.vtkIterativeClosestPointTransform()
icp.SetSource(self.source)
icp.SetTarget(self.target)
icp.GetLandmarkTransform().SetModeToRigidBody()
#icp.DebugOn()
icp.SetMaximumNumberOfIterations(20)
icp.StartByMatchingCentroidsOn()
icp.Modified()
icp.Update()
icpTransformFilter = vtk.vtkTransformPolyDataFilter()
icpTransformFilter.SetInput(self.source)
icpTransformFilter.SetTransform(icp)
icpTransformFilter.Update()
transformedSource = icpTransformFilter.GetOutput()
pointCount = 3
index = 0
while index < pointCount:
point = [0,0,0]
transformedSource.GetPoint(index, point)
print "xformed source point[%s]=%s" % (index,point)
index += 1
#--------------------------------------------------------------------------------------------------------------s
More information about the vtkusers
mailing list