Chapter 2
Installation

This section describes the process for installing OTB on your system. OTB is a toolbox, and as such, once it is installed in your computer, provided by default a set of useful libraries. You can use these libraries to build your own applications based on it. By default, What OTB does provide—besides the toolbox proper—is a large set of test files and examples that will introduce you to OTB concepts and will show you how to use OTB in your own projects.

Since the release 3.12, OTB embedded a specific framework to generate applications in more user-friendly way. The majority of the applications available in the OTB-Applications packages have been revamped into the main OTB package. Now if you activate the specific option BUILD_APPLICATIONS, OTB build for each application one shared library (also known as plugin). This plugin can be auto-loaded into appropriate tools wihtout recompiling, and is able to fully describe its parameters, behaviour and documentation.

The tools to use these plugins can be extended, but OTB shipped the following:

For the moment, the former OTB-Applications package will be keep available but will no longer be maintained.

The classical OTB powered applications are keep available and will continue to be maintained:

Monteverdi
An integrated applications giving graphical access to a lot of OTB functionnalities.
OTB-Wrapping
Calling OTB from Python or Java (see chapter 34).

There are two ways to install OTB on your system: installing from a binary distribution, or compiling from sources. What you need depends on your system, and on what you intend to do. Table 2.1.







OTB library and internal applications

Monteverdi

OTB-Applications

Wrapping (Java and Python)






Any platform

Build from source (see section 2.2)

Build from source (see section 2.2)

Build from source (see section 2.2)

Build from source (see section 2.2)






Windows 2000/XP/Vista/Seven

OSGeo4W installer for internal applications

Windows or OSGeo4W installer (see section 2.1.1)

Windows installer (see section 2.1.1)

Windows or OSGeo4W installer (see section 2.1.1)






MacOS X 10.5 and higher

app’s DMG file (see section 2.1.2)






Ubuntu Linux 11.10, 11.04, 10.10 and 10.04 (32/64 bits)

APT repository (see section 2.1.3)

APT repository (see section 2.1.3)

APT repository (see section 2.1.3)






OpenSuse 11.X and higher (32/64 bits)

RPM package (see section 2.1.3)

RPM package (see section 2.1.3)

RPM package (see section 2.1.3)






CentOS 5.5 and higher (32/64 bits)

RPM package (see section 2.1.3)

RPM package (see section 2.1.3)

RPM package (see section 2.1.3)







Table 2.1: Available installation procedures with respect to system configuration and target usage

2.1 Installing binary packages

2.1.1 Windows 2000/XP/Vista/Seven

For Windows 2000/XP/Vista/Seven users, classical installation programs exists for Monteverdi, old OTB-Applications and OTB-Wrapping. This is the old way, we recommend to use the new install process directly through OSGeo4W which is described later in this paragraph.

The classical installers depends on dependencies that can be installed through OSGeo4W. The packages that need to be installed are:

Remember that the corresponding dlls are to be accessible in the system path. To ensure so, add the OSGeo4W bin directory to your system path.

Once the dependencies have been properly installed, please go the the OTB download page, to get the installer. Double-click on the installer and let it guide you through the installation process.

Since OTB 3.12, we provide OTB packages through OSGeo4W for new OTB Applications, Monteverdi and OTB-Wrapping. This packages are available directly in the OSGeo4W installer with the following names:

Select the package you want add let it guide by the installation process which will manage the installation of all dependecies needed. In the case of otb-monteverdi, monteverdi will be directly install in OSGeo4W repository and some shortcuts will be added to your desktop and in the start menu. You can now use directly monteverdi from your desktop, from the starter menu and from an OSGeo4W shell with command monteverdi. For the otb-bin packages, it will be available directly in the OSGeo4W shell, for example otbgui_BandMath. We recommended to use this way to install the OTB packages on Windows. If you want use the otb-python package, for example in QGIS, please following the install note found in the OTB wiki. You can simply check into a OSGeo4W shell the list of available application:

python  
import otbApplication  
print str( otbApplication.Registry.GetAvailableApplications() )

For more information you can read the OTB Cookbook which provide useful information about these new OTB Application.

2.1.2 MacOS X

For MacOS X, a .dmg file is available for Monteverdi for MacOS X 10.5 and higher. Please go the the OTB download page. Click on the file to launch Monteverdi.

2.1.3 Linux

Ubuntu 10.04, 10.10, 11.04 and 11.10

For Ubuntu 10.04 (Lucid Lynx), 10.10 (Maverick Meerkat), 11.04 (Natty Narwhal) and 11.10 (Oneiric), OTB, OTB-Applications, Monteverdi and OTB-Wrapping packages are available through APT repositories.

If you are using apt command-line tools, use these command-lines to add the otb repository to apt sources:

sudo aptitude install add-apt-repository  
sudo add-apt-repository ppa:otb/orfeotoolbox-stable

Now run:

sudo aptitude update

If you want only OTB libraries, please use:

sudo aptitude install libotb otbapp monteverdi otb-wrapping-python otb-wrapping-java

If you want old OTB Applications, please use:

sudo aptitude install otbapp

If you want new OTB Applications, please use:

sudo aptitude install otb-bin otb-bin-qt otb-python

If you want monteverdi application, please use:

sudo aptitude install monteverdi

If you want Python/Java wrapping, please use:

sudo aptitude install otb-wrapping-python otb-wrapping-java

If you are using Synaptic, you can add the repositories, update and install the packages through the graphical interface.

If you want to use OTB with bleeding edge versions of gdal and qgis, there is an alternate UbuntuGIS repository. You can add it by using these command-lines:

sudo aptitude install add-apt-repository  
sudo apt-add-repository ppa:ubuntugis/ubuntugis-unstable  
sudo add-apt-repository ppa:otb/orfeotoolbox-stable-ubuntugis

Now run:

sudo aptitude update

Following the guidlines for orfeotoolbox ppa install you can select the package you want or install all

sudo aptitude install libotb otbapp monteverdi otb-wrapping-python otb-wrapping-java

Be careful not to add the two repositories, since they may cause incompatibilities.

Moreover, nightly builds for all OTB projects are also available through APT repositories. If you are using apt command-line tools, use these command-lines to add the otb repository to apt sources:

sudo aptitude install add-apt-repository  
sudo add-apt-repository ppa:otb/orfeotoolbox-nightly

Now run:

sudo aptitude update

As the previous cases, select which packages you will install.

sudo aptitude install libotb otb-bin otb-bin-qt otb-python otbapp monteverdi

For further informations about ubuntu packages go to hrefhttps://launchpad.net/ otb/+archive/orfeotoolbox-stableorfeotoolbox-stable launchpad page and click on Read about installing.

apt-add-repository will try to retrieve the GPG keys of the repositories to certify the origin of the packages. If you are behind a http proxy, this step won’t work and apt-add-repository will stall and eventually quit. You can temporarily ignore this error and proceed with the update step. Following this, aptitude update will issue a warning about a signature problem. This warning won’t prevent you from installing the packages.

OpenSuse 11.X and higher

For OpenSuse 11.X and higher, OTB, OTB-Applications, Monteverdi and OTB-Wrapping packages are available through zypper.

First, you need to add the appropriate repositories with these command-lines (please replace 11.4 by your OpenSuse version):

sudo zypper ar  
http://download.opensuse.org/repositories/games/openSUSE_11.4/ Games  
sudo zypper ar  
http://download.opensuse.org/repositories/Application:/Geo/openSUSE_11.4/ GEO  
sudo zypper ar  
http://download.opensuse.org/repositories/home:/tzotsos/openSUSE_11.4/ tzotsos

Now run:

sudo zypper refresh  
sudo zypper install OrfeoToolbox  
sudo zypper install OrfeoToolbox-devel  
sudo zypper install Monteverdi  
sudo zypper install Orfeo-Applications  
sudo zypper install OrfeoToolbox-python

Alternatively you can use the One-Click Installer from the openSUSE Download page or add the above repositories and install through Yast Package Management.

In case you wish to test the latest version of the packages, you can run:

sudo zypper refresh  
sudo zypper install OrfeoToolbox-beta  
sudo zypper install OrfeoToolbox-beta-devel  
sudo zypper install Monteverdi-beta  
sudo zypper install Orfeo-Applications-beta

There is also support for the recently introduced ’rolling’ openSUSE distribution named ’Tumbleweed’. For Tumbleweed you need to add the following repositories with these command-lines:

sudo zypper ar  
http://download.opensuse.org/repositories/games/openSUSE_Tumbleweed/ Games  
sudo zypper ar  
http://download.opensuse.org/repositories/Application:/Geo/openSUSE_Tumbleweed/ GEO  
sudo zypper ar  
http://download.opensuse.org/repositories/home:/tzotsos/openSUSE_Tumbleweed/ tzotsos

and then add the OTB packages as shown above.

CentOS 5.5

Since 3.12 version, OTB packages (OTB, monteverdi, OTB-Applications) are available on CentOS 5.5 distribution. In the following lines, we will describe the way to install OTB and monteverdi packages on this distribution. If you want use OTB-Wrapping, please following the instructions found in this file. Preliminary steps (common to all packages):

  1. Configure your system to pass through your HTTP(S) proxy,
  2. Add required extra repositories: EPEL, ELGIS and centosplus,

can be found in the previous file.

So if you want OTB and monteverdi packages, you need to install a standard RPM packages which is available on OTB website:

   wget http://www.orfeo-toolbox.org/packages/centos/5.5/i386/3.11.0/  
         gdal-1.8.0-5.i386.rpm  
   yum --nogpgcheck install gdal-1.8.0-5.i386.rpm  
   

We can now get and install (replace version number by the current):

  1. OTB libraries and new OTB application package:
       wget http://www.orfeo-toolbox.org/packages/centos/5.5/i386/3.11.0/  
             OrfeoToolbox-3.11.0-1.i386.rpm  
       yum --nogpgcheck install OrfeoToolbox-3.11.0-1.i386.rpm  
       

  2. monteverdi package:
       wget http://www.orfeo-toolbox.org/packages/centos/5.5/i386/3.11.0/  
             Monteverdi-1.9.0-0.i386.rpm  
       yum --nogpgcheck install Monteverdi-1.9.0-0.i386.rpm  
       

2.2 Building from sources

OTB has been developed and tested across different combinations of operating systems, compilers, and hardware platforms including MS-Windows, Linux on Intel-compatible hardware, Solaris and Mac OSX. It is known to work with the following compilers:

Given the advanced usage of C++ features in the toolbox, some compilers may have difficulties processing the code. If you are currently using an outdated compiler this may be an excellent excuse for upgrading this old piece of software!

Please note that though this section only describes how to compile OTB from sources, OTB-Applications, Monteverdi and OTB-Wrapping can be compiled in a similar way.

2.2.1 Getting the OTB source code

There are three ways of getting the OTB source code:

These last two options need a proper Mercurial installation. To get source code from Mercurial, do:

hg clone http://hg.orfeo-toolbox.org/OTB

Using Mercurial, you can easily navigate through the different version. For instance, this brings you to the 3.12.0 source code version:

hg update -r 3.12.0

And this brings you to the latest development version:

hg update

2.2.2 External Libraries

The OTB depends on several libraries:

See section 32.4 for quick installation guidelines.

2.2.3 Configuring OTB

The challenge of supporting OTB across platforms has been solved through the use of CMake, a cross-platform, open-source build system. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. CMake is quite sophisticated—it supports complex environments requiring system configuration, compiler feature testing, and code generation.

CMake generates Makefiles under UNIX systems and generates Visual Studio workspaces under Windows (and appropriate build files for other compilers like Borland). The information used by CMake is provided by CMakeLists.txt files that are present in every directory of the OTB source tree. These files contain information that the user provides to CMake at configuration time. Typical information includes paths to utilities in the system and the selection of software options specified by the user.

Preparing CMake

CMake can be downloaded at no cost from

http://www.cmake.org

OTB requires at least CMake version 2.8. You can download binary versions for most of the popular platforms including Windows, Solaris, IRIX, HP, Mac and Linux. Alternatively you can download the source code and build CMake on your system. Follow the instructions in the CMake Web page for downloading and installing the software.

For Unix/Linux systems, an additional help can be found in the 32.4 section, subsection Unix/Linux Platforms.

Running CMake initially requires that you provide two pieces of information:

These are referred to as the source directory and the binary directory. We recommend setting the binary directory to be different than the source directory (an out-of-source build), but OTB will still build if they are set to the same directory (an in-source build).

Compiling OTB

CMake runs in an interactive mode in that you iteratively select options and configure according to these options. The iteration proceeds until no more options remain to be selected. At this point, a generation step produces the appropriate build files for your configuration.

This interactive configuration process can be better understood if you imagine that you are walking through a decision tree. Every option that you select introduces the possibility that new, dependent options may become relevant. These new options are presented by CMake at the top of the options list in its interface. Only when no new options appear after a configuration iteration can you be sure that the necessary decisions have all been made. At this point build files are generated for the current configuration.

As the following figures display it, CMake has a different interface according to your systems.


PIC PIC

Figure 2.1: CMake interface. Top) ccmake, the UNIX version based on curses. Bottom) CMakeSetup, the MS-Windows version based on MFC.


On Windows The OTB needs some external library to work. On Windows, we recommended to use the OSGeo4Windows tools to get those libraries. Please refer to the section 2.1.1 to do the procedure. On windows, you need to create the binary directory before launching CMake. Here, you’ll use the following one:

⋆ OTB  
|- OTB\_SOURCE\_DIR  
|- OTB\_BINARY\_DIR

Launch CMake executable, on the top of the GUI, select the source and binary directory. Then press Configure, the Generate button will be accessible only when every needed CMake variable will be set. The CMake GUI is used to specify the source and build directories (Figure 2.1). Here is a list recommended variables to set :

You’ll probably need to push several times Configure to have access to the variable and to check the Advanced button to have access to the advanced CMake variable. When this is done, push Generate, the CMake window will close itself.

Now, you can go in your binary directory (here OTB_BINARY_DIR). CMake has generated Makefiles or Visual Studio projects. You can open the solution and generate the ALL_BUILD project. If you plan to run executables from within the Visual Studio environment, you should open the Visual Studio solution file from the OSGeo4W shell. To do this, simply drag-and-drop the ”.sln” file to an OSGeo4W shell and press Enter.

Windows platforms didn’t support to build with shared libraries. If you experience any problem with that, you can set BUILD_SHARED_LIBS to OFF but the built size might reach 1 GB.

That should be all! Otherwise, subscribe to otb-users@googlegroups.com and you will get some help.

On Linux/Unix On Unix, the binary directory is created by the user and CMake is invoked with the path to the source directory. For example:

mkdir OTB_BINARY_DIR  
cd OTB_BINARY_DIR  
ccmake ../OTB_SOURCE_DIR

Once the interface open, you can push c (for Configure), or/and t for Toggle (to have access to the advanced variables). If you have follow the section 32.4 every needed libraries are in the /usr and will be found automatically by CMake. Set the following recommended CMake variables:

Push c to update CMake untill the option Generate is accessible in the GUI, then push g fot Generate. The CMake interface will close itself. Then, go into your build directory (here OTB_BINARY_DIR) and do make to launch the compilation.

If you want to put OTB in a standard location, you can proceed with:

make install

Compilation awarness The build process will typically take anywhere from 15 to 30 minutes depending on the performance of your system. If you decide to enable testing as part of the normal build process, about 2500 small tests programs will be compiled. This will verify that the basic components of OTB have been correctly built on your system.

Set the CMake variables BUILD_TESTING and BUILD_EXAMPLES to ON will activate the compilation of the examples and the tests and slow down the build process. The examples distributed with the toolbox are a helpful resource for learning how to use OTB components but are not essential for the use of the toolbox itself. The testing section includes a large number of small programs that exercise the capabilities of OTB classes. Due to the large number of tests, enabling the testing option will considerably increase the build time. It is not desirable to enable this option for a first build of the toolbox.

OTB Applications, which contains applications incorporating GUIs and different levels of visualization are also available. The variable BUILD_APPLICATION=ON enables application building. A complete list of available applications can be found on OTB Website

2.3 Getting Started With OTB

The simplest way to create a new project with OTB is to create a new directory somewhere in your disk and create two files in it. The first one is a CMakeLists.txt file that will be used by CMake to generate a Makefile (if you are using UNIX) or a Visual Studio workspace (if you are using MS-Windows). The second file is an actual C++ program that will exercise some of the large number of classes available in OTB. The details of these files are described in the following section.

Once both files are in your directory you can run CMake in order to configure your project. Under UNIX, you can cd to your newly created directory and type “ccmake .”. Note the “.” in the command line for indicating that the CMakeLists.txt file is in the current directory. The curses interface will require you to provide the directory where OTB was built. This is the same path that you indicated for the OTB_BINARY_DIR variable at the time of configuring OTB. Under Windows you can run CMakeSetup and provide your newly created directory as being both the source directory and the binary directory for your new project (i.e., an in-source build). Then CMake will require you to provide the path to the binary directory where OTB was built. The OTB binary directory will contain a file named OTBConfig.cmake generated during the configuration process at the time OTB was built. From this file, CMake will recover all the information required to configure your new OTB project.

2.3.1 Hello World !

Here is the content of the two files to write in your new project. These two files can be found in the OTB/Examples/Installation directory. The CMakeLists.txt file contains the following lines:

PROJECT(HelloWorld)  
 
FIND_PACKAGE(OTB REQUIRED)  
INCLUDE(${OTB_USE_FILE})  
 
ADD_EXECUTABLE(HelloWorld HelloWorld.cxx )  
TARGET_LINK_LIBRARIES(HelloWorld OTBCommon OTBIO ITKCommon ITKIO)

The first line defines the name of your project as it appears in Visual Studio (it will have no effect under UNIX). The second line loads a CMake file with a predefined strategy for finding OTB 1. If the strategy for finding OTB fails, CMake will prompt you for the directory where OTB is installed in your system. In that case you will write this information in the OTB_DIR variable. The line INCLUDE(${USE_OTB_FILE}) loads the UseOTB.cmake file to set all the configuration information from OTB.

The line ADD_EXECUTABLE defines as its first argument the name of the executable that will be produced as result of this project. The remaining arguments of ADD_EXECUTABLE are the names of the source files to be compiled and linked. Finally, the TARGET_LINK_LIBRARIES line specifies which OTB libraries will be linked against this project.

The source code for this example can be found in the file
Examples/Installation/HelloWorld.cxx.

The following code is an implementation of a small OTB program. It tests including header files and linking with OTB libraries.

#include "otbImage.h" 
#include <iostream> 
 
int main() 
{ 
  typedef otb::Image<unsigned short, 2> ImageType; 
 
  ImageType::Pointer image = ImageType::New(); 
 
  std::cout << "OTB Hello World !" << std::endl; 
 
  return EXIT_SUCCESS; 
}

This code instantiates an image whose pixels are represented with type unsigned short. The image is then constructed and assigned to a itk::SmartPointer. Although later in the text we will discuss SmartPointer’s in detail, for now think of it as a handle on an instance of an object (see section 3.2.4 for more information). The itk::Image class will be described in Section 5.1.

At this point you have successfully installed and compiled OTB, and created your first simple program. If you have difficulties, please join the otb-users mailing list (Section 1.4.1 on page 9) and post questions there.