Search

Hugin: create amazing panoramas from your photos

July 15th, 2007 edited by Tincho

Having been to DebConf7, I took advantage to visit a few beautiful places around the venue. Some of them are very hard to photograph with a common camera, specially when you’re trying to capture the full landscape from a hill or the complete sensation from a room in a castle —with all the walls covered with paintings and complicated ornaments—. So you have to resort to taking many pictures, but that’s not like the real thing.

Coincidentally, some time ago I’ve been researching some image processing topics, and found some amazing algorithms for automatic blending of multiple pictures to create mosaics of them. But I’d yet to see some ready to use implementation. Then, somebody from the table at the hacklab in DebConf7 enlightened me: hugin was the solution!

I have to admit it: the first attempts were really frustrating. A good time lost trying to adjust the images and the result was a nonsensical patchwork of images. So, take this in mind, and do what I didn’t: read the fine manual (and the tutorials). The manual is not very useful, but there are plenty of tutorials in the website.

So, the process is more or less like this: load the images, indicate where they overlap (setting control points), optimise, preview, adjust the control points, repeat until done. Setting the control points is what will determine how the images blend; but the most critical task is remember to run the optimiser before previewing or you won’t see your changes correctly! Here you can find a small tutorial that summarises the basic operation.

File list Control point setting Preview
File list and basic controls Setting the control points Preview of the final image

There are some optional tools that you’d like to have installed along with hugin:

autopano-sift
A tool that automates the most tedious part of creating a panorama: setting the control points. Note: you will have to change the default executable name in the hugin preferences to “autopanog”, as the default is wrong. Sometimes it works perfectly, sometimes it need to be helped by manually adding control points or horizontal/vertical lines, some other times is of no use at all. Your mileage may vary.
binfmt-support
Since autopano-sift runs in the mono environment, you would need this to execute it as a normal binary.
enblend
Replacement for the tool provided with hugin for blending images, with much better results.

A big problem I had was that hugin asked me some “crop factor” which is proportional to the size of the camera sensor, but nowhere is documented what that means. So, if you bump into this, you need to get the diagonal size of the camera CCD in mm and calculate 43.3 / diagonal. To get information about that, in this page you have a nice explanation about CCD’s sensors sizes. In the same site, you will find information for most digital cameras. If you don’t put correctly this value, most probably you won’t get any good result.

I’ll recommend you to also read this article, which explains how to use autopano-sift and the replacement blending tool, and gives some very good tips. Experiment and you will be amazed of the results!

To put an end to all this chatter, here is an example of a 360° panorama I’ve created from 23 pictures taken from the top of the Arthur’s Seat hill in Edinburgh. The control points were created with autopano-sift, and later added manually some horizontal lines to put the horizon into place, and some vertical lines in the monolith. The final blending was done with enblend, and the finishing touch is to crop it and convert to JPEG with gimp and copy the EXIF headers with jhead.
Arthur's Seat Hill panorama

Hugin is available in Debian since Etch, and in Ubuntu since Edgy

Posted in Debian, Ubuntu |

