ITK/Python Wrapping: Difference between revisions

From KitwarePublic
< ITK
Jump to navigationJump to search
(Started the page)
 
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Python Wrapping ==
{{Historical}}
 
= Python Wrapping =


This section describes how to wrap ITK classes for being used from Python.
This section describes how to wrap ITK classes for being used from Python.


Since slight differences exist depending on the platform where the wrapping is done, this section will describe those platforms independently.
== Step 1: Make sure the python headers are installed ==
 
Python will need to be installed along with the Python development headers (Python.h).


=== Microsoft Windows ===
If you need to specify a specific Python version or a custom location of the headers, the following CMake configuration variables can be modified:


In order to wrap ITK for Python under Microsoft Windows you must start by gathering the following materials - at least this is the configuration with which I succeeded
* PYTHON_INCLUDE_DIR
* PYTHON_LIBRARY
* PYTHON_EXECUTABLE
* PY_SITE_PACKAGES_PATH


# Python 2.4
== Step 2: Turn on Python wrapping in the ITK configuration ==
# ITK CVS version posterior to July 10 2004 - I used 3.2.0
# CableSwig- I used 2.2


It is convenient to use CSwig from CVS and to check it out inside the source tree of ITK. However this is not necessary as the path to CableSwig can be set in the CMake configuration for ITK.
Turn ''ON'' the CMake configuration ''ITK_WRAP_PYTHON''.


CMake configuration:
== Step 3: Select the pixel types and dimensions to build ==


# Compiler: I tried MS Visual Studio Express which failed. However, I think this because VS Express does not include the MS Windows SDK. I believe that installing that (free download from MS) and adding it to the "VC directories" paths correctly in VS Express will make it work. I have MS VC 2003 .NET as well, and both CableSwig and ITK compiled without errors.  
You can choose what pixel types and dimensions to build into the wrapped interface. There is a trade-off between the number of pixel types and images dimensions supported and the amount of compilation time required and the size of the wrapping libraries.


# Shared Libs ON
For the dimensions to support, set the CMake configuration variable ''ITK_WRAP_DIMS''.  This is a semi-colon delimited string containing the dimensions to support (Image dimensions, etc).  The default is ''2;3''.
# ITK_CSWIG_PYTHON ON
# Set the python paths (Advanced Values), don't worry about PYTHON_DEBUG_LIBRARY
# ITK_EXPLICIT_INSTANTATION must be off.


Open ALL_BUILD in MSVC, select the configuration you want (Release, RelWithDebugInfo etc) and build for a long time.
The pixel types to support are boolean variables in the pattern ''ITK_WRAP_<pixel type>''.  For instance,


* ''ITK_WRAP_float''
* ''ITK_WRAP_rgb_unsigned_char''
* ''ITK_WRAP_vector_double''
* ''ITK_WRAP_complex_double''




=== Linux ===


{{ITK/Template/Footer}}
{{ITK/Template/Footer}}

Latest revision as of 20:04, 8 August 2017

Python Wrapping

This section describes how to wrap ITK classes for being used from Python.

Step 1: Make sure the python headers are installed

Python will need to be installed along with the Python development headers (Python.h).

If you need to specify a specific Python version or a custom location of the headers, the following CMake configuration variables can be modified:

  • PYTHON_INCLUDE_DIR
  • PYTHON_LIBRARY
  • PYTHON_EXECUTABLE
  • PY_SITE_PACKAGES_PATH

Step 2: Turn on Python wrapping in the ITK configuration

Turn ON the CMake configuration ITK_WRAP_PYTHON.

Step 3: Select the pixel types and dimensions to build

You can choose what pixel types and dimensions to build into the wrapped interface. There is a trade-off between the number of pixel types and images dimensions supported and the amount of compilation time required and the size of the wrapping libraries.

For the dimensions to support, set the CMake configuration variable ITK_WRAP_DIMS. This is a semi-colon delimited string containing the dimensions to support (Image dimensions, etc). The default is 2;3.

The pixel types to support are boolean variables in the pattern ITK_WRAP_<pixel type>. For instance,

  • ITK_WRAP_float
  • ITK_WRAP_rgb_unsigned_char
  • ITK_WRAP_vector_double
  • ITK_WRAP_complex_double




ITK: [Welcome | Site Map]