Getting output parameters in Python


Context

Given an OTB application, I am trying to get its output parameters, e.g. out for BandMath or io.out for OrthoRectification

Configuration setup

My system: Ubuntu
Version of the OTB: 7.2
I installed the OTB with: the SuperBuild
Python version: 3.8

Description of my issue

I tried GetOutputParametersSumUp method in Python that refers to that in the C++ :

  /** Return all parameters which role is Role_Output in a vector of pairs that contains the
  * parameter key and its value.
  */
  std::vector<std::pair<std::string, std::string>> GetOutputParametersSumUp();

It seems to be fine for me but in Python all I get is a Swig object that I can not use…

How could I get the output parameters of an application ?

Hello,

Output parameters are a bit confusing in OTB. An output parameter is a parameter whose value is computed by the application. For example in the PixelValue application, which returns the value of the input image at position x,y has an output parameter value, the computed value. OutputImage parameters are not output parameter in the OTB sense, the value of the parameter is actually an input of the application (the output filename).

Regarding GetOutputParametersSumUp it looks like this method is not correctly wrapped. As you noticed the output cannot be used directly. There is something to fix here, but I actually think this function should not be wrapped at all, because I don’t think it is very useful (because of what I explained above).

If you want to get the parameters of type OutputImage of an application you can use:

import otbApplication as otb

appName = "EdgeExtraction"

app = otb.Registry.CreateApplication(appName)

for param in app.GetParametersKeys():
  if app.GetParameterType(param) == otb.ParameterType_OutputImage:
    print(param)

I hope that helps,
Cédric

2 Likes

Hi Cedric,
Thanks a lot for your answer, indeed I was not looking for actual output computed by OTB but output parameters such as filenames.
Using ParameterType_OutputImage is perfect for my usage