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:
\begin{verbatim}
OTB-6.2.0-rc1-Win32.zip
OTB-6.4.0-Win32.zip
\end{verbatim}
If you have a 64 bit machine:
\begin{verbatim}
OTB-6.2.0-rc1-Win64.zip
OTB-6.4.0-Win64.zip
\end{verbatim}
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:\\
\texttt{John{\textbackslash}install{\textbackslash}OTB-6.2.0-rc1-win32{\textbackslash}bin{\textbackslash}otbgui\_Rescale.bat}
\texttt{John{\textbackslash}install{\textbackslash}OTB-6.4.0-win32{\textbackslash}bin{\textbackslash}otbgui\_Rescale.bat}
(see figure \ref{fig:windows-otbgui}).
\end{enumerate}
......@@ -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:
\begin{verbatim}
chmod +x OTB-6.2.0-rc1-Linux64.run
./OTB-6.2.0-rc1-Linux64.run
chmod +x OTB-6.4.0-Linux64.run
./OTB-6.4.0-Linux64.run
\end{verbatim}
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:
\begin{verbatim}
cd OTB-6.2.0-rc1-Linux64
cd OTB-6.4.0-Linux64
./monteverdi.sh
./mapla.sh
\end{verbatim}
......@@ -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
OTB-6.2.0-rc1-Darwin64.run from \url{https://www.orfeo-toolbox.org/download/}.
OTB-6.4.0-Darwin64.run from \url{https://www.orfeo-toolbox.org/download/}.
This is a self-extracting binary which extracts itself in the current directory. Testing the installation is done like in the Linux case.
\clearpage
\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:
\begin{verbatim}
lib/python into lib/python3, for variable PYTHONPATH
\end{verbatim}
Notes:
\begin{enumerate}
\item You must use monteverdi and mapla through mapla.sh and monteverdi.sh 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 “OTB-6.4.0-Linux64.run” in that directory.
\item Multiple installation of OTB can exists in same system without one conflicting the other!
\end{enumerate}
\subsection{Test}
In order to test the Python OTB dependencies, try:
\begin{enumerate}
\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
\end{enumerate}
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.
\end{document}
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.
#+begin_center
#+ATTR_LaTeX: width=0.95\textwidth center
[[file:Images/lluvias-peru.jpg]]
#+end_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
application
- Example:
#+begin_src python
import otbApplication
orth=otb.Registry.CreateApplication("OrthoRectification")
#+end_src
*** Syntax
- Getters
#+begin_src python
app.GetParametersKeys()
#+end_src
- Setters
#+begin_src python
app.SetParameterString("in", argv[1])
#+end_src
- 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)
#+end_src
- Use:
#+begin_src python
ExtractROI.STARTX=140
#+end_src
- 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
- [[https://www.orfeo-toolbox.org/CookBook/OTB-Applications.html][Introduction to OTB applications]]
- [[https://www.orfeo-toolbox.org/CookBook/Applications.html][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.
#+begin_center
#+ATTR_LaTeX: width=0.95\textwidth center
[[file:Images/lluvias-peru.jpg]]
#+end_center
(photo Twitter de @hombredeltiempo)
*** OTB-Applications en Python
#+begin_src python
import otbApplication
orth=otb.Registry.CreateApplication("OrthoRectification")
#+end_src
*** Liens utiles
- [[https://www.orfeo-toolbox.org/CookBook/CookBookse1.html#x7-60001.1][Introduction aux OTB applications]]
- [[https://www.orfeo-toolbox.org//Applications/][Documentation de référence des applications]]
- [[https://www.orfeo-toolbox.org/CookBook/CookBookch3.html#x38-370003][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: "segmentation-en.org" :minlevel 2
#+INCLUDE: "classification-en.org" :minlevel 1
* SAR processing on Sentinel-1 images
#+INCLUDE: "sar-en.org" :minlevel 2
#+INCLUDE: "sar-en.org" :minlevel 2
* Using OTB Application in Python
#+INCLUDE: "app-python-en.org" :minlevel 2
......@@ -122,3 +122,5 @@ Know how to set up OTB processing and use OTB applications to perform:
#+INCLUDE: "classification-en.org" :minlevel 2
* TP4: SAR processing with Sentinel-1
#+INCLUDE: "sar-en.org" :minlevel 2
* TP5: OTB Applications in Python
#+INCLUDE: "app-python-en.org" :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