From: <bru...@us...> - 2008-02-02 00:36:45
|
Revision: 804 http://panotools.svn.sourceforge.net/panotools/?rev=804&view=rev Author: brunopostle Date: 2008-02-01 16:36:49 -0800 (Fri, 01 Feb 2008) Log Message: ----------- unfinished wrapper to run autopano-sift on stereographic versions of fisheye images Added Paths: ----------- trunk/Panotools-Script/bin/match-n-shift Added: trunk/Panotools-Script/bin/match-n-shift =================================================================== --- trunk/Panotools-Script/bin/match-n-shift (rev 0) +++ trunk/Panotools-Script/bin/match-n-shift 2008-02-02 00:36:49 UTC (rev 804) @@ -0,0 +1,92 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Math::Trig; +use Panotools::Script; + +# Wrapper to run autopano-sift on stereographic versions of fisheye images +# +# Bruno Postle - February 2008 +# +# UNFINISHED +# +# Stuff done so far: Takes an .oto file generated by autopano-sift and rewrites +# the control point coordinates assuming that they are based on temporary +# stereographic versions of the input photos, the resulting .oto file should be +# applicable to the original fisheye photos. + +# TODO +# +# check that it actually works +# create the stereographic images via ImageMagick and nona +# replace autopano-complete.sh logic +# do the same for rectilinear photos +# requires --fov and --projection parameters which need to be supplied by hugin +# projection and FoV need to be set in .oto files + +my $path_pto = shift || die 'supply an input pto file'; +my $path_pto_out = shift || die 'supply an output pto file'; + +my $pto = new Panotools::Script; +$pto->Read ($path_pto); + +for my $point (@{$pto->Control}) +{ + my $n = $pto->Image->[$point->{n}]; + my $N = $pto->Image->[$point->{N}]; + + ($point->{x}, $point->{y}) = + sgraphic2fisheye ({ rad_fov => deg2rad ($n->{v}), + pix_x => $point->{x}, pix_y => $point->{y}, + pix_width => $n->{w}, pix_height => $n->{h}}); + + ($point->{X}, $point->{Y}) = + sgraphic2fisheye ({ rad_fov => deg2rad ($N->{v}), + pix_x => $point->{X}, pix_y => $point->{Y}, + pix_width => $N->{w}, pix_height => $N->{h}}); +} + +$pto->Write ($path_pto_out); + +sub sgraphic2fisheye +{ + my $args = shift; + + my $A = $args->{rad_fov} / 2; + my $B = a2b ($A); + + my $pix_w2 = $args->{pix_width} / 2; + my $pix_h2 = $args->{pix_height} / 2; + + my $pix_dx = $args->{pix_x} - $pix_w2; + my $pix_dy = $args->{pix_y} - $pix_h2; + my $pix_b1 = dist ($pix_dx, $pix_dy); + + my $b1 = ($pix_b1 / $pix_w2) * $B; + my $a1 = b2a ($b1); + my $pix_a1 = ($a1 / $A) * $pix_w2; + + return ($pix_w2, $pix_h2) if ($pix_b1 == 0); + my $b1_a1 = $pix_a1 / $pix_b1; + return (($pix_dx * $b1_a1) + $pix_w2, ($pix_dy * $b1_a1) + $pix_h2); +} + +sub a2b +{ + my $a = shift; + 2 * tan ($a / 2); +} + +sub b2a +{ + my $b = shift; + 2 * atan ($b / 2); +} + +sub dist +{ + my ($x, $y) = @_; + sqrt (($x * $x) + ($y * $y)); +} + Property changes on: trunk/Panotools-Script/bin/match-n-shift ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |