[Insight-users] ITK, VTK, and Python

Brian Eastwood beastwoo at email.unc.edu
Mon Jun 9 12:58:07 EDT 2008


Hi All,

I have been having problems using python-wrapped versions of ITK and 
VTK--they wrap individually just fine, but when I compile ConnectVTKITK 
from InsightApplications, and use it to link an ITK and VTK pipeline I 
get the error below with the following code:

#----
import InsightToolkit as itk
import vtk
import ConnectVTKITKPython

fileIn = "Spot-30x30-00.png"
reader = itk.itkImageFileReaderUS2.New()
reader.SetFileName(fileIn)

itkExport = itk.itkVTKImageExportUS2.New()
itkExport.SetInput(reader.GetOutput())

vtkImport = vtk.vtkImageImport()
ConnectVTKITKPython.ConnectITKUS2ToVTK(itkExport.GetPointer(), vtkImport)

writer = vtk.vtkPNGWriter()
writer.SetInput(vtkImport.GetOutput())
writer.SetFileName(fileOut)

reader.Update()
writer.Write()
#----

Here is the error:

TypeError: Type error. Got 
_p_itk__VTKImageExportTitk__ImageTunsigned_short_2u_t_t, expected 
_p_itk__VTKImageExportTitk__ImageTunsigned_short_2_t_t

I am guessing by how close the type names are that there is a slight 
difference between how type names get generated for ITK and 
InsightApplications.

I am using:
cmake 2.6, patch 0
CableSwig-ITK 3.6.0
InsightToolkit 3.6.0
InsightApplications 3.6.0
VTK 5.0.4

Has anyone gotten this to work recently?

Also, does anyone have an example CMake configuration for wrapping 
custom-written ITK objects with CableSwig?  I have modified a few of the 
wrapping config files that come with ITK, but I don't want to have to 
keep redoing this every time I update ITK; I would prefer to create my 
own wrapped project.

Thanks very much in advance,
Brian Eastwood


More information about the Insight-users mailing list