Skip to content
Snippets Groups Projects
Commit 4817d4f8 authored by Tristan Laurent's avatar Tristan Laurent
Browse files

Merge branch 'one-line-otb-installer' into 'develop'

ENH: Add a one line otb installer

See merge request !1059
parents 146c3a9b dfc16350
No related branches found
No related tags found
1 merge request!1059ENH: Add a one line otb installer
Pipeline #16566 passed
...@@ -469,6 +469,34 @@ def GenerateRstForModules(rst_dir,otb_root): ...@@ -469,6 +469,34 @@ def GenerateRstForModules(rst_dir,otb_root):
with open(rst_dir + '/Applications/app_' + appName + '.rst', 'w',encoding='utf-8') as appFile: with open(rst_dir + '/Applications/app_' + appName + '.rst', 'w',encoding='utf-8') as appFile:
appFile.write(render_application(otb_root,appName, appList,False)) appFile.write(render_application(otb_root,appName, appList,False))
def GenerateRstForRemoteModules(rst_dir,otb_root):
otb_remote_modules_dir = os.path.join(otb_root,"Modules/Remote")
appIndexFile = open(rst_dir + '/Applications.rst', 'w')
appIndexFile.write(RstPageHeading("Applications by module", "2", ref="apprefdoc"))
moduleslist = [modname for modname in os.listdir(otb_remote_modules_dir)
if os.path.isdir(os.path.join(otb_remote_modules_dir, modname))]
moduleslist.sort()
for mod in moduleslist:
appIndexFile.write('\tApplications/'+ mod + '.rst\n')
moduleappDir = mod + "/app"
currentModuleDir = os.path.join(otb_remote_modules_dir,moduleappDir)
sortedapplist = sorted(os.listdir(currentModuleDir))
for currentApp in sortedapplist:
if ".cxx" in currentApp or ".cpp" in currentApp:
appName = currentApp.split('.')[0][3:]
modFileName = rst_dir + '/Applications/' + mod + '.rst'
if os.path.isfile(modFileName):
with open(modFileName, 'a') as tagFile:
tagFile.write("\tapp_" + appName + "\n")
else:
with open(modFileName, 'a') as tagFile:
tagFile.write(RstPageHeading(mod,"1"))
tagFile.write("\tapp_" + appName + "\n")
# Write application rst
with open(rst_dir + '/Applications/app_' + appName + '.rst', 'w',encoding='utf-8') as appFile:
appFile.write(render_application(otb_root,appName, sortedapplist,False))
def GenerateRstForApplications(rst_dir,otb_root): def GenerateRstForApplications(rst_dir,otb_root):
"Generate .rst files for all applications" "Generate .rst files for all applications"
...@@ -532,3 +560,4 @@ if __name__ == "__main__": ...@@ -532,3 +560,4 @@ if __name__ == "__main__":
#GenerateRstForApplications(args.rst_dir,args.otb_root) #GenerateRstForApplications(args.rst_dir,args.otb_root)
GenerateRstForModules(args.rst_dir,args.otb_root) GenerateRstForModules(args.rst_dir,args.otb_root)
#GenerateRstForRemoteModules(args.rst_dir,args.otb_root)
...@@ -16,47 +16,37 @@ Debian / Ubuntu ...@@ -16,47 +16,37 @@ Debian / Ubuntu
Simple OTB use case : Compute NDVI with the CLI interface Simple OTB use case : Compute NDVI with the CLI interface
````````````````````````````````````````````````````````` `````````````````````````````````````````````````````````
Download OTB Download and install OTB
++++++++++++ ++++++++++++++++++++++++
.. code-block:: bash .. code-block:: bash
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-10.0.0-Linux.tar.gz -o /Path/Download/OTB-10.0.tar.gz bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s 9.1.0 $HOME/otb
Installation
++++++++++++
.. code-block:: bash
# Install otb
cd /Path/Download
tar xvf OTB-10.0.tar.gz --one-top-level="/Path/To/Install/OTB"
source /Path/To/Install/OTB/otbenv.profile
Download an example image Download an example image
+++++++++++++++++++++++++ +++++++++++++++++++++++++
.. code-block:: bash .. code-block:: bash
curl https://www.orfeo-toolbox.org/packages/examples/phr_xs.tif -o /Path/You/Want/phr_xs.tif curl https://www.orfeo-toolbox.org/packages/examples/phr_xs.tif -o $HOME/Data/phr_xs.tif
Compute NDVI using the CLI interface Compute NDVI using the CLI interface
++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++
.. code-block:: bash .. code-block:: bash
otbcli_BandMath –il /Path/You/Want/phr_xs.tif –out /Path/You/Want/ndvi.tif –exp “(im1b4-im1b1)/ (im1b4+im1b1)” source $HOME/otb/otbenv.profile
otbcli_BandMath –il $HOME/Data/phr_xs.tif –out $HOME/Data/ndvi.tif –exp “(im1b4-im1b1)/ (im1b4+im1b1)”
Use Python API to compute NDVI Use Python API to compute NDVI
++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++
To use the Python API you have first to recompile the bindings for your version of Python. By default they are compiled for Python 3.10 To use the Python API you have first to recompile the bindings for your version of Python if this version is different than 3.10.
.. code-block:: bash .. code-block:: bash
# Recompile python bindings # Recompile python bindings
cd /Path/To/OTB-10.0 cd $HOME/otb
source otbenv.profile source otbenv.profile
sh recompile-bindings.sh sh recompile-bindings.sh
......
Windows binary packages are available for Windows 10 64bits or higher. Windows binary packages are available for Windows 10 64bits or higher.
In order to run properly, you need to make sure you installed the required system dependencies In order to run properly, you need to make sure you installed the required system dependencies
Important Note
``````````````
Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for launching OTB applications (see :doc:`QGISInterface` )
Installation of required dependencies Installation of required dependencies
````````````````````````````````````` `````````````````````````````````````
- You must have "Visual C++ Redistributable for Visual Studio 2019" installed for using this package. - You must have "Visual C++ Redistributable for Visual Studio 2019" installed for using this package.
It can be downloaded freely from `microsoft <https://aka.ms/vs/16/release/vc_redist.x64.exe>`_ It can be downloaded freely from `microsoft <https://aka.ms/vs/16/release/vc_redist.x64.exe>`_
Important Note
``````````````
Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for OTB
...@@ -24,7 +24,7 @@ OTB 10.x is known to work on: ...@@ -24,7 +24,7 @@ OTB 10.x is known to work on:
+--------------------------------------------+-------------------------------+--------------------+ +--------------------------------------------+-------------------------------+--------------------+
| RedHat 8 | GCC 8 | Python >= 3.8 | | RedHat 8 | GCC 8 | Python >= 3.8 |
+--------------------------------------------+-------------------------------+--------------------+ +--------------------------------------------+-------------------------------+--------------------+
| Windows 10 | MSVC 2019 | Python 3.10 | | Windows 10 / 11 | MSVC 2019 | Python 3.10 |
+--------------------------------------------+-------------------------------+--------------------+ +--------------------------------------------+-------------------------------+--------------------+
If you want to use another version of python you will need to recompile python bindings as explained in `"Recompiling Python Bindings" <#recompiling-python-bindings>`__. If you want to use another version of python you will need to recompile python bindings as explained in `"Recompiling Python Bindings" <#recompiling-python-bindings>`__.
......
Recommended Installation : One package containing all the modules One line installation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
For a ready to use installation, we provide a script that installs and set the environment for you :
.. code-block:: bash
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)"
This script without arguments downloads the latest version of OTB and installs it in your "$HOME/otb-OTB_VERSION".
Then, it initializes the necessary environment variables and paths and downloads the GDAL python bindings corresponding to your Python version.
After the installation, you are ready to use OTB by calling :
.. code-block:: bash
source $HOME/otb/otbenv.profile
You can customize the command by adding parameters to the one line installer :
.. code-block:: bash
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s OTB_VERSION OTB_INSTALL_DIRECTORY
**Example**
I want to download the 9.1.0 version and install it to /home/user/apps/otb :
.. code-block:: bash
bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s "9.1.0" "/home/user/apps/otb"
Manual Installation : One package containing all the modules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With OTB 9 the packaging is made by CMake to deliver a unique self extractible tar.gz to users. All you have to do is downloading the **OTB-10.0.0-Linux.tar.gz** package. With OTB 9 the packaging is made by CMake to deliver a unique self extractible tar.gz to users. All you have to do is downloading the **OTB-10.0.0-Linux.tar.gz** package.
**Important note for RedHat / Fedora / Rocky users** **Important note for RedHat / Fedora / Rocky users**
...@@ -15,8 +45,8 @@ You can download the package from the website and extract it in your file manage ...@@ -15,8 +45,8 @@ You can download the package from the website and extract it in your file manage
tar xf /Path/To/Downloads/OTB-10.0.0-Linux.tar.gz --one-top-level=/Path/To/OTB_install tar xf /Path/To/Downloads/OTB-10.0.0-Linux.tar.gz --one-top-level=/Path/To/OTB_install
source /Path/To/OTB_install/otbenv.profile source /Path/To/OTB_install/otbenv.profile
Advanced Installation : Modular installation Advanced Manual Installation : Modular installation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We provide a Core package and standalone optional packages to install over the Core for GNU/Linux x86_64. They include We provide a Core package and standalone optional packages to install over the Core for GNU/Linux x86_64. They include
all of the OTB applications along with command line launchers. all of the OTB applications along with command line launchers.
...@@ -29,7 +59,7 @@ Because OTB is a quite big software, the modular installation helps you to have ...@@ -29,7 +59,7 @@ Because OTB is a quite big software, the modular installation helps you to have
Download Download
```````` ````````
In order to run OTB you will need the **OTB-Dependencies-9.0.tar.gz** package to run the Core **AND** optional packages that you can install afterwards. In order to run OTB you will need the **OTB-Dependencies.tar.gz** package to run the Core **AND** optional packages that you can install afterwards.
Let's say you want to start using OTB only with the Core applications, and some months later you realize that you need to do more specific operations such as Learning. Let's say you want to start using OTB only with the Core applications, and some months later you realize that you need to do more specific operations such as Learning.
In that case you will just need to download the OTB-Learning package and its dependencies. In that case you will just need to download the OTB-Learning package and its dependencies.
......
...@@ -9,6 +9,19 @@ environment script ``otbenv`` to properly setup variables such as ...@@ -9,6 +9,19 @@ environment script ``otbenv`` to properly setup variables such as
source the script). In other cases, you should set these variables depending on source the script). In other cases, you should set these variables depending on
your configuration. your configuration.
Important Note for Windows Users
--------------------------------
On Windows, since Python 3.8, you have to add a call to os.add_dll_directory to be able to import modules
that are not installed on your default PYTHONPATH.
.. code-block:: python
import os
os.add_dll_directory("/Path/To/OTB_INSTALL/lib/otb/python")
os.add_dll_directory("/Path/To/OTB_INSTALL/lib/")
import otbApplication as otb
Once your environment is set, you can use OTB applications from Python, just Once your environment is set, you can use OTB applications from Python, just
like this small example: like this small example:
......
#!/bin/bash
#
# Copyright (C) 2005-2025 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script permits to build gdal bindings with python > 3.10 which is the default version in OTB 10
#Initialize variables if no input parameters has been set
OTB_VERSION="9.1.0"
INSTALL_FOLDER="$HOME/otb-$OTB_VERSION"
if [ ! -z "$1" ]:
OTB_VERSION="$1"
fi
if [ ! -z "$2" ]:
INSTALL_FOLDER="$2"
fi
# Download and install
curl https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-$OTB_VERSION-Linux.tar.gz -o /tmp/OTB-$OTB_VERSION-Linux.tar.gz
tar xf /tmp/OTB-$OTB_VERSION-Linux.tar.gz --one-top-level=$INSTALL_FOLDER
# Source the environment
. $INSTALL_FOLDER/otbenv.profile
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment