From 1fed2cb0c12b504dff07c7415298fc7be59a7451 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 11:39:29 +0100 Subject: [PATCH 1/9] ENH: add install-otb one line install script --- Packaging/Files/install-otb.sh | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Packaging/Files/install-otb.sh diff --git a/Packaging/Files/install-otb.sh b/Packaging/Files/install-otb.sh new file mode 100644 index 0000000000..89001c440f --- /dev/null +++ b/Packaging/Files/install-otb.sh @@ -0,0 +1,39 @@ +#!/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 -- GitLab From 004818fa851d271e68053867fa83e8275d2f4caa Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 11:47:05 +0100 Subject: [PATCH 2/9] DOC: add the one liner installation instruction to the cookbook --- Documentation/Cookbook/rst/Installation.rst | 2 +- .../Cookbook/rst/Installation_Linux.rst | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Documentation/Cookbook/rst/Installation.rst b/Documentation/Cookbook/rst/Installation.rst index 639a274583..868a24d694 100644 --- a/Documentation/Cookbook/rst/Installation.rst +++ b/Documentation/Cookbook/rst/Installation.rst @@ -24,7 +24,7 @@ OTB 10.x is known to work on: +--------------------------------------------+-------------------------------+--------------------+ | 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>`__. diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index 8766ce2454..c2b2287bd5 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -1,5 +1,22 @@ -Recommended Installation : One package containing all the modules -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +One liner 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 downloads the latest version of OTB and installs it in your "$HOME/otb-OTB_VERSION". +Then, it automatically sources the otb environment, so you are ready to use OTB. + +You can customize the default installation by adding parameters to the one line installer : + +.. code-block:: bash + + bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh) OTB_VERSION OTB_INSTALL_DIRECTORY" + +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. **Important note for RedHat / Fedora / Rocky users** @@ -15,8 +32,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 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 all of the OTB applications along with command line launchers. @@ -29,7 +46,7 @@ Because OTB is a quite big software, the modular installation helps you to have 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. In that case you will just need to download the OTB-Learning package and its dependencies. -- GitLab From ff4190a676f24a1bd189452c34ce6b368f866d9d Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 14:31:07 +0100 Subject: [PATCH 3/9] DOC: fix a regression in generateWrappersRstDoc and update First steps with the one line install --- .../Scripts/otbGenerateWrappersRstDoc.py | 1 - .../Cookbook/rst/First_Step_Linux.rst | 23 +++++-------------- .../Cookbook/rst/First_Step_Windows.rst | 9 ++++---- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index 97558a9e08..7e40cde940 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -445,7 +445,6 @@ def GenerateRstForModules(rst_dir,otb_root): if os.path.isdir(os.path.join(otb_modules_dir, modname))] #Create the rst for each module moduleslist.remove("ThirdParty") - moduleslist.remove("Remote") moduleslist.sort() for mod in moduleslist: diff --git a/Documentation/Cookbook/rst/First_Step_Linux.rst b/Documentation/Cookbook/rst/First_Step_Linux.rst index f8b90a32d3..fe0ef8bb06 100644 --- a/Documentation/Cookbook/rst/First_Step_Linux.rst +++ b/Documentation/Cookbook/rst/First_Step_Linux.rst @@ -16,42 +16,31 @@ Debian / Ubuntu Simple OTB use case : Compute NDVI with the CLI interface ````````````````````````````````````````````````````````` -Download OTB -++++++++++++ +Download and install OTB +++++++++++++++++++++++++ .. 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 - - -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 + bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh) 9.1.0 $HOME/otb" Download an example image +++++++++++++++++++++++++ .. 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 ++++++++++++++++++++++++++++++++++++ .. code-block:: bash - otbcli_BandMath –il /Path/You/Want/phr_xs.tif –out /Path/You/Want/ndvi.tif –exp “(im1b4-im1b1)/ (im1b4+im1b1)†+ otbcli_BandMath –il $HOME/Data/phr_xs.tif –out $HOME/Data/ndvi.tif –exp “(im1b4-im1b1)/ (im1b4+im1b1)†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 diff --git a/Documentation/Cookbook/rst/First_Step_Windows.rst b/Documentation/Cookbook/rst/First_Step_Windows.rst index 9cee4514ea..4b6a3d08d7 100644 --- a/Documentation/Cookbook/rst/First_Step_Windows.rst +++ b/Documentation/Cookbook/rst/First_Step_Windows.rst @@ -1,13 +1,14 @@ 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 +Important Note +`````````````` + +Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for launching OTB applications + Installation of required dependencies ````````````````````````````````````` - 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>`_ -Important Note -`````````````` - -Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for OTB -- GitLab From eb39541c5fab6018bd461ae3ad3cb4a4a9536eba Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 14:36:03 +0100 Subject: [PATCH 4/9] DOC: add a note for windows users about pythonAPI for the need to add dll directory before import otbApplication --- Documentation/Cookbook/rst/templates/PythonAPI.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/Cookbook/rst/templates/PythonAPI.rst b/Documentation/Cookbook/rst/templates/PythonAPI.rst index 7708fd1937..7ef5cbd1b7 100644 --- a/Documentation/Cookbook/rst/templates/PythonAPI.rst +++ b/Documentation/Cookbook/rst/templates/PythonAPI.rst @@ -9,6 +9,20 @@ environment script ``otbenv`` to properly setup variables such as source the script). In other cases, you should set these variables depending on 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 like this small example: -- GitLab From d694d87e4974be426d151795ef2117749045bb6b Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 16:33:07 +0100 Subject: [PATCH 5/9] DOC: add generate remote modules documentation --- .../Scripts/otbGenerateWrappersRstDoc.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index 7e40cde940..ea6168d587 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -445,6 +445,7 @@ def GenerateRstForModules(rst_dir,otb_root): if os.path.isdir(os.path.join(otb_modules_dir, modname))] #Create the rst for each module moduleslist.remove("ThirdParty") + moduleslist.remove("Remote") moduleslist.sort() for mod in moduleslist: @@ -468,6 +469,34 @@ def GenerateRstForModules(rst_dir,otb_root): with open(rst_dir + '/Applications/app_' + appName + '.rst', 'w',encoding='utf-8') as appFile: 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): "Generate .rst files for all applications" @@ -531,3 +560,4 @@ if __name__ == "__main__": #GenerateRstForApplications(args.rst_dir,args.otb_root) GenerateRstForModules(args.rst_dir,args.otb_root) + GenerateRstForRemoteModules(args.rst_dir,args.otb_root) -- GitLab From 73f516768fbaaa2f7dfe0d51adb4c98d5461e455 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 17:21:47 +0100 Subject: [PATCH 6/9] DOC: update install and revert remote module doc creation as it is not working properly --- Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py | 2 +- Documentation/Cookbook/rst/Installation_Linux.rst | 6 +++--- Documentation/Cookbook/rst/templates/PythonAPI.rst | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index ea6168d587..90adda7ac3 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -560,4 +560,4 @@ if __name__ == "__main__": #GenerateRstForApplications(args.rst_dir,args.otb_root) GenerateRstForModules(args.rst_dir,args.otb_root) - GenerateRstForRemoteModules(args.rst_dir,args.otb_root) + #GenerateRstForRemoteModules(args.rst_dir,args.otb_root) diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index c2b2287bd5..86dcec8f87 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -1,5 +1,5 @@ -One liner installation -~~~~~~~~~~~~~~~~~~~~~~ +One line installation +~~~~~~~~~~~~~~~~~~~~~ For a ready to use installation, we provide a script that installs and set the environment for you : .. code-block:: bash @@ -13,7 +13,7 @@ You can customize the default installation by adding parameters to the one line .. code-block:: bash - bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh) OTB_VERSION OTB_INSTALL_DIRECTORY" + bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s OTB_VERSION OTB_INSTALL_DIRECTORY Manual Installation : One package containing all the modules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Documentation/Cookbook/rst/templates/PythonAPI.rst b/Documentation/Cookbook/rst/templates/PythonAPI.rst index 7ef5cbd1b7..fb6d7a0a89 100644 --- a/Documentation/Cookbook/rst/templates/PythonAPI.rst +++ b/Documentation/Cookbook/rst/templates/PythonAPI.rst @@ -22,7 +22,6 @@ that are not installed on your default PYTHONPATH. 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 like this small example: -- GitLab From db87dc4045227b4c0089932e3138954aa240b324 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Fri, 21 Feb 2025 17:26:01 +0100 Subject: [PATCH 7/9] DOC: update first step doc for more clarity --- Documentation/Cookbook/rst/First_Step_Linux.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Documentation/Cookbook/rst/First_Step_Linux.rst b/Documentation/Cookbook/rst/First_Step_Linux.rst index fe0ef8bb06..f73833122b 100644 --- a/Documentation/Cookbook/rst/First_Step_Linux.rst +++ b/Documentation/Cookbook/rst/First_Step_Linux.rst @@ -21,7 +21,7 @@ Download and install OTB .. code-block:: bash - bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh) 9.1.0 $HOME/otb" + bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -s 9.1.0 $HOME/otb Download an example image +++++++++++++++++++++++++ @@ -35,6 +35,7 @@ Compute NDVI using the CLI interface .. code-block:: bash + 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 @@ -45,7 +46,7 @@ To use the Python API you have first to recompile the bindings for your version .. code-block:: bash # Recompile python bindings - cd /Path/To/OTB-10.0 + cd $HOME/otb source otbenv.profile sh recompile-bindings.sh -- GitLab From 292a17954805649e1a0ffc869968fe23db197b84 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Mon, 24 Feb 2025 13:50:11 +0100 Subject: [PATCH 8/9] DOC: clarify the one line install with parameters --- .../Cookbook/rst/Installation_Linux.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/Cookbook/rst/Installation_Linux.rst b/Documentation/Cookbook/rst/Installation_Linux.rst index 86dcec8f87..34e3358297 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -6,15 +6,28 @@ For a ready to use installation, we provide a script that installs and set the e bash -c "$(curl -fsSL https://orfeo-toolbox.org/packages/install-otb.sh)" -This script downloads the latest version of OTB and installs it in your "$HOME/otb-OTB_VERSION". -Then, it automatically sources the otb environment, so you are ready to use OTB. +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. -You can customize the default installation by adding parameters to the one line installer : +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. -- GitLab From dfc1635088b16093d47615830897e449ff7ca2b3 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@cs-soprasteria.com> Date: Mon, 24 Feb 2025 15:45:25 +0100 Subject: [PATCH 9/9] DOC: add link to qgis interface on windows first steps page --- Documentation/Cookbook/rst/First_Step_Windows.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Cookbook/rst/First_Step_Windows.rst b/Documentation/Cookbook/rst/First_Step_Windows.rst index 4b6a3d08d7..1fd20d8450 100644 --- a/Documentation/Cookbook/rst/First_Step_Windows.rst +++ b/Documentation/Cookbook/rst/First_Step_Windows.rst @@ -4,7 +4,7 @@ In order to run properly, you need to make sure you installed the required syste Important Note `````````````` -Monteverdi has been removed in OTB >= 9 version, you can use QGIS which is now the default viewer for launching OTB applications +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 ````````````````````````````````````` -- GitLab