Commit 0f12cf0f authored by Manuel Grizonnet's avatar Manuel Grizonnet

Merge branch 'otb_app_python' into 'otb_app_python'

Otb app python

See merge request !1
parents bdb43589 67ce638c
......@@ -50,13 +50,13 @@ Install a minimal command line environment for Windows. For instance, Git for Wi
To install OTB and Monteverdi, download the appropriate package for your architecture (32 or 64 bits). If you have a 32 bit machine:
If you have a 64 bit machine:
These files are available at:
......@@ -80,7 +80,7 @@ $\rightarrow$ "OTB-Applications browser".
(see figure \ref{fig:windows-mapla}).
\item Go to the \texttt{bin} folder in the OTB install directory and double-click on the \texttt{.bat} file corresponding to the application to be run, for instance:\\
(see figure \ref{fig:windows-otbgui}).
......@@ -159,15 +159,15 @@ Download the self-extracting binary for Linux (64 bits), available at:
The self-extracting binary will extract itself in the current directory. First, the archive has to be made executable, and then it can be run:
chmod +x
chmod +x
The executable binaries will be inside the 'bin' directory, and you can put this directory in your PATH variable if you want to.
There are also scripts which set all the environment variables to allow to run Monteverdi and Mapla:
cd OTB-6.2.0-rc1-Linux64
cd OTB-6.4.0-Linux64
......@@ -194,8 +194,41 @@ $\rightarrow$ "OTB-Applications browser".
The software can also be installed on Mac OS X.
First install QGIS using the instructions for Mac OS X on the official site. To install OTB and Monteverdi download from \url{}. from \url{}.
This is a self-extracting binary which extracts itself in the current directory. Testing the installation is done like in the Linux case.
\section{Python install for OTB}
Starting from OTB 5.8.0, OTB bindings for Python 2.7 are distributed with binary package. With OTB 6.4.0, additional bindings for Python 3.5 are also included. Please note that using a different Python version may not be compatible with OTB wrappings. If no compatible Python 2.x version is found a notification is generated during the installation process. If the installation completes without issue, information relating to your Python bindings will be provided.
You must have Python numpy bindings installed in your system. They can be installed locally without admin rights as follows: “pip install –user numpy”. This is to give users the option to select their own existing Python installation rather than the one dibstributed by the OTB package.
By default, bindings for Python 2.7 will be enabled with the otbenv script. If you want to use bindings for Python 3.5, you can copy this script and modify:
lib/python into lib/python3, for variable PYTHONPATH
\item You must use monteverdi and mapla through and helper scripts in extracted directory.
\item The helper scripts for monteverdi and mapla set required environment variables
\item You might be tempted to move “OTB-6.4.0-Linux64” into another location say /usr/local/ after extraction. But avoid this action!
\item To have “OTB-6.4.0-Linux64” installed in /usr/local or /opt execute “” in that directory.
\item Multiple installation of OTB can exists in same system without one conflicting the other!
In order to test the Python OTB dependencies, try:
\item Load the environment variables (Linux : sourcing the otb.profile; Windows: executing otbenv.bat)
\item Launch the python console (Linux: execute python ; Windows: python.exe)
\item Execute in the python console : import numpy
\item Execute in the python console : import otbApplication
If no error message is printed after the import commands, everything is fine. If not, check the Python version (2.7 or 3.5), and the PATH,OTB_APPLICATION_PATH and PYTHONPATH variables.
This diff is collapsed.
** The Orfeo ToolBox Application mechanism :slides:
*** Data and Objectives
**** Objectives
- Know how to set the environnement to use OTB application in Python
- Know how to set application parameter in Python
- Know how to use in memory connection of applications
- Know how to use OTB/NumPy bridge.
**** Data
Data can be found in folder ~Data/otb-python/~.
*** Outline
This exercise consists in coding a Python script to perform surface water
extraction on Sentinel-2 images over the area of /Laguna la nina/ in Peru.
#+ATTR_LaTeX: width=0.95\textwidth center
(Twitter pic from @hombredeltiempo)
*** Quick introduction to OTB applications
- Orfeo ToolBox is a *library* offering remote sensing features
- Often several features of OTB must be combined within a processing chain
- Need for higher level interfaces (parameters, input and output data, logs ...)
- Each application corresponds to a high level function (segmentation, orthorectification, raster calculator ...)
- And corresponds to a C++ class (/otb::Application/) $\rightarrow$ library
- Plugin mechanism
- One can develop and distribute his/her own homemade applications
*** OTB applications in Python
- Library called *otbApplication*
- 2 main classes can be manipulated:
- Registry: list available applications (or create some)
- Application: base class for all applications (interact with an
- Example:
#+begin_src python
import otbApplication
*** Syntax
- Getters
#+begin_src python
- Setters
#+begin_src python
app.SetParameterString("in", argv[1])
- How to launch an application
- Execute() -> wire the pipeline
- ExecuteAndWriteOutput() -> wire the pipeline and write output
*** Syntactic sugar
- Instead of:
#+begin_src python
ExtractROI.SetParameterInt('startx', 140)
- Use:
#+begin_src python
- Upper case is mandatory for now
*** In-memory connection
- Applications are often use as parts of larger workflow
- Heavy I/O operations generally in remote sensing image processing
- Connect output parameter from app1 to the input parameter of app2
- Available both in C++ API and Python
- Related to ITK/OTB streaming mechanisms
*** NumPy bridge
- Plug OTB into any image processing chain in Python
- Use etImageFromNumpyArray() and SetImageFromNumpyArray() methods
*** Useful links
- [[][Introduction to OTB applications]]
- [[][Application Reference Documentation]]
- Application help: /otbcli\textunderscore{}XXX -help/
** Utiliser les applications OTB en Python (TODO) :slides:
*** Objectifs et données
**** Objectifs
- Savoir configurer l'environnement pour utiliser les applications en Python
- Savoir paramétrer une application OTB en Python
- Savoir utiliser la connexion en mémoire entre applications
- Savoir utiliser le /bridge/ entre OTB et NumPy
**** Données
Les données se trouvent dans le répertoire ~Data/otb-python/~.
*** Déroulement
Le TP consiste à mettre en place un script Python pour réaliser l'extraction
des surfaces en eaux dans une série d'images Sentinel-2 sur le zone de
/Laguna la nina/ au Pérou.
#+ATTR_LaTeX: width=0.95\textwidth center
(photo Twitter de @hombredeltiempo)
*** OTB-Applications en Python
#+begin_src python
import otbApplication
*** Liens utiles
- [[][Introduction aux OTB applications]]
- [[][Documentation de référence des applications]]
- [[][Exemples utilisation des OTB applications]]
- Aide d'une application: /otbcli\textunderscore{}XXX -help/
......@@ -51,6 +51,7 @@ image processing chains using OTB applications, including:
- Classification
- Segmentation
- Synthetic Aperture Radar processing
- OTB Application Python API
** Training kit
*** Data package
......@@ -130,4 +131,6 @@ For more information on these satellites:
#+INCLUDE: "" :minlevel 2
#+INCLUDE: "" :minlevel 1
* SAR processing on Sentinel-1 images
#+INCLUDE: "" :minlevel 2
#+INCLUDE: "" :minlevel 2
* Using OTB Application in Python
#+INCLUDE: "" :minlevel 2
......@@ -122,3 +122,5 @@ Know how to set up OTB processing and use OTB applications to perform:
#+INCLUDE: "" :minlevel 2
* TP4: SAR processing with Sentinel-1
#+INCLUDE: "" :minlevel 2
* TP5: OTB Applications in Python
#+INCLUDE: "" :minlevel 2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment