Stitching from command line

270 views
Skip to first unread message

Adrien Marc

unread,
Apr 29, 2008, 4:53:13 PM4/29/08
to hugin and other free panoramic software
Hello all,

This is something I've wanted to be able to do for a long time ...
type in a command prompt something like:
stitch_script -o pano.jpg image1.jpg image2.jpg image3.jpg
and have our friends autopano, autooptimiser, vig_optimize, nona,
enblend and exiftool called by this stitch_script and do all the work.

The purpose is to automatically stitch rows of typically 4 or 5
images.

I quickly tried something yesterday but found that this won't be as
easy as calling the tools one after the other. I am willing to dig
this further but the following steps won't be too easy, especially
because I never wrote anything in perl (oh my !), which means my
beginnings with Panotools::Script might be a little stiff.

So before I go further I would like to ask if anyone here has already
done something similar. Or any kind of advice on how this should be
done would be very welcome !

Cheers,
Adrien

Bruno Postle

unread,
Apr 29, 2008, 5:42:57 PM4/29/08
to Hugin ptx
On Tue 29-Apr-2008 at 13:53 -0700, Adrien Marc wrote:
>
>This is something I've wanted to be able to do for a long time ...
>type in a command prompt something like:
>stitch_script -o pano.jpg image1.jpg image2.jpg image3.jpg
>and have our friends autopano, autooptimiser, vig_optimize, nona,
>enblend and exiftool called by this stitch_script and do all the work.
>
>The purpose is to automatically stitch rows of typically 4 or 5
>images.
>
>I quickly tried something yesterday but found that this won't be as
>easy as calling the tools one after the other.

Actually it more or less is doable like that, so long as you want to
do simple stuff. The clunky script at the end of this page does
what you are asking (and the page was created by the script itself):

http://bugbear.postle.net/~bruno/misc/2007-06-23-goodwood-panorama/

Basically it runs match-n-shift using (my) known lens parameters,
then autooptimiser produces a straightened and centred .pto project.

After that it isn't as good as it could be, there is a tool in
Panotools::Script called pto2tiff that I use here to render and
blend the project file - But this doesn't use the recent hugin
Makefile stitching system, because there currently isn't a
command-line tool to create the .mk Makefiles from a .pto project.

So you can automatically stitch and blend a panorama so long as you
don't want enfuse or HDR.

The rest of the script just creates QTVR and 'little planet' views,
you probably don't need that. So an all-purpose script that
stitches normal non-fisheye photos would look something like this
(completely untested as usual):

#!/usr/bin/perl
use strict;
use warnings;

my $projection = 0;
my $fieldofview = 50;

my $a = $ARGV[0];
my $b = $ARGV[-1];
$a =~ s/\.[[:alnum:]]+$//;
$b =~ s/\.[[:alnum:]]+$//;
$b =~ s/.*[\/\\]//;
my $stub = "$a-$b";

system ('match-n-shift', '-c', '-o', "$stub.oto", '-f', $projection, '-v', $fieldofview, @ARGV);
system ('autooptimiser', '-a', '-l', '-s', '-o', "$stub.pto", "$stub.oto");
system ('pto2tiff', "$stub.pto");

..you'll need to do some fiddling to get vig_optimize and exiftool
in there.

--
Bruno

Adrien Marc

unread,
Apr 29, 2008, 5:49:48 PM4/29/08
to hugin and other free panoramic software
> [...]
> I quickly tried something yesterday but found that this won't be as
> easy as calling the tools one after the other.
> [...]

Just to add some precision about the issues I encountered :

- The first image of the row gets white
Note that if I use hugin to open the project file generated by
autopano-complete, I can see that the exposition value for this image
is not null.
I guess this could be worked around by replacing the corresponding Eev
value of the project file but wanted to know if there was a way to not
have this value in the project file in the first place.

- I could not figure out how to use vig_optimizer.
It seems like the project file has to first be modified so that
certain parameters are asked to be optimized but I don't know the name
of these parameters ...

- I'm currently using the computed size returned by the -s option of
autooptimiser. But it would ideally be 100%.
I guess that this issue can be addressed by using Panotools::Script
but I haven't taken a look at it already.

Also ... does anyone know a tool that could be used to automatically
crop the black parts out of the blended image ?

Thanks in advance !
Adrien

James Legg

unread,
Apr 29, 2008, 6:11:45 PM4/29/08
to hugi...@googlegroups.com
2008/4/29 Adrien Marc <ohlong...@gmail.com>:

> Also ... does anyone know a tool that could be used to automatically
> crop the black parts out of the blended image ?

Try ImageMagick. There is a command line tool called mogrify, use the
-trim option.
See http://www.imagemagick.org/script/mogrify.php for more details.

James

Adrien Marc

unread,
Apr 29, 2008, 6:37:45 PM4/29/08
to hugin and other free panoramic software
On 30 avr, 00:11, "James Legg" <lankyle...@gmail.com> wrote:
> 2008/4/29 Adrien Marc <ohlongjohn...@gmail.com>:
>
> > Also ... does anyone know a tool that could be used to automatically
> > crop the black parts out of the blended image ?
>
> Try ImageMagick. There is a command line tool called mogrify, use the
> -trim option.
> Seehttp://www.imagemagick.org/script/mogrify.phpfor more details.
>
> James

Thanks for the hint, I actually tried ImageMagick but the -trim option
won't produce a final result because the cropped part is of a unified
color, i.e.: it will only remove the totally black part of the
borders.

Adrien
Reply all
Reply to author
Forward
0 new messages