From: <bru...@us...> - 2009-11-26 23:30:23
|
Revision: 1167 http://panotools.svn.sourceforge.net/panotools/?rev=1167&view=rev Author: brunopostle Date: 2009-11-26 23:30:08 +0000 (Thu, 26 Nov 2009) Log Message: ----------- unfinished ptoanchor: run apsc for each exposure layer, specify options in .pto file, run autooptimiser and vig_optimize. Modified Paths: -------------- trunk/Panotools-Script/bin/panostart trunk/Panotools-Script/bin/ptoanchor Modified: trunk/Panotools-Script/bin/panostart =================================================================== --- trunk/Panotools-Script/bin/panostart 2009-11-25 23:33:35 UTC (rev 1166) +++ trunk/Panotools-Script/bin/panostart 2009-11-26 23:30:08 UTC (rev 1167) @@ -4,7 +4,6 @@ use warnings; use Getopt::Long; use Pod::Usage; -use Panotools::Script; use Panotools::Makefile; use Panotools::Photos; Modified: trunk/Panotools-Script/bin/ptoanchor =================================================================== --- trunk/Panotools-Script/bin/ptoanchor 2009-11-25 23:33:35 UTC (rev 1166) +++ trunk/Panotools-Script/bin/ptoanchor 2009-11-26 23:30:08 UTC (rev 1167) @@ -10,98 +10,115 @@ use File::Temp qw/tempdir/; my $path_output; -my $pix_max = 1600; -my $points = 25; -my $noransac = 0; -my $refine = 0; my $clean = 0; my $help = 0; # TODO projects with relative paths -# TODO run autopano-sift-c for each exposure layer # TODO run panomatic too +# TODO write a Makefile instead of system() +# TODO $pto->ExposureLayers() and drop Panotools::Photos +# TODO run vig_optimize conditionally +# TODO $stub needs to be supplied on command-line GetOptions ('o|output=s' => \$path_output, - 's|size=i' => \$pix_max, - 'p|points=i' => \$points, - 'n|noransac' => \$noransac, - 'r|refine' => \$refine, 'c|clean' => \$clean, 'h|help' => \$help); pod2usage (-verbose => 2) if $help; pod2usage (2) unless (defined $path_output and scalar @ARGV); -my $ransac = 1; $ransac = 0 if $noransac; -# extra refine options -my @refine = (); @refine = ('--refine', '--keep-unrefinable', 0) if $refine; +my $stub = tempdir (CLEANUP => $clean); +print STDERR "Temporary files will be saved in $stub\n" unless $clean; -my $tempdir = tempdir (CLEANUP => $clean); -print STDERR "Temporary files will be saved in $tempdir\n" unless $clean; - my $path_input = shift @ARGV; my $pto = new Panotools::Script; $pto->Read ($path_input); +my $pix_max = $pto->Option->{cpgenSize} || 1600; +my $points = $pto->Option->{cpgenNumber} || 25; +my $ransac = 1; +$ransac = 0 if (defined $pto->Option->{cpgenRansac} and $pto->Option->{cpgenRansac} eq 'false'); +my @refine = (); +@refine = ('--refine', '--keep-unrefinable', 0) + if (defined $pto->Option->{cpgenRefine} and $pto->Option->{cpgenRefine} eq 'true'); + my $photos_all = new Panotools::Photos (map {$_->Path ($path_input)} @{$pto->Image}); my $tmp; $tmp->{$_} = undef for (map {$_->{j} if defined $_->{j}} @{$pto->Image}); -my @stack_numbers = keys %{$tmp}; -if (scalar @stack_numbers > 1) +if (scalar keys %{$tmp} > 1) { - my $longest = shift @{$photos_all->Speeds}; - print STDERR "Longest exposure: $longest\n"; - my $bases; my $stacks; for my $index_photo (0 .. scalar @{$photos_all} -1) { - my $et = $photos_all->[$index_photo]->{exif}->{ExposureTime} || $photos_all->[$index_photo]->{exif}->{ShutterSpeed}; - push @{$bases}, $index_photo if $et eq $longest; + for my $speed (@{$photos_all->Speeds}) + { + my $et = $photos_all->[$index_photo]->{exif}->{ExposureTime} + || $photos_all->[$index_photo]->{exif}->{ShutterSpeed}; + push @{$bases->{$speed}}, $index_photo if $et eq $speed; + } + next if $pto->Image->[$index_photo]->{r} =~ /^=/; push @{$stacks->[$pto->Image->[$index_photo]->{j}]}, $index_photo; } - my $pto_bases = $pto->Subset (@{$bases}); - my $path_pto_bases = File::Spec->catfile ($tempdir, "bases.pto"); - $pto_bases->Write ($path_pto_bases .'.0'); + my @path_pto; + + for my $speed (@{$photos_all->Speeds}) + { + my @id_images = @{$bases->{$speed}}; + $speed =~ s/[^0-9a-zA-Z]/-/g; + my $path_pto_bases = File::Spec->catfile ($stub, 'bases_'. $speed); - $ransac = 0 if $pto_bases->Image->[0]->{v} > 60; + $ransac = 0 if $pto->Image->[$id_images[0]]->V ($pto) > 60; - system ('autopano-sift-c', '--maxdim', $pix_max, @refine, '--ransac', $ransac, - '--maxmatches', $points, $path_pto_bases .'.1', $path_pto_bases .'.0'); - system ('celeste_standalone', '-i', $path_pto_bases .'.1', '-o', $path_pto_bases .'.2'); - system ('cpclean', '-o', $path_pto_bases .'.3', $path_pto_bases .'.2'); + system ('ptosplit', @id_images, $path_input, "$path_pto_bases.0.pto"); + system ('autopano-sift-c', '--maxdim', $pix_max, @refine, '--ransac', $ransac, + '--maxmatches', $points, "$path_pto_bases.1.pto", "$path_pto_bases.0.pto"); + system ('celeste_standalone', '-i', "$path_pto_bases.1.pto", '-o', "$path_pto_bases.2.pto"); + system ('cpclean', '-o', "$path_pto_bases.3.pto", "$path_pto_bases.2.pto"); - my @path_pto = ($path_input, $path_pto_bases .'.3'); + push @path_pto, "$path_pto_bases.3.pto"; + } for my $stack (@{$stacks}) { + next unless scalar @{$stack} > 1; + my @path_photos = map {$pto->Image->[$_]->Path ($path_input)} @{$stack}; my @projection = (); @projection = ('-e') if ($pto->Image->[$stack->[0]] == 2 or $pto->Image->[$stack->[0]] == 3); my $deg_fov = $pto->Image->[$stack->[0]]->V ($pto); - my $path_pto_stack = File::Spec->catfile ($tempdir, 'stack_'. join ('_', @{$stack}) .'.pto'); + my $path_pto_stack = File::Spec->catfile ($stub, 'stack_'. join ('_', @{$stack}) .'.pto'); system ('align_image_stack', @projection, '-f', $deg_fov, '-p', $path_pto_stack, @path_photos); push @path_pto, $path_pto_stack; } - my $path_pto_merged = File::Spec->catfile ($tempdir, "merged.pto"); - system ('ptomerge', @path_pto, $path_pto_merged); - system ('ptosort', '--image', 'n', $path_pto_merged, $path_output); + my $path_pto_merged = File::Spec->catfile ($stub, 'merged.pto'); + system ('ptomerge', $path_input, @path_pto, $path_pto_merged); + system ('autooptimiser', '-a', '-l', '-s', '-o', $path_output, $path_pto_merged); } else { - my $path_pto_merged = File::Spec->catfile ($tempdir, "merged.pto"); + $ransac = 0 if $pto->Image->[0]->V ($pto) > 60; + + my $path_pto_simple = File::Spec->catfile ($stub, 'simple'); + system ('autopano-sift-c', '--maxdim', $pix_max, @refine, '--ransac', $ransac, - '--maxmatches', $points, $path_pto_merged .'.0', $path_input); - system ('celeste_standalone', '-i', $path_pto_merged .'.0', '-o', $path_pto_merged .'.1'); - system ('ptomerge', $path_input, $path_pto_merged .'.1', $path_pto_merged); - system ('ptosort', '--image', 'n', $path_pto_merged, $path_output); + '--maxmatches', $points, "$path_pto_simple.0.pto", $path_input); + system ('celeste_standalone', '-i', "$path_pto_simple.0.pto", '-o', "$path_pto_simple.1.pto"); + system ('cpclean', '-o', "$path_pto_simple.2.pto", "$path_pto_simple.1.pto"); + system ('ptomerge', $path_input, "$path_pto_simple.2.pto", "$path_pto_simple.3.pto"); + system ('autooptimiser', '-a', '-l', '-s', '-o', "$path_pto_simple.4.pto", + "$path_pto_simple.3.pto"); + system ('ptovariable', '--positions', '--vignetting', '--response', '--exposure', + '-o', "$path_pto_simple.5.pto", "$path_pto_simple.4.pto"); + system ('vig_optimize', '-o', $path_output, "$path_pto_simple.5.pto"); } + exit 0; __END__ @@ -116,24 +133,26 @@ Options: -o | --output name Filename of created panorama project - -s | --size number Downsize images until width and height is - smaller than number, default 1600 - -p | --points number Number of generated control points between, - each pair, default: 25 - -n | --noransac No ransac detection, useful for fisheye images - -r | --refine Refine the found control points using the - original images, delete unrefinable. -c | --clean Delete all temporary files afterwards. -h | --help Outputs help documentation. =head1 DESCRIPTION -B<ptoanchor> is a wrapper around autopano-sift-c and align_image_stack that -takes a .pto project and adds control points. +B<ptoanchor> is a wrapper various tools that generates control points and +optimises a Hugin project using a .pto project as input. Output is in the form +of a .pto project. Stacks are passed to align_image_stack for processing, but need to be indicated with 'i-line' 'j' parameters in the input project file. +Control point generator parameters are set via Option lines in the input +project: + + #hugin_cpgenSize 1500 + #hugin_cpgenNumber 25 + #hugin_cpgenRansac true + #hugin_cpgenRefine false + =head1 LICENSE This program is free software; you can redistribute it and/or This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |