Can anyone help me with using Hugin Commandline

1,518 views
Skip to first unread message

xhe

unread,
Dec 5, 2008, 3:48:57 PM12/5/08
to hugin and other free panoramic software
Hi All,

I am searching the answer for how to use hugin command line for quite
a long time, but really can not get any answer, so I really appreciate
anyone who can show me a step by step help.

What I want to do is just use command line to stitch photos into a
panorama. Sounds simple, but when I tried to google it, no answer at
all.

I finally focused in Hugin, it shipped with lots of command line
tools. But which tool can I use to generate the panorama? Is it
autopano, nona or something else? There must be some ways to realize
my dream.

If there is a utility that allows me to pass a series of photos name,
and output the final panorama, that will be just what I need.

I am using windows environment, but I think the same solution will be
applied to linux as well.

Thanks anyone for reading and helping.

xhe

unread,
Dec 5, 2008, 3:09:16 PM12/5/08
to hugin and other free panoramic software

Bruno Postle

unread,
Dec 5, 2008, 8:08:23 PM12/5/08
to Hugin ptx
On Fri 05-Dec-2008 at 12:09 -0800, xhe wrote:
>
>What I want to do is just use command line to stitch photos into a
>panorama. Sounds simple, but when I tried to google it, no answer at
>all.

Yes it can be done and a howto document is being written, it's just
going very slowly.

>I finally focused in Hugin, it shipped with lots of command line
>tools. But which tool can I use to generate the panorama? Is it
>autopano, nona or something else? There must be some ways to realize
>my dream.

You can use autopano-sift-C, panomatic or match-n-shift to create a
project file with control points (I use match-n-shift, but only
because I haven't tested the others thoroughly), use autooptimiser
to align the images and level the panorama, and then use pto2mk to
generate a Makefile for stitching.

>If there is a utility that allows me to pass a series of photos name,
>and output the final panorama, that will be just what I need.

Yes panostart from Panotools::Script will do something like this and
it even works a lot of the time.

--
Bruno

Frank He

unread,
Dec 6, 2008, 9:09:51 AM12/6/08
to hugi...@googlegroups.com
Thanks buddy,

Glad to see this can be realized, that just approved my expectation for hugin.

But Bruno, if you don't mind, is that possible for you to show me your script? Without the detailed howto tutorial, I am always lost in the way toward the final aim.

Greatly appreciate it.

Frank

Frank He

unread,
Dec 6, 2008, 12:13:08 PM12/6/08
to hugi...@googlegroups.com
Hi Bruno,

Please pardon my ignorance, and I am lost in the process.

Step 1. I used "autopano-sift-c.ext output.pto 1.jpg 2.jpg 3.jpg 4.jpg" to generate the pto file, it is fine
step 2. when I use autooptimiser.ext output.pto, I was told "HFOV in image1 is invalid, please specify HFOV with -v". checking the help, it said 'autopano-sift generate pto with invalid HFOV'. So can you  tell me the choice of the value of HFOV? I just used "autooptimiser -v 1 output.pto" to went through, and no idea if right or not;
Step 3. I used "pt2tomk -o final -p final_ output.pto", and got make file - final

Then I lost. How to stitch by using this makefile? In command line, which utility should I use?

Please help to point out any errros in my steps.

I am using all the utilities located under bin directory in my windows system

Thanks very much.

Frank

On Fri, Dec 5, 2008 at 8:08 PM, Bruno Postle <br...@postle.net> wrote:

Bruno Postle

unread,
Dec 6, 2008, 12:58:11 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 12:13 -0500, Frank He wrote:
>
>Step 1. I used "autopano-sift-c.exe output.pto 1.jpg 2.jpg 3.jpg 4.jpg" to

>generate the pto file, it is fine

>step 2. when I use autooptimiser.exe output.pto, I was told "HFOV in image1


>is invalid, please specify HFOV with -v". checking the help, it said
>'autopano-sift generate pto with invalid HFOV'. So can you tell me the
>choice of the value of HFOV? I just used "autooptimiser -v 1 output.pto" to
>went through, and no idea if right or not;

HFOV is 'horizontal angle of view' in degrees, so unless you have a
telephoto lens 1 degree is too small. A 'normal' lens is usually
about 50 degrees (if you are using a fisheye lens then you need a
slightly different autopano-sift-c command-line).

autooptimiser has some more options, I would use something like
this (assuming a 50 degree lens):

autooptimiser -v 50 -a -l -s -o optimised.pto output.pto

This will create optimised.pto (I suggest opening these .pto files
in hugin to see what is happening at each step).

>Step 3. I used "pt2tomk -o final -p final_ output.pto", and got make file -
>final
>
>Then I lost. How to stitch by using this makefile? In command line, which
>utility should I use?

Makefiles are usually used when building software, we use them for
'building' panoramas as the process is somewhat similar (lots of
tools creating intermediate files and assembling them).

Makefiles are processed by the 'make' tool, so you can now do this:

make -f final

--
Bruno

Zoran Mesec

unread,
Dec 6, 2008, 1:55:43 PM12/6/08
to hugin and other free panoramic software
Hi all!

Hugin is a graphical user interface for a number of command line tools
and therefore it does feature a lot of command line options. If you
want to create a panorama from cmd you can simply invoke manually all
the tools that hugin invokes for you when you click Stitch.

Third step can be done much easier by using PTBatcher. PTBatcher is
hugin's batch stitcher and it will be released in the next version of
hugin(0.71). PTbatcher keeps a list of hugin projects and executes
them in a batch. It can be invoked from the command line(it is
available also in GUI) without the use of any other programming
languages or tools.

But before you use PTBatcher you need to create pto project file like
Bruno described in steps 1&2.

cheers,
Zoran

Frank He

unread,
Dec 6, 2008, 2:05:11 PM12/6/08
to hugi...@googlegroups.com
Thanks Bruno,

Every step is wonderful except the last one.
When I used "make -f final", I got this error:

"make (e=2): The system can not find the file specified
make: [final_.tif] Error 2 (ignored)"

See the attached error img.

But when I use hugin to open the project and generate the panorama, it works fine.

Shall we passe any more paramater for the last step?

Thanks
error.JPG

Frank He

unread,
Dec 6, 2008, 2:07:04 PM12/6/08
to hugi...@googlegroups.com
I downloaded the hugin and can not find PTBatcher. Where is it?

Frank He

unread,
Dec 6, 2008, 3:24:17 PM12/6/08
to hugi...@googlegroups.com
I found that if I neglect the error, the final panorama is already generated by "make -f final", that is great

I now have three more questions:

1. Are there any utility that I can use to delete the middle files, such as result0001.tif, result0002.tif....automatically, or just pass some parameter to have them removed after pano generation;
2. Can I trop the dark edge of the generated panorama by some utility? It is really a little pity to have the black edge around the panorama;
3. The generated format is tif, how can I convert it to jpeg? I remembed there are some command in linux to convert tif to jpeg, just forgot it. But in windows, do we have that command as well?

Thanks.

Frank He

unread,
Dec 6, 2008, 4:13:26 PM12/6/08
to hugi...@googlegroups.com
I think using ptcrop can be used to chop the black edge of the generated panorama, is that right? But when I run
PTCrop.exe result.tif, the black edge has not been totally chopped.
If this is not for removing the black edge, are there any utility that I can use to chop the black edge of the panorama?

Thanks in advance.

Bruno Postle

unread,
Dec 6, 2008, 5:10:21 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 14:05 -0500, Frank He wrote:
>
>Every step is wonderful except the last one.
>When I used "make -f final", I got this error:

As you figured out the output is created anyway, just EXIF data
isn't added. This is a known quirk of pto2mk that will get fixed at
some point, basically it doesn't read the hugin preferences when it
creates the Makefile so the exiftool settings are undefined.

The workaround is to define the two missing variables in the shell
and call `make -e` instead of just `make`. I'm not sure how you set
windows environment variables, but this is how I do it on Linux:

export EXIFTOOL_COPY_ARGS='-ImageDescription -Make -Model -Artist -WhitePoint -Copyright -GPS:all -DateTimeOriginal -CreateDate -UserComment -ColorSpace -OwnerName -SerialNumber'
export EXIFTOOL=exiftool

--
Bruno

Frank He

unread,
Dec 6, 2008, 5:20:38 PM12/6/08
to hugi...@googlegroups.com
thanks.

But do you know why PTcrop is not working properly to crop all  the black edges? I found a tiffcrop utility from website and that can just crop the panorama perfectly.

So have you every met any problem for using PTcrop?

Bruno Postle

unread,
Dec 6, 2008, 5:24:04 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 15:24 -0500, Frank He wrote:
>
>1. Are there any utility that I can use to delete the middle files, such as
>result0001.tif, result0002.tif....automatically, or just pass some parameter
>to have them removed after pano generation;

The Makefile has lots of rules defined in addition to the default
'all', so you need to run the 'clean' rule too:

make -e -f final all clean

>2. Can I trop the dark edge of the generated panorama by some utility? It is
>really a little pity to have the black edge around the panorama;

Removing all the black is a hard problem, as far as I know there is
no solution to do this programatically.

>3. The generated format is tif, how can I convert it to jpeg? I remembed
>there are some command in linux to convert tif to jpeg, just forgot it. But
>in windows, do we have that command as well?

You can install ImageMagick and run convert:

convert -quality 75 project.tif project.jpg

..but actually the enblend step in the Makefile is quite capable of
creating JPEG output, you need to edit the .pto project before
running pto2mk and change this line:

#hugin_outputImageType tif

--
Bruno

Frank He

unread,
Dec 6, 2008, 5:40:29 PM12/6/08
to hugi...@googlegroups.com
Great Bruno,

Thanks again for your kind introduction. And hugin is such a good tool for automatically generating panorama!

I still found it difficult to install it into my linux account, which is as shared hosting. BTW, in windows, it already works fine. if you have some notes for installing into linux shared hosting site, I will appreciate. Or just forget it, and I will try to figure it out by myself.

Frank

Bruno Postle

unread,
Dec 6, 2008, 5:42:13 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 17:20 -0500, Frank He wrote:
>
>But do you know why PTcrop is not working properly to crop all the black
>edges? I found a tiffcrop utility from website and that can just crop the
>panorama perfectly.

The problem is that for most cases there are many hundreds of
rectangles that could all be the 'right' crop, do you want the most
pixels? the widest crop? the tallest crop? a crop that keeps the
centre of the image in the centre?

--
Bruno

Bruno Postle

unread,
Dec 6, 2008, 5:52:13 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 09:09 -0500, Frank He wrote:
>
>But Bruno, if you don't mind, is that possible for you to show me your
>script? Without the detailed howto tutorial, I am always lost in the way
>toward the final aim.

Using panostart from Panotools::Script and current hugin SVN, I
process a days photos and stitch them into panoramas like so:

panostart -o Makefile -f 2 -v 111 -k -459,2459,-57,2861 -l *.JPG
make qtvr

..but this doesn't help explain what is going on or help you fix
things when it goes wrong.

--
Bruno

Bruno Postle

unread,
Dec 6, 2008, 6:00:39 PM12/6/08
to Hugin ptx
On Sat 06-Dec-2008 at 17:40 -0500, Frank He wrote:
>
>I still found it difficult to install it into my linux account, which is as
>shared hosting. BTW, in windows, it already works fine.

This is going to be difficult since hugin depends on lots of system
libraries which are easily available for all Linux distributions but
which require Administrator access to install.

You could build the command-line stuff locally with a minimal set of
dependencies and upload the lot, but I wouldn't recommend this as a
first Linux project.

--
Bruno

Zoran Mesec

unread,
Dec 7, 2008, 6:04:02 AM12/7/08
to hugin and other free panoramic software
On Dec 6, 8:07 pm, "Frank He" <hexuf...@gmail.com> wrote:
> I downloaded the hugin and can not find PTBatcher. Where is it?
>

PTBatcher will be in the next hugin release, so you can't download the
executable yet. You need to build hugin from SVN to obtain it.
Instructions are here:
http://wiki.panotools.org/Special:Search?search=compiling&fulltext=Search

IMPO it is very easy to build hugin on linux, much easier than on
windows. :)