18 Responses

  1. Timothy Says:

    That picture is amazing.
    If I get it correctly this is the landscape that surrounded you? … or did you move sideways… can’t seem to get my head around it :-)

    Either way, thumbs up.

  2. dkp Says:

    Timothy: He would have most likely stood on one spot and spun around in a circle (albeit slowly) whilst taking photographs. And making sure each photograph overlap each other slightly so the Hugin software can see where to stitch each photo.

  3. Kelly Clowers Says:

    On Debian Sid, this page, the front page and the feed of this page all kills Iceweasel 2.0.0.4-1 (Gecko 1.8.1.4 2007050801 (Debian)) and SeaMonkey 1.1.2 (Gecko 1.8.1.4 20070509).
    Both programs crash as soon as the page finishes loading.

    Posting with Konqueror.

    PS The last image looks like static in Konq and in Gecko (in the short time it is displayed before the browser crashes). In Konq the full image will not display - I just get a white page. download and viewing with gThumb works.

  4. gord Says:

    works fine in epiphany here

  5. Márcio Vinícius Pinheiro Says:

    This program doesn’t work in my Ubuntu. It works fine in Windows. But in Ubuntu I always receive a error message like this (translated from pt-br):

    command: autopanog.exe –output autopano_result_tempfile.pto –imagelist /tmp/ap_imgnamestykw1f
    failed with code error: 127

    Do you know what does it mean?

  6. Tincho Says:

    Timothy: yes, I took the pictures just by rotating my head (and camera), as dkp said.

    Marcio: as I said in the article, you should change “autopanog.exe” to “autopanog” as the default is wrong. Even if autopanog is not working, you can still use hugin. Just will just have to set the control points by hand.

  7. sebsauvage Says:

    For those who speak french, I set up an article explaining the whole thing (AutoPano+Hugin+Enblend).

    http://www.commentcamarche.net/faq/sujet-6740-creer-une-vue-panoramique-avec-hugin-et-autopano-sift

  8. Vincent Says:

    Lol, I didn’t read the manual either, and I was quite impressed at how it could recognize the same points in different images. I then took it through the optimizer and generated the panorama, and it looked… Awful :P

    But I’m very impressed and might even read the manual some time in the future ;)

  9. Tim Says:

    Other tips: use a constant exposure for all shots. Rotate around the lens’s nodal point if at all possible, although hugin can cope if you don’t. Beware of water / waves and clouds and their shadows if it’s windy.

    If you’re using the auto-fine-tune functions in Hugin then you won’t have to play around with moving the control-points; it’s best just to get them right first time and move the anchor point, re-optimize, redo a draft-quality JPEG and test a few times before going for broke with a large image.

    If you’re storing EXIF info, you won’t need to prat around with crop-factors.

    Finally, I have a panorama from by the Observatory, looking out to Arthur’s Seat. Smile and wave: http://pig.sty.nu/Pictures/gallery/display-db.rb?pic=2042.

  10. Davide Says:

    Here you can find CCD for a lot of camera (it is a large xml file):

    http://hugin.svn.sourceforge.net/viewvc/hugin/lensdb/trunk/db/ptlens.xml?view=log

  11. KaTeznik Says:

    It seems that neither autopano-sift nor enblend are in debian yet. Can you confirm that I must compile them by hand ?

  12. Mr. Shiney Says:

    I just wanted to say kudos for taking up the Deb Package of the Day reigns. There is a lot of greatness in the package repository and I like the buried treasure you unearth on a daily basis. Keep up the good work!

  13. sebsauvage Says:

    I am under Ubuntu (Debian-based) and AutoPano, Enblend and Hugin are in the repositories.
    Install is a piece of cake:
    sudo aptitude install autopano-sift hugin enblend

    Maybe you can add the Ubuntu repositories to your Debian, or just grab the .debs:
    http://packages.ubuntu.com

  14. Tincho Says:

    KaTeznik: Sorry, it was my mistake! autopano-sift and enblend are in the debian-multimedia repositories. I think there are some patent issues around them. You can use the repo by adding this to sources.list:

    deb http://www.debian-multimedia.org lenny main

  15. KaTeznik Says:

    Thanks Tincho, everything is working fine w/ debian multimedia.

    I’m in stable, and it worked nevertheless.

    I looked up at the licences, the stitch algorithm is patented in the US. As I’m in France, use of all these software is still open-source for me.

    Thanks for help,

  16. A.Lizard Says:

    terrarium:/home/alizard# aptitude install autopano-sift hugin enblend
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    Reading extended state information
    Initializing package states… Done
    Reading task descriptions… Done
    Building tag database… Done
    The following packages are BROKEN:
    autopano-sift
    The following packages have been automatically kept back:
    libfreetype6 libfreetype6-dev libgpgme11 libtimedate-perl xserver-xorg-core
    The following NEW packages will be automatically installed:
    binfmt-support freeglut3 hugin-bin hugin-data hugin-tools libboost-thread1.33.1 libgdiplus libglew1
    libmono-corlib1.0-cil libmono-sharpzip0.84-cil libmono-system1.0-cil libpano12-0 libpano12-bin mono-common
    mono-jit
    The following packages have been kept back:
    adduser camorama ffmpeg jpilot jpilot-plugins libavcodec1d libavformat1d libavutil1d libpostproc1d pdmenu
    sysstat xserver-xorg-video-intel
    The following NEW packages will be installed:
    binfmt-support enblend freeglut3 hugin hugin-bin hugin-data hugin-tools libboost-thread1.33.1 libgdiplus
    libglew1 libmono-corlib1.0-cil libmono-sharpzip0.84-cil libmono-system1.0-cil libpano12-0 libpano12-bin
    mono-common mono-jit
    0 packages upgraded, 18 newly installed, 0 to remove and 17 not upgraded.
    Need to get 13.4MB/13.5MB of archives. After unpacking 44.6MB will be used.
    The following packages have unmet dependencies:
    autopano-sift: Depends: libglade-cil which is a virtual package.
    Resolving dependencies…
    The following actions will resolve these dependencies:

    Keep the following packages at their current version:
    autopano-sift [Not Installed]

    Score is -9881

  17. A.Lizard Says:

    note: I’m running etch/lenny here.

  18. Damian Montaldo Says:

    Try autopano-sift-c written in C instead of autopano-sift in C#

    You don’t have to install anything of mono or C# and is faster.

    For example, in Debian GNU+Linux (stable i386):
    http://debian-multimedia.org/dists/stable/main/binary-i386/package/autopano-sift-c.php

    Thanks Tincho for showing me hugin.