Wrapping

From OTBWiki
Revision as of 18:28, 19 November 2010 by WikiSysop (Talk | contribs) (Reverted edits by Ulofyvy (Talk); changed back to last version by Olahlou)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Java bindings

The list of class to be wrapped so as to validate the java binding process is as follows :

  • otb::ImageFileReader (to read images)
  • otb::ImageFileWriter (to write images)
  • otb::VectorData (OTB type to store vector information, ie polygons, lines, points)
  • otb::VectorDataFileReader (to read vector data files, ie shp or kml)
  • otb::VectorDataFileWriter (to write vector data files)
  • otb::ExtractROI, otb::MultichannelExtractROI, otb::MultiToMonoChannelExtractROI (to perform ROI extraction on images)
  • otb::OrthorectificationFilter (to perform orthorectification)
  • otb::SimpleRcsPanSharpeningFusionImageFilter (to perform simple pansharpening)
  • otb::HarrisImageFilter (example of ImageToImageFilter)
  • otb::MeanShiftImageFilter and otb::MeanShiftVectorIamgeFilter (to perform mean-shift segmentation)
  • otb::StandardFilterWatcher (simple filter progress printing to standard output)

These filters allow to follow most of the OTB tutorials in Java and thus to demonstrate the maturity of the bindings. Any suggestion on missing filters is welcome.


Java Modules

Open list of Java Modules:

  • Common
  • BasicFilters
  • Radiometry
  • Projections
  • FeatureExtraction
  • ChangeDetection

Technical notes on wrappings

This page is intended to describe how to wrap a new class in OTB-Wrapping project. There is no "general" process to wrap a class (each class is singular : there are non-template classes, template classes with scalar parameters, template classes with image parameters, template classes with template class parameters, etc.) but the wrapping mecanism will be explained.

Note : Each following path/file is given in relative path from OTB-Wrapping root.

Each class to be wrapped has to be defined in a wrap_<explicit_name>.cmake file (explicit_name can be the otb class name for example). These files are in Modules/XXX, where XXX is a module name (like Base, Common, IO, etc.) But we can also declare several classes to be wrapped in a same .cmake file (a .cmake for each class is not mandatory !)

All macros used to wrap otb classes or in the CMakeLists files are defined in the following files : TypedefMacros.cmake WrapBasicTypes.cmake The file WrapITKTypes.cmake defines types used in wrap_X.cmake. These types are template parameters, and can be scalar types (unsigned char, short, double, ...) or more complex types (otbImage, otbVectorImage, ...). If a class to be wrapped has a parameter type not defined in those 2 files, you can :

 - Define it there (WrapITKTypes.cmake)!
 - use the true mangling of the template for example otb::Vector<${ITKT_F${d}}> wich is equivalent to otb::Vector<float,2> if ${ITKT_F} == float 

Note : Some basic types in C++ have not been wrapped by SWIG (like char**), so new SWIG code has be written in itk.swg file to convert it in String[] compatible with JAVA. If some other conversion have to be done, SWIG code has to be written in this file !

Some cases will be detailed below.


Wrap a non-template class

MACRO to use : WRAP_NON_TEMPLATE_CLASS.

Careful : the .cmake file name which define this class CANNOT be wrap_<name_of_the_otb_class>.cmake In fact, generated cxx/java files cannot have the same name than <name_of_the_otb_class>. There is no problem when class is templated, because generated class has the following name : <name_of_the_otb_class><instanciated_type1>(<instanciated_type2>...).

Example : Librairies/otbCommon/wrap_otbCommandLineArgumentParserNT.cmake


Wrap a template class with scalar parameters

MACRO to use : WRAP_CLASS, WRAP_TEMPLATE

Example : Librairies/otbCommon/wrap_otbMultiToMonoChannelExtractROI.cmake


Wrap a template class with otbImage parameters

MACRO to use : WRAP_CLASS, WRAP_IMAGE_FILTER* (possible with WRAP_TEMPLATE too)

This is the most simple case, because WrapITK has written basic MACROs for that case, named WRAP_IMAGE_FILTER*.

Example : Librarires/otbFeatureExtraction/wrap_otbHarrisImageFilter.cmake


Wrap a template class with other template class parameters

MACRO to use : WRAP_CLASS, WRAP_TEMPLATE

This is the most complex type, because the template class parameter has to be added as a type in WrapITKTypes.cmake.

Careful : This is not OK atm.

Example : Librarires/otbBasicFilters/wrap_otbPerBandVectorImageFilter.cmake


General Warnings

  • If several non-template classes are in a same OTB file, WRAP_NON_TEMPLATE_MULTI_CLASS_IN_SAME_FILE MACRO has to be used (new macro for OTB-Wrapping).
  • If several template classes are in a same OTB file, then a new macro has to be written...

Roadmap to the 50 wrapped classes

Basic filtering

  • general thresholding
  • gradient magnitude
  • canny edge detection
  • mean filter
  • median filter
  • mean shift filtering and clustering

Metrics???

Segmentation

  • connected threshold
  • fast marching segmentation

Classification

  • k-means clasification
  • SVM

Feature Extraction

  • harris detector
  • sift detector
  • surf detector
  • geometrics moments
    • complex moments for images

Developper (Base)

  • ImageRegionIterator
  • NeighborhoodIterator