cheers,
Zoran

Bob Campbell

unread,
Dec 7, 2008, 1:10:41 PM12/7/08
to hugin and other free panoramic software

On Dec 6, 4:13 pm, "Frank He" <hexuf...@gmail.com> wrote:
> I think using ptcrop can be used to chop the black edge of the generated
> panorama, is that right? But when I run
> PTCrop.exe result.tif, the black edge has not been totally chopped.
> If this is not for removing the black edge, are there any utility that I can
> use to chop the black edge of the panorama?

I haven't tried PTBatcher, but...

After I generate a stitch in Hugin, the resulting TIFF has a
transparent background and the canvas size is usually bigger than the
actual image. The JPEG format does not support transparency and I
prefer my panos non-rectangular with a white background and as little
border as possible. To do this, I use the 'convert' utility which is
part of ImageMagick - a free, multiplatform suite for image
manipulation.

The command I use is:
convert newpano.tif -background white -flatten -trim -quality 90
newpano.jpg

In the above command, '-background white' does exactly that, '-
flatten' merges all the layers of the tif into a single layer, '-trim'
finds the least common horizontal and vertical viewing areas that are
not background field color, and '-quality 90' does a small bit of JPEG
compression on the file but saves a huge amount in the size of the
file, and finally giving the output file name an extension of '.jpg'
tells it to do TIFF to JPEG conversion.

Here's a shell script I lashed together, if anyone's interested:
---
#!/bin/sh
# by Robert Campbell <r...@indra.com>

set -e
NARG=$#
if [ $NARG -ne 1 ]; then
echo 1>&2 "usage: huginpost.sh image.tif"
exit 1
fi

# We're only expecting one argument, so natch
file=$1

# Now chop off the .tif
fileroot=`echo $file | awk -F'.tif' '{print $1}'`

# Let ourselves know what's happening
echo "Converting $file to ${fileroot}.jpg"

# Call the ImageMagick utility 'convert' to do all our transformations
convert $file -background white -flatten -trim -quality 90 $
{fileroot}.jpg
---

Quick example:
http://www.yourebelscum.com/images/g-n-t_lowertrail-stitch.jpg
(tif is there, too, but it's 30 MB, not 2.2)

Frank He

unread,
Dec 10, 2008, 11:42:17 AM12/10/08
to hugi...@googlegroups.com
When I generate a panorama, the finished result is not aligned, but kind of tilting. Is this because some paramaters were not correct? The original image is not tilting at all.
Thanks.
testresult.jpg

Bruno Postle

unread,
Dec 10, 2008, 2:11:39 PM12/10/08
to Hugin ptx
Try clicking the 'Straighten' button in the 'Preview', if this
doesn't work then you need to set 'Vertical control points':

http://wiki.panotools.org/Hugin_Control_Points_tab

--
Bruno

Reply all
Reply to author
Forward
0 new messages