diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index 97558a9e08c4705e3d2bd6d021690c0e38a5f4d3..90adda7ac354fba3bd35fae8e1aa4ef98e4297ae 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -469,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" @@ -532,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) diff --git a/Documentation/Cookbook/rst/First_Step_Linux.rst b/Documentation/Cookbook/rst/First_Step_Linux.rst index f8b90a32d31cc59c82a9d822a87c67a4914f972d..f73833122bc6670b3b711d8e524e75f349e22cb8 100644 --- a/Documentation/Cookbook/rst/First_Step_Linux.rst +++ b/Documentation/Cookbook/rst/First_Step_Linux.rst @@ -16,47 +16,37 @@ 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)" -s 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)†+ 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 ++++++++++++++++++++++++++++++ -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 # Recompile python bindings - cd /Path/To/OTB-10.0 + cd $HOME/otb source otbenv.profile sh recompile-bindings.sh diff --git a/Documentation/Cookbook/rst/First_Step_Windows.rst b/Documentation/Cookbook/rst/First_Step_Windows.rst index 9cee4514ea9d127e578b0692976d24eafbc99e19..1fd20d845031b44e32816000602b454b6d49640c 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 (see :doc:`QGISInterface` ) + 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 diff --git a/Documentation/Cookbook/rst/Installation.rst b/Documentation/Cookbook/rst/Installation.rst index 639a274583ccff810dcc95064e285434b8195950..868a24d694e36c4e09aeaa0023c6b63fdad083d6 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 8766ce24543b7fcd30bf4ae69bc496f5c6a9e882..34e33582975a9c996bc11bfcec2afefa41e0bc0e 100644 --- a/Documentation/Cookbook/rst/Installation_Linux.rst +++ b/Documentation/Cookbook/rst/Installation_Linux.rst @@ -1,5 +1,35 @@ -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. **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 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 +59,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. diff --git a/Documentation/Cookbook/rst/templates/PythonAPI.rst b/Documentation/Cookbook/rst/templates/PythonAPI.rst index 7708fd1937ef7d1eaf4d1d9b2375986c38c853ae..fb6d7a0a89c23bf8f74a86490e79a9056e224c9c 100644 --- a/Documentation/Cookbook/rst/templates/PythonAPI.rst +++ b/Documentation/Cookbook/rst/templates/PythonAPI.rst @@ -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 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: diff --git a/Packaging/Files/install-otb.sh b/Packaging/Files/install-otb.sh new file mode 100644 index 0000000000000000000000000000000000000000..89001c440f8ed6862051ef755e4ef9bcc0c0fd7a --- /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