Skip to content

ApplicationEngine new services

Guillaume Pasero requested to merge appli_new_services into develop


This MR contains new service in the core of ApplicationEngine, as well as improvements for the Python wrappings


See the issue #1514 for more details. This MR addresses the points about new services and metadata for Numpy arrays.

Implementation Details

Classes and files

M       Modules/Core/ImageBase/include/otbImage.h

Small fix for the SetSignedSpacing() template function.

M       Modules/Core/Streaming/include/otbPipelineMemoryPrintCalculator.h
M       Modules/Core/Streaming/src/otbPipelineMemoryPrintCalculator.cxx

I have added an optional flag in PipelineMemoryPrintCalculator::Compute() to avoid the propagation step. This is useful if you want to compute the memory print on a pipeline with a specific requested region already set.

A       Modules/Wrappers/ApplicationEngine/include/otbWrapperMetaDataHelper.h
A       Modules/Wrappers/ApplicationEngine/src/otbWrapperMetaDataHelper.cxx

A new helper class that instanciate the different Getter/Setter template function to manipulate a MetaDataDictionary.

M       Modules/Wrappers/ApplicationEngine/include/otbWrapperApplication.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexInputImageParameter.txx
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperComplexOutputImageParameter.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageListParameter.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperInputImageParameter.txx
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputImageParameter.h
M       Modules/Wrappers/ApplicationEngine/include/otbWrapperTypes.h
M       Modules/Wrappers/ApplicationEngine/src/CMakeLists.txt
M       Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
M       Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexInputImageParameter.cxx
M       Modules/Wrappers/ApplicationEngine/src/otbWrapperComplexOutputImageParameter.cxx
M       Modules/Wrappers/ApplicationEngine/src/otbWrapperInputImageParameter.cxx
M       Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputImageParameter.cxx

In a nutshell:

  • the ImageBaseType is now unique for the whole ApplicationEngine framework, no need to duplicate it in various parameters
  • New functions in class otb::Wrapper::Application to provide an interface with underlying Image objects:
    • GetImageOrigin()
    • GetImageSpacing()
    • GetImageSize(): returns the size of the LargestPossibleRegion
    • GetImageNbBands(): returns the number of components per pixel
    • GetImageProjection(): returns the ProjRef
    • GetImageKeywordlist(): returns the Ossim keywordlist
    • GetImageMetaData(): returns the itk::MetaDataDictionary
    • GetImageRequestedRegion()
    • PropagateRequestedRegion(): set a given RequestedRegion on the image and propagate it, returns the memory print estimation
    • GetImageBasePixelType(): helper function to guess the pixel type of the underlying Image/VectorImage.
    • GetParameterImageBase(): helper, returns the image as a ImageBaseType (works on all image parameters)
    • SetParameterImageBase(): helper, sets the parameter InputImage/InputImageList/ComplexInputImage with an ImageBaseType

Note: some of these function use an optional index to refer to an image parameter. By default this index is 0. It allows to access InputImageLists transparently.

M       Modules/Wrappers/SWIG/src/itkBase.i
M       Modules/Wrappers/SWIG/src/itkBase.includes
M       Modules/Wrappers/SWIG/src/otbApplication.i
M       Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h

Improvements on the SWIG wrappings:

  • wrapping of ITK base classes such as Size, Index, Region, Point, ... Specific for Python: enhancements added to manipulate these objects as lists (support operator[], len(), str())
  • wrapping of itk::MetaDataDictionary, helper functions have been added to get/set values without using ExposeMetadata/EncapsulateMetadata. Specific for Python: it behaves like a Python dict.
  • wrapping of other base classes such as OTB_GCP, ImageKeywordlist, VectorDataKeywordlist. Specific for Python: ImageKeywordlist behaves like a dictionary
  • refactoring of Numpy C++ code
    • shorter using the new helper functions
    • better handling of numpy.ndarray with 2D or 3D shapes
    • new Import/Export function that preserve metadatas

The new ExportImage mechanism for Numpy arrays returns a Python dictionary with the following layout:

  • dict['array'] is the Numpy ndarray
  • dict['origin'] is the image origin (itkPoint)
  • dict['spacing'] is the image spacing (itkVector)
  • dict['size'] is the size of largest possible region (itkSize)
  • dict['region'] is the buffered region present in 'array' (itkRegion)
  • dict['metadata'] is the MetaDataDictionary (itkMetaDataDictionary)


No change


M       Modules/Wrappers/ApplicationEngine/test/CMakeLists.txt
M       Modules/Wrappers/ApplicationEngine/test/otbApplicationEngineTestDriver.cxx
A       Modules/Wrappers/ApplicationEngine/test/otbWrapperImageInterface.cxx
M       Modules/Wrappers/SWIG/test/python/CMakeLists.txt
A       Modules/Wrappers/SWIG/test/python/

New tests have been added for these image interface services.


The Python recipe has been filled with documentation about the new services.

Additional notes

Edited by Guillaume Pasero

Merge request reports