[Insight-users] Wrapping a custom C++ function in Python
Julien Lamy
lamy at unistra.fr
Mon Jun 8 09:12:03 EDT 2009
Hi list,
I'm trying to wrap a simple C++ function in Python using WrapITK, but
the Python script fails with the following traceback :
TypeError: in method 'test_wrapper', argument 1 of type 'itk::Image<
unsigned short,3 > *'
WrapITK otherwise works fine (thank you for those wrappers :) )
My C++ function is :
bool test_wrapper(itk::Image<unsigned short, 3>::Pointer input)
{
std::cout << input->GetRequestedRegion().GetSize() << std::endl;
}
My Python script is :
import numpy
import itk
from Wrapper import test_wrapper
data = numpy.arange(3*5*7, dtype=numpy.uint16).reshape((3,5,7))
image_itk = itk.PyBuffer[itk.Image[itk.US, 3]].GetImageFromArray(data)
test_wrapper(image_itk)
My SWIG wrapper is :
%module Wrapper
%{
#include "test_Wrapper.hpp"
%}
bool test_wrapper(itk::Image<unsigned short, 3> * input);
Is there a specific module I should add to the SWIG wrapper ? I'm using
ITK 3.14, SWIG 1.3.35, gcc 4.3.2, and Python 2.5.2.
Thanks in advance,
--
Julien Lamy
More information about the Insight-users
mailing list