2
# Merge two or more pto files - Chris
3
# It's useful to make panoramas by more image rows,
4
# if control points for each row were generated by autopano.
5
# After the merging do not forget to make control points between
12
Usage: mergepto [-o merged.pto ] row1.pto row2.pto [ row3.pto ... ]
16
my $outname="merged.pto";
17
my @ptos; # pto file names
18
my @clines; # control point lines
19
my @ilines; # input image lines
20
my $pline; # save the p line
21
my $mline; # save the m line
22
my $first_i_line=1; # first i line should not be altered
23
my $image_offset=0; # value to increment the image numbers in c lines
25
while ($_=shift(@ARGV))
26
{ if (/-o/) { $outname=shift; }
27
else { push(@ptos,$_); }
30
if ( @ptos < 2 ) { die "Please give at least two pto files\n"; }
31
open(OUT,">$outname") || die "Could not open $outname for writing\n";
32
print "Merging " . @ptos . " pto files to $outname...\n";
35
for(my $f=0;$f < @ptos;$f++)
36
{ # print "Processing " . ($f+1) . ":$ptos[$f]...\n";
38
open(IN,"<$ptos[$f]") || die "Could not open $ptos[$f]\n";
44
$pline=$_ if (/^p / && $f eq 0);
45
$mline=$_ if (/^m / && $f eq 0);
49
if ($first_i_line) { chop; push(@ilines,$_); undef $first_i_line; }
52
# set the same lens parameters as by the first image
57
push(@ilines,join(' ',@i));
63
my ($img1)= / n(\d+) /;
64
my ($img2)= / N(\d+) /;
74
# image number offset for the next file
75
$image_offset+=$images_in_pto;
79
print OUT "# merged pto files\n\n$pline$mline\n";
80
foreach my $il (@ilines) { print OUT $il . "\n"; }
81
print OUT "\n# control points\n";
82
foreach my $cl (@clines) { print OUT $cl . "\n"; }
85
print "$outname has " . @ilines . " images and " . @clines . " control points.\n";