Install remote module on Windows

Hello,

I would like to install the otb-bv remote module on a Windows system but I don’t understand the steps to do so. I have installed the binary version of OTB for windows: OTB-7.1.0-Win64. I Have also installed cmake and Visual studio 2019 and cloned git depositery of otb-bv and his dependencies Phenotb (https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/wikis/remote-modules#:~:text=Remote%20modules%20allow%20anyone%20to,forking%20the%20remote%20module%20template). I read the section "including a remote module on otb"on the web page (https://wiki.orfeo-toolbox.org/index.php/How_to_write_a_remote_module) explaining how to install the add-on but I can’t find the Modules/remote folder. I found the directory “C:\OTB\OTB-7.1.0-Win64\lib\cmake\OTB-7.1\Modules” with some cmake call of remote module (for example SertitObject.cmake) but how to make the link between this file and the source code of the add-on modules.
Please, can you explain me in details the steps to install the otb_bv module under windows.
Thanks.

Ranfosic

Hello,

I don’t know these remote modules but looking at the github repos activity, I am not sure they are still maintained …

In particular, the CMake file for Phenotb does not follow the skeleton of OTB remote modules. It means that Phenotb cannot be built outside of OTB sources and that if you want to use these modules you have to re-compile OTB entirely from sources.

There are information on how to do this here. To be honest compiling OTB from sources on Windows is not super easy (there us a lot of thing to set up to make it work). But i can try to help you if you want to do it.

CMake scripts to download and compile phenotb and otb-bv are still in the library source code. When compiling OTB you can activate the module with the CMake options activated :

- Module_OTBPhenology = ON
- Module_OTBBioVars = ON

Cédric

Hello,

Thank you for your response.

I also tried to install the module TemporalGapfilling but i have this error message when i configure module with cmake gui:
“CMake Error at src/CMakeLists.txt:19 (add_library):
add_library cannot create target “OTBTemporalGapFilling” because an
imported target with the same name already exists.
CMake Error at src/CMakeLists.txt:20 (target_link_libraries):
Cannot specify link libraries for target “OTBTemporalGapFilling” which is
not built by this project.”

I send to you the log file. Can you give me an example of how to set up cmake please? I don’t understand this step.

Why is there natively a cmake file named OTBTemporalGapFilling in the directory OTB-7.1.0-Win64\lib\cmake\OTB-7.1\Modules?

The module I need is otb-bv, explained that I have to install it from source, but I would like to understand how is it possible to install a remote module for an otb binaries installation?

Thanks

François

CMakeOutput.log (11.4 KB)

Hello,

There are three ways to compile a remote module, if it follows the template (which is not the case here):

  • Compile it inside an build tree : copy the remote module in otb sources in otb/Module/Remote and build OTB with the Cmake option ModuleMyRemoteModule=ON and build otb.
  • Compile it as an external module against an OTB build tree. Build OTB sources, and then build the remote module as a cmake project and give the path of the build tree with the CMakePrefixPath option.
  • Build against an install tree (from example the binary packages), same as above, but you need to set the Cmake option OTB_BUILD_MODULE_AS_STANDALONE to ON.

In the last case, to build a remote module named MyRemoteModule you would do :

#get the source
git clone MyRemoteModule.git
mkdir build && cd build

# Cmake configuration step
cmake ..\MyRemoteModule -DCMake_Build_Type="Release" -DCMake_Prefix_Path="Path\To\OTBBinaries" -DCMake_Install_Prefix="D:\OTB\install" -G"NMake Makefiles"

# Build and install steps
nmake install

TemporalGapFilling is a remote module, but it is packaged with OTB binaries, this is why you can find it in the binaries.

otb-bv depends on TemporalGapFilling and Phenology. As I stated in my previous message, OTBPhenology cannot be built outside of a build tree (solution 1 above). You could try to modify CMake files to make it work. However I think the easiest way to compile otb-bv is to recompile otb. I just tried and managed to build it with MSVC 2019, with a few modifications to the sources (the module is not maintained anymore). Here are the steps I used (you need to have tools like git, Cmake, MSVC installed) :

# First step : go to a otb binary installation dir and uninstall otb. This will leave an xdk that you can use to compile otb. I think this is the easiest way to obtain all otb dependencies on Windows.
cd Path\To\OTBBinaryDIR
tools\uninstall_otb.bat

# Set %WORKING_DIR% where you want to download and build otb  
cd %WORKING_DIR%
# Clone otb sources into %WORKING_DIR%\otb.
git clone https://gitlab.orfeo-toolbox.org/remote_modules/remote-module-template.git

mkdir build
mkdir install
cd build

# CMake command, here I used NMake, but you can use other build system. OTB is tested on WIndows with the Ninja build system.
# This will build the default module and TemporalGapFilling, Phenology and BioVars (otb-bv).  
#If you want to build other module (other applications, or python wrapper, gui ...) you can use cmake gui to tune the configuration
cmake ../otb -G"NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%WORKING_DIR%\install -DCMAKE_PREFIX_PATH=Path\To\OTBBinaries -DCMAKE_CXX_FLAGS:STRING="/DTHROW_QCRITICAL=0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc" -DModule_OTBTemporalGapFilling=ON -DModule_OTBPhenology=ON -DModule_OTBBioVars=ON  -DOTB_USE_GSL=ON -DCMAKE_BUILD_TYPE=Release -DOTB_USE_OPENCV=ON

The CMake command will download the remote modules in otb\Modules\Remote.
Here i had to make a few patches to the sources :

  1. In Phenology sources, otb\Module\Remote\OTBPhenology\app\otbSigmoFitting.cxx : remove SetDocName(...)l53 http://tully.ups-tlse.fr/jordi/phenotb/blob/master/app/otbSigmoFitting.cxx#L53

This method has been removed in OTB 7.0.0

  1. In otb-bv sources, in otb\Module\Remote\OTBBioVars\include\otbMultiLinearRegressionModel.h l146, replace by :
TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType* quality = nullptr, ProbaSampleType* proba = nullptr) const override

The function signature has changed in the base class
http://tully.ups-tlse.fr/jordi/otb-bv/blob/master/include/otbMultiLinearRegressionModel.h#L146

I had to make two additionnal fixes, but you might not need them, depending on your configuration (MSVC version principally) :

  1. OTBTemporalGapFilling : the remote module could not find GSL libraries, adding OTBGSL to the module depency fixed it for me. In otb\Module\Remote\OTBTemporalGapFilling\otb-module.cmak you need to add OTBGSL to the dependencies, the file should be :
set(DOCUMENTATION "Time series gapfilling.")


# OTB_module() defines the module dependencies in GapFilling
# GapFilling depends on OTBCommon and OTBApplicationEngine
# The testing module in GapFilling depends on OTBTestKernel
# and OTBCommandLine

# define the dependencies of the include module and the tests
otb_module(OTBTemporalGapFilling
  DEPENDS
  OTBITK
  OTBCommon
  OTBApplicationEngine
  OTBBoost
  OTBGSL
  TEST_DEPENDS
    OTBTestKernel
    OTBCommandLine
  DESCRIPTION
    "${DOCUMENTATION}"
)

  1. I think this will only happen if you use MSVC 2019, in otb\Modules\ThirdParty\OssimPlugins\src\ossim\AlosPalsar\AlosPlasarData.h line 30 you should add the include :
#include <iostream>

You might no need it depending on your configuration. This is a bug that will be fixed, it has been noticed on linux on recent compilers (gcc 10)

Once you patched the files you can run :

nmake install

And the module should compile (hopefully)

Cédric

1 Like