From: <bru...@us...> - 2009-12-15 22:14:29
|
Revision: 1183 http://panotools.svn.sourceforge.net/panotools/?rev=1183&view=rev Author: brunopostle Date: 2009-12-15 22:14:20 +0000 (Tue, 15 Dec 2009) Log Message: ----------- ptochain consecutive images control point finder Modified Paths: -------------- trunk/Panotools-Script/Changes trunk/Panotools-Script/MANIFEST trunk/Panotools-Script/bin/ptoanchor Added Paths: ----------- trunk/Panotools-Script/bin/ptochain Modified: trunk/Panotools-Script/Changes =================================================================== --- trunk/Panotools-Script/Changes 2009-12-15 22:12:04 UTC (rev 1182) +++ trunk/Panotools-Script/Changes 2009-12-15 22:14:20 UTC (rev 1183) @@ -15,6 +15,7 @@ - match-n-shift fix detection of longest exposure in bracketed sets - match-n-shift just write a .pto project and use ptoanchor to find features - pto2mk2 alternative to pto2mk + - ptochain consecutive images control point finder - ptoanchor replacement makefile based control point generator using autopano-sift-c and align_image_stack - Panotools::Script::Line::Image renamed V() to v() etc... - UnifyLenses() method Modified: trunk/Panotools-Script/MANIFEST =================================================================== --- trunk/Panotools-Script/MANIFEST 2009-12-15 22:12:04 UTC (rev 1182) +++ trunk/Panotools-Script/MANIFEST 2009-12-15 22:14:20 UTC (rev 1183) @@ -18,6 +18,7 @@ bin/pto2mk2 bin/ptoanchor bin/ptocentre +bin/ptochain bin/ptoclean bin/ptodummy bin/ptograph @@ -84,6 +85,7 @@ t/031.matrix.t t/032.image.t t/033.points.t +t/034.angle.t t/101.makerule.t t/102.platform.t t/103.platform.t Modified: trunk/Panotools-Script/bin/ptoanchor =================================================================== --- trunk/Panotools-Script/bin/ptoanchor 2009-12-15 22:12:04 UTC (rev 1182) +++ trunk/Panotools-Script/bin/ptoanchor 2009-12-15 22:14:20 UTC (rev 1183) @@ -2,12 +2,10 @@ use strict; use warnings; -use File::Spec; use Getopt::Long; use Pod::Usage; use Panotools::Makefile; use Panotools::Script; -use File::Temp qw/tempdir/; my $path_prefix; my $path_output; Added: trunk/Panotools-Script/bin/ptochain =================================================================== --- trunk/Panotools-Script/bin/ptochain (rev 0) +++ trunk/Panotools-Script/bin/ptochain 2009-12-15 22:14:20 UTC (rev 1183) @@ -0,0 +1,167 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Getopt::Long; +use Pod::Usage; +use Panotools::Makefile; +use Panotools::Script; + +my $path_prefix; +my $path_output; +my $help = 0; + +GetOptions ('p|prefix=s' => \$path_prefix, + 'o|output=s' => \$path_output, + 'h|help' => \$help); + +pod2usage (-verbose => 2) if $help; +pod2usage (2) unless (defined $path_prefix and scalar @ARGV); + +$path_prefix =~ s/\.[[:alnum:]]+$//; + +my $path_input = shift @ARGV; + +my $mk = new Panotools::Makefile; +$mk->Comment ('Command-line tools'); +$mk->Variable ('PTOMERGE', 'ptomerge'); +$mk->Variable ('AUTOPANO', 'autopano'); +$mk->Variable ('GENKEYS', 'generatekeys'); +$mk->Variable ('CELESTE', '-', 'celeste_standalone'); +$mk->Variable ('CPCLEAN', 'cpclean'); +$mk->Variable ('RM', '-', 'rm'); + +$mk->Comment ('Input project file and prefix for output'); +$mk->Variable ('PROJECT_FILE', $path_input); +$mk->Variable ('PREFIX', $path_prefix); + +my $rule = $mk->Rule ('all'); +$rule->Prerequisites ('$(PREFIX).pto'); + +$mk->Comment ("Files we don't need afterwards"); +my $var_tempfiles = $mk->Variable ('TEMP_FILES'); + +$rule = $mk->Rule ('clean'); +$rule->Command ('$(RM_SHELL)', '$(TEMP_FILES_SHELL)'); + +$rule = $mk->Rule ('.PHONY'); +$rule->Prerequisites ('all', 'clean'); + +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'); + +$ransac = 0 if $pto->Image->[0]->v ($pto) > 60; + +$mk->Comment ('All input photos'); +$mk->Variable ('INPUT_IMAGES', map {$_->Path ($path_input)} @{$pto->Image}); + +$mk->Comment ('Rule to create feature-point files when required'); +$rule = $mk->Rule ('%.key'); +$rule->Prerequisites ('%'); +$rule->Command ('$(GENKEYS_SHELL)', '$<', '$@', $pix_max); + +$var_tempfiles->Values (map {$_->Path ($path_input) .'.key'} @{$pto->Image}); + +my $var_links = $mk->Variable ('LINK_PTOS'); + +$mk->Comment ('Rules to match points between adjacent images'); +for my $id_image (0 .. scalar @{$pto->Image} -2) +{ + my $path_a = $pto->Image->[$id_image]->Path ($path_input); + my $path_b = $pto->Image->[$id_image +1]->Path ($path_input); + # strip any suffixes + $path_a =~ s/\.[[:alnum:]]+$//; + $path_b =~ s/\.[[:alnum:]]+$//; + # strip all but filename + $path_b =~ s/.*[\/\\]//; + my $stub = $path_a .'-'. $path_b; + + $rule = $mk->Rule ($stub .'.a.pto'); + $rule->Prerequisites ($pto->Image->[$id_image]->Path ($path_input) .'.key', + $pto->Image->[$id_image +1]->Path ($path_input) .'.key'); + $rule->Command ('$(AUTOPANO_SHELL)', @refine, '--ransac', $ransac, + '--maxmatches', $points, $stub .'.a.pto', + $pto->Image->[$id_image]->Path ($path_input) .'.key', + $pto->Image->[$id_image +1]->Path ($path_input) .'.key'); + + $var_tempfiles->Values ($stub .'.a.pto'); + + $rule = $mk->Rule ($stub .'.pto'); + $rule->Prerequisites ($stub .'.a.pto'); + $rule->Command ('$(CPCLEAN_SHELL)', '-o', $stub .'.pto', $stub .'.a.pto'); + + $var_links->Values ($stub .'.pto'); + $var_tempfiles->Values ($stub .'.pto'); +} + +$rule = $mk->Rule ('$(PREFIX).pto'); +$rule->Prerequisites ('$(PROJECT_FILE)', '$(LINK_PTOS)'); +$rule->Command ('$(PTOMERGE_SHELL)', '$(PROJECT_FILE_SHELL)', '$(LINK_PTOS_SHELL)', + '$(PREFIX_SHELL).pto'); + +my $rule_secondary = $mk->Rule ('.SECONDARY'); +$rule_secondary->Prerequisites ('$(TEMP_FILES)'); + +$mk->Write ($path_output) if defined $path_output; +$mk->DoIt ('all', 'clean') unless defined $path_output; + +exit 0; + +__END__ + +=head1 NAME + +ptochain - add control points to a Hugin project between consecutive photos + +=head1 SYNOPSIS + +ptochain [options] --output project.mk --prefix prefix input.pto + + Options: + -o | --output file Output Makefile + -p | --prefix Prefix of output project + -h | --help Outputs help documentation. + +=head1 DESCRIPTION + +B<ptochain> is a wrapper various tools that generates control point. Output is +in the form of a .pto project. + +If the --output option is given, rules for generating the project are written +to a Makefile, if --output isn't set then these rules will be executed +immediately. + +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 +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +=head1 SEE ALSO + +L<http://hugin.sourceforge.net/> + +=head1 AUTHOR + +Bruno Postle - November 2009. + +=cut + +=begin perl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |