compiling panotools/ hugin from source on debian/ suse linux

[Updated 09/19/2011: separated pages for rpm-based (SUSE) and deb-based (Debian) systems]
[Updated 10/20/2011: included a sample Debian /etc/apt/sources.list]
[Updated 11/06/2011: included version-specific steps for Hugin 2011.2]

The Panotools library are a set of algorithms for panorama stitching and processing of images. Originally written and developed by Prof. Helmut Dersch, they are one of the “must-have” image processing software I have used. An archived page of the project dating back to 2002 can also be found here.

The steps below build panotools and their frontend Hugin on Linux using source tarballs while keeping the relevant steps from official panotools wiki (which uses CVS/ SVN repositories to get the source). The advantage of source tarballs is that they need not be downloaded every time the application is installed, unlike using repositories.

debian logo
Part I (Debian system)

A. Collecting all required binaries
Source binaries of the following applications are required at minimum. Additional tools may be built if required, but these are ok to start with, then upgrade according to actual use. Click on each to download its latest tarball (tar.gz). Most of these files are available at Hugin’s Sourceforge site. Put all of them in a common location, say \home\<user>\Downloads>. We’ll refer this location throughout as our base.

  1. libpano13-2.9.17 (Pano Tools Library v13: the core requirement)
  2. Enblend (seam blender) + Enfuse (tone-mapping multiple exposures) v4.0
  3. Hugin 0.8.0 (a decent multi-functional GUI). A more recent version may be tried.
  4. Autopoint-sift-C 2.5.1 (Automatic Control Point Detectors – they do a great job of selecting similar points in overlapping zones of photos – which form the basis of stitching the panorama)
  5. Exif-Tool-8.30 (self-explanatory)
  6. PanoGLView-0.2.2 (an OpenGL based panorama quick viewer)

B. Building the Debian Environment
The build would require cmake and other compile tools, so at first, run the following to check whether these are already present; if not, then install. With apt-get, things are really simple. If you’ve built any application from source earlier, then probably you’ll have some of them already.  The below will install those you haven’t. About 500MB of packages will be downloaded on a base Debian system in course of the following steps, most of them being for dependencies. If you have a tex system installed already, the download size reduces significantly.

Sample /etc/apt/sources.list
Before we begin our apt-gets, lets look at a sample repository list:

# Debian Install CD/DVD
deb cdrom:[Debian GNU/Linux 6.0.0 _Squeeze_ - Official Snapshot i386 LIVE/INSTALL Binary 20110827-21:12]/ squeeze main

# deb squeeze main non-free
deb http://debian.cites.uiuc.edu/pub/debian/ squeeze main non-free
deb-src http://debian.cites.uiuc.edu/pub/debian/ squeeze main non-free

# deb security
deb http://security.debian.org/ squeeze/updates contrib non-free main
deb-src http://security.debian.org/ squeeze/updates contrib non-free main

# squeeze-updates, previously known as 'volatile'
deb http://debian.cites.uiuc.edu/pub/debian/ squeeze-updates main
deb-src http://debian.cites.uiuc.edu/pub/debian/ squeeze-updates main

We may now proceed with our train of apt-gets:

sudo apt-get install build-essential autoconf automake1.9 libtool flex bison gdb libc6-dev libgcc1 cmake

C. Installing libpano13 libraries
Since this is the core requirement of our application, we’ll begin with it. Get the dependencies of libpano13:

sudo apt-get install zlib1g zlib1g-dev libpng12-dev libjpeg62-dev libtiff4-dev

Extract the tarball (libpano13-2.9.17) and install:

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>./configure
/source-tarball>make
/source-tarball>sudo make install

D. Installing enblend+enfuse 4.0
Get the dependencies:

sudo apt-get install pkg-config libboost-graph-dev libboost-thread-dev libboost-filesystem-dev liblcms1-dev libglew1.5-dev libplot-dev libglut3-dev libopenexr-dev libxi-dev libxmu-dev help2man texi2html texinfo fig2ps tidy gnuplot libxml-xpath-perl imagemagick

If you already have a Tex system on your machine, you do not need to install it’s packages at this point (it will prompt to install otherwise).

Extract the tarball (enblend-enfuse-4.0) and install. (ref. steps in C)

E. Installing Hugin 0.8.0
Get the dependencies:

sudo apt-get install libboost-dev boost-build gettext libwxgtk2.8-dev libexiv2-dev libimage-exiftool-perl libglew-dev liblapack-dev libboost-regex-dev libboost-iostreams-dev

Extract the tarball (hugin_0.8.0.dfsg.orig) and install (using cmake this time):

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>mkdir buildHugin && cd buildHugin
/source-tarball/buildHugin>cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
/source-tarball/buildHugin>make
/source-tarball/buildHugin>sudo make install

F. Installing Automatic Control Detector (Autopano-sift-C 2.5.1)
Get the dependencies:

sudo apt-get install libxml2-dev

Extract the tarball (autopano-sift-C-2.5.1) and install (ref. steps in E)

G. Installing Image-ExifTool 8.30
Get the dependencies. We need Perl (Community Edition will do) for this one.

sudo apt-get install libimage-exiftool-perl

Extract tarball (Image-ExifTool-8.30) and install:

/Downloads>tar -xvf Image-ExifTool-8.30.tar.gz && cd Image-ExifTool-8.30
/Image-ExifTool-8.30>perl Makefile.PL
/Image-ExifTool-8.30>make test
/Image-ExifTool-8.30>sudo make install

H. Installing PanoGLView
Get the dependencies:

sudo apt-get install wx-common

Extract tarball (panoglview-0.2.2) and install (ref. steps in C).

Lastly, we need to ensure that the  dynamic linkers and cache to the shared libraries are created. To do this, run

/Downloads>sudo ldconfig

That’s it. Now the application can be opened from Applications/ Graphics. Although the installation is pretty extensive for the end user, this is too good an application to miss. So I guess the effort is worth it.

You may clean the apt-cache on your machine (which grows considerably after installing a lot of packages). Run

sudo apt-get clean

This cleans up the /var/cache/apt/archives.


openSUSE logo
Part II (SUSE system)

The official build wiki for openSUSE uses Mercurial/ SVN repositories to get the source files. We want to build from source tarballs instead. It may seem that once these are obtained and their dependencies resolved like in Part I Step A, the subsequent steps are same. Most of the steps are indeed same. However, the actual problem lies in the dependencies. There are more than those mentioned in the official wiki; with some packages requiring special config switches. Compiling the latest Hugin (v2011.2) requires some minor modifications in its source code as well, to bypass certain ambiguous function calls. Similar ambiguity is also found in another required package “libpng” (>= v1.2.9), which uses a different function signature than that in its earlier versions (png_set_expand_gray_1_2_4_to_8); this breaks the compilation outright. Therefore, we have a separate section for SUSE here.

A. Getting the dependencies:
The following steps were done on a base openSUSE KDE4 with X11 (X window system) and Base Development (C/C++ compiler, make, autoconf etc.) patterns. On top of that, the SUSE system requires the following packages:

zypper

Install zypper first; we’ll use it like apt-get of Debian wherever required/ possible. It can be installed using YAST, and it is usually available w.e.f openSUSE 11.3. Use zypper as root.

1. General dependencies:

zypper in cmake boost-devel gettext-runtime libexiv2-devel libopenexr-devel libjpeg62-devel libtiff-devel liblcms-devel openexr libxmi freeglut gnuplot tidy glew transfig wxGTK-devel lapack

The packages gettext-runtime, libopenexr-devel, libjpeg62-devel, openexr provide gettext, OpenEXR-devel, libjpeg-devel, openEXR respectively, as mentioned in official wiki. Even if latter names are given, zypper will automatically get the exact providers. Zypper will skip a package if already installed (and no updates exist for them in the zypper repositories). Zypper will also automatically resolve dependencies if any. The SUSE system comes with numerous development packages pre-included in its installation DVD. Most “devel” packages therefore can be installed along with the OS. These packages can usually be found in the “Development” pattern during OS installation.

2. Dependencies that need to be downloaded separately:
a) Templatized C++ Command Line Parser (tclap)
Extract and install tclap-1.2.1.tar.gz as below:

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>./configure
/source-tarball>make
/source-tarball>su -
root:/source-tarball>make install && ldconfig

b) wxWidgets – cross-platform C++ GUI libraries
Extract the source tarball and install as per above steps with an additional switch “–with-opengl” in configure command:

/source-tarball>./configure --with-opengl

3. Other (recommended) dependencies:
Expat – XML Parser for libpano13
Perl for Image-ExifTool

At this point, we have installed all dependencies for the below applications.

B. Installing Enblend/ Enfuse 4.0:
The simplest way is using zypper. The official instructions are to build from source obtained through CVS. Neither this nor source tarball for it obtained in Part I step A will compile because of the mismatch in libpng code w.e.f. v1.2.9. A temporary fix for that may be found here. Unfortunately the error is not specifically mentioned when encountered, so going by the compile time messages won’t help. An alternate solution is to use libpng12-devel (older version; you may need to downgrade from that provided with SUSE latest).

zypper in enblend

C. Installing libpano13:
Extract the tarball (obtained in Part I step A) and install as per below. Note that no further dependencies are to be installed for this.

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>sh ./bootstrap
/source-tarball>make
root:/source-tarball>make install install-data-am && ldconfig

After executing the bootstrap script, it should generate a report like this:

libpano13 bootstrap

D. Installing Hugin:
a) Hugin v2010.4
Download Hugin 2010.4.0. Extract and install as per below. It is fairly long installation; the make command can take upto 30 mins to complete.

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>mkdir mybuild && cd mybuild
/mybuild>ccmake ../
/mybuild>cmake ../
/mybuild>make
root:/mybuild>make install && ldconfig

If it does not go well as per above steps (because of some change by a third party library in future that may break the compilation), use the official steps to build it from SVN:

Checkout Hugin:

root:/Downloads>mkdir /usr/src/hugin && cd /usr/src/hugin
/usr/src/hugin>svn co https://hugin.svn.sourceforge.net/svnroot/hugin/hugin/trunk hugin

Compile Hugin:

root:/usr/src/hugin>mkdir /usr/src/hugin/buildHugin && cd /usr/src/hugin/buildHugin
buildHugin>ccmake -DBUILD_ANYWAY=1 /usr/src/hugin/hugin
buildHugin>cmake -DBUILD_ANYWAY=1 /usr/src/hugin/hugin
buildHugin>make && make install

Note the “-DBUILD_ANYWAY=1” switch for ccmake & cmake. This is to force cmake to build from SVN repositories.

b) Hugin v2011.2
This is the latest Hugin version, with significant improvements. This version requires the following workarounds* in its source code. Extract the tarball (hugin-2011.2.0.tar.bz2) and make these changes:

Hugin 2011.2 workarounds

This screenshot shows the files, their location w.r.t hugin-2011.2.0 and the line numbers where these changes are to be done. For example, in the first diff output, the numbers 596c596 indicate the changes are in line # 596 for both files. The files with prefix “1” denote the original versions that came with the tarball. Once done, proceed with the compilation as given above for v2010.4.

*The workarounds are just temporary fixes to get the compilation running; without compromising on major functionality of the application. I have found no issues due to them while creating single row (horizontal) or multi-row/ stacked panoramas so far.

E. Installing Autopano-sift C:
Get the binary as in Part I step A. Extract and install as below.

/Downloads>tar -xvf source-tarball.tar.gz && cd source-tarball
/source-tarball>mkdir buildapsc && cd buildapsc
/buildapsc>cmake -DCMAKE_INSTALL_PREFIX=/usr/local ../
/buildapsc>make
root:/buildapsc>make install && ldconfig

F. Installing Image-ExifTool 8.30:
Get the binary as in Part I step A. Extract and install as below.

/Downloads>tar -xvf Image-ExifTool-8.30.tar.gz && cd Image-ExifTool-8.30
/Image-ExifTool-8.30>perl Makefile.PL
/Image-ExifTool-8.30>make test
root:/Image-ExifTool-8.30>make install && ldconfig

That’s all. We don’t need panoGLView here. You can create a launcher on desktop for hugin (usually @ /usr/local/bin/hugin). To get location of hugin, run which hugin from prompt. The menu entry for hugin can be found at KDE4-Menu > Applications > Graphics > More Programs.

To clean up disk space, you may delete /tmp (as root).


Check out 40 MP & 56 MP panoramas that I created using this application.
Get started at Hugin Tutorials.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s