命令行界面¶
OTB发货时有100多个随时可用于遥感任务的应用程序。它们通常公开底层C++库中的现有处理函数,或者将它们集成到高级管道中。OTB应用程序允许用户:
- 组合Orfeo工具箱中的两个或多个函数,
- 提供高级接口处理:数据的输入输出、参数的定义以及与用户的通信。
OTB应用程序可以以不同的方式启动,并从不同的入口点访问。虽然该框架可以扩展,但Orfeo工具箱附带了以下内容:
- 命令行启动器,用于从终端调用应用程序,
- SWIG界面,这意味着任何应用程序都可以加载、设置和执行为高级语言,例如Python。
- A QGIS接口 基于提供者的是建立在SWIG/Python接口之上的,并且可以在 QGIS 。
本章介绍了完整的应用程序列表 所有应用程序 。
所有标准应用程序共享相同的实现,并自动公开生成的接口。但是,它们的访问方式略有不同:命令行界面的前缀是 otbcli_
。例如,调用 otbcli_DynamicConvert
将启动DynamicConvert应用程序的命令行界面。
命令行启动器¶
命令行应用程序启动器加载应用程序插件,允许设置其参数,然后可以从命令行执行。启动 otbApplicationLauncherCommandLine
在未提供任何参数的情况下,将显示以下帮助:
$ otbApplicationLauncherCommandLine
Usage: ./otbApplicationLauncherCommandLine module_name [MODULEPATH] [arguments]
这个 module_name
参数与应用程序名称对应。这个 [MODULEPATH]
参数是可选的,并允许指向与 module_name
传给发射器。
也可以使用环境变量设置此路径 OTB_APPLICATION_PATH
, making the [MODULEPATH]
optional. This variable is checked by default when no [MODULEPATH]
argument is given. When using multiple paths in OTB_APPLICATION_PATH
, one must ensure that the standard path separator of the target system is used, which is :
on Unix and `` ;``在Windows上。
应用程序名称中的错误(即参数中的错误 module_name
)将使 otbApplicationLauncherCommandLine
列出在可用路径中找到的所有应用程序的名称(或 [MODULEPATH]
和/或 OTB_APPLICATION_PATH
)。
为了简化应用程序的使用,并避免广泛的环境定制;OTB安装提供了可随时使用的脚本来启动每个应用程序。他们负责将标准应用程序安装路径添加到 OTB_APPLICATION_PATH
环境变量。
这些脚本被命名为 otbcli_<ApplicationName>
并且不需要任何路径设置。例如,您可以使用名为的脚本启动正射校正应用程序 otbcli_Orthorectification
。
启动不带参数或参数不完整的应用程序将导致启动器显示参数摘要。此摘要将显示执行应用程序所需的最小参数集。以下是一个基于正射矫正应用程序的示例:
$ otbcli_OrthoRectification
ERROR: Waiting for at least one parameter.
This is the Ortho-rectification (OrthoRectification) application, version 6.7.0
This application allows ortho-rectifying optical and radar images from supported sensors.
Complete documentation: https://www.orfeo-toolbox.org/CookBook/Applications/app_OrthoRectification.html or -help
Parameters:
-io <group> Input and output data
MISSING -io.in <string> Input Image (mandatory)
MISSING -io.out <string> [pixel] Output Image [pixel=uint8/uint16/int16/uint32/int32/float/double/cint16/cint32/cfloat/cdouble] (default value is float) (mandatory)
-map <string> Map Projection [utm/lambert2/lambert93/wgs/epsg] (mandatory, default value is utm)
-map.utm.zone <int32> Zone number (mandatory, default value is 31)
-map.utm.northhem <boolean> Northern Hemisphere (mandatory, default value is false)
-map.epsg.code <int32> EPSG Code (mandatory, default value is 4326)
-outputs <group> Output Image Grid
-outputs.mode <string> Parameters estimation modes [auto/autosize/autospacing/outputroi/orthofit] (mandatory, default value is auto)
MISSING -outputs.ulx <float> Upper Left X (mandatory)
MISSING -outputs.uly <float> Upper Left Y (mandatory)
MISSING -outputs.sizex <int32> Size X (mandatory)
MISSING -outputs.sizey <int32> Size Y (mandatory)
MISSING -outputs.spacingx <float> Pixel Size X (mandatory)
MISSING -outputs.spacingy <float> Pixel Size Y (mandatory)
-outputs.lrx <float> Lower right X (optional, off by default)
-outputs.lry <float> Lower right Y (optional, off by default)
-outputs.ortho <string> Model ortho-image (optional, off by default)
-outputs.isotropic <boolean> Force isotropic spacing by default (mandatory, default value is true)
-outputs.default <float> Default pixel value (optional, off by default, default value is 0)
-elev <group> Elevation management
-elev.dem <string> DEM directory (optional, off by default)
-elev.geoid <string> Geoid File (optional, off by default)
-elev.default <float> Default elevation (mandatory, default value is 0)
-interpolator <string> Interpolation [bco/nn/linear] (mandatory, default value is bco)
-interpolator.bco.radius <int32> Radius for bicubic interpolation (mandatory, default value is 2)
-opt <group> Speed optimization parameters
-opt.rpc <int32> RPC modeling (points per axis) (optional, off by default, default value is 10)
-opt.ram <int32> Available RAM (MB) (optional, off by default, default value is 128)
-opt.gridspacing <float> Resampling grid spacing (optional, off by default, default value is 4)
-progress <boolean> Report progress
-help <string list> Display long help (empty list), or help for given parameters keys
Use -help param1 [... paramN] to see detailed documentation of those parameters.
Examples:
otbcli_OrthoRectification -io.in QB_TOULOUSE_MUL_Extract_500_500.tif -io.out QB_Toulouse_ortho.tif
有关应用程序行为和参数的详细描述,请查看第章中提供的应用程序参考文档 所有应用程序 或遵循 DOCUMENTATION
hyperlink provided in the output of otbApplicationLauncherCommandLine
. Parameters are passed to the application using the parameter key (which might include one or several .
字符),前缀为 -
。本章提供了命令行示例 所有应用程序 。
将参数加载并保存到XML¶
OTB应用程序参数可以使用特殊的 -inxml
和 -outxml
参数。这些参数在所有应用程序中都可用。例如:
otbcli_BandMath -il input_image_1 input_image_2
-exp "abs(im1b1 - im2b1)"
-out output_image
-outxml saved_applications_parameters.xml
然后,您可以使用先前保存的输出XML文件,使用相同的参数运行应用程序。为此,您必须使用inxml参数:
otbcli_BandMath -inxml saved_applications_parameters.xml
请注意,您还可以同时向命令行添加其他参数
otbcli_BandMath -inxml saved_applications_parameters.xml
-exp "(im1b1 - im2b1)"
在本例中,它将使用“(im1b1-im2b1)”而不是“abs(im1b1-im2b1)”作为数学表达式。
使用MPI的并行执行¶
如果Orfeo工具箱已经构建并激活了MPI和SPTW模块,则可以使用MPI进行大规模并行计算和写入输出图像。一个简单的调用 mpirun
在命令行激活此行为之前,请使用以下逻辑。只有在以下情况下才会触发MPI写入:
- OTB是用MPI和SPTW构建的,
- MPI进程数大于1,
- 输出文件名为
.tif
或.vrt
在这种情况下,输出图像将根据指定给 mpirun
命令,则将并行计算所有平铺。
如果输出文件扩展名为 .tif
,平铺将使用SPTW(简单并行Tiff编写器)并行写入单个Tiff文件。
如果输出文件扩展名为 .vrt
,则每个切片将被写入单独的Tiff文件,并且全局 VRT 文件将被写入。
以下是群集上的MPI调用的示例:
$ mpirun -np $nb_procs --hostfile $PBS_NODEFILE \
otbcli_BundleToPerfectSensor \
-inp $ROOT/IMG_PHR1A_P_001/IMG_PHR1A_P_201605260427149_ORT_1792732101-001_R1C1.JP2 \
-inxs $ROOT/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201605260427149_ORT_1792732101-002_R1C1.JP2 \
-out $ROOT/pxs.tif uint16 -ram 1024
------------ JOB INFO 1043196.tu-adm01 -------------
JOBID : 1043196.tu-adm01
USER : michelj
GROUP : ctsiap
JOB NAME : OTB_mpi
SESSION : 631249
RES REQSTED : mem=1575000mb,ncpus=560,place=free,walltime=04:00:00
RES USED : cpupercent=1553,cput=00:56:12,mem=4784872kb,ncpus=560,vmem=18558416kb,
walltime=00:04:35
BILLING : 42:46:40 (ncpus x walltime)
QUEUE : t72h
ACCOUNT : null
JOB EXIT CODE : 0
------------ END JOB INFO 1043196.tu-adm01 ---------
你可以看到,Pleiades图像的全色和多光谱波段的配准和全色锐化已经在560个CPU之间分割,只用了56秒就完成了。
请注意,这种应用程序的MPI并行调用仅适用于对OTB应用程序的命令行调用,并且仅适用于图像输出参数。