Phil,
this is a bit embarrassing.
Anyway, here is the "working" script I came up with.
For accuracy I calculate the bearing differently for the first, middle and last image of a series.
Do you think the formulas are right?
May I ask you to take part in the GPled
DIY-streetview project of mine?
We could really need some help.
I am available at janmartin AT diy-streetview DOT org for further information.
Thanks,
Jan
#!/usr/bin/perl
# use Image::ExifTool;
use Geo::Ellipsoid;
# streetview_add_bearing.pl
#
# version 0.1 of January 2nd 2010.
# The most up-to-date version of the script is available from:
# http://www.diy-streetview.org/forum/viewforum.php?f=21
#
# Licence: GPL 3 or later
# Copyright: Jan of www.DIY-streetview.org
#
# What this is for:
# This script is to calculate and add the bearing to individual streetviews of a series of streetvi
+ews.
# Streetviews typically are taken every 5 seconds from a moving car or bicycle etc.
#
# Assumtions:
# This scipt assumes the middle of the streetview image points straight forward. (All streetviews I
+ know of do.)
#
# Usage:
# Backup your original images!
# Only ever work with copies!
#
# Run this file on a directory with GEOTAGGED panoramas (or simply photos) to add GPSImgDirectionRe
+f and GPSImgDirection to the EXIF info.
#
# Example for Linux:
# perl streetview_add_bearing.pl /home/me/streetviews
#
# This script has been tested on Ubuntu 9.10 Karmic Koala.
print "\nDirectory = $ARGV[0]";
my(@lines) = `exiftool -n -p \'\$FileName \$GPSLatitude \$GPSLongitude \$GPSAltitude \$GPSDateStamp
+ \$GPSTimeStamp \' -q -f $ARGV[0]`;
@lines = sort(@lines);
$size = @lines;
for ($i=0; $i<$size; $i++) {
($FileName, $GPSLatitude, $GPSLongitude, $GPSAltitude, $GPSDateStamp, $GPSTimeStamp) = split(' ',$
+lines[$i]);
$geo = Geo::Ellipsoid->new(ellipsoid=>'WGS84', units=>'degrees');
if ($i == 0) { # first streetview F = Following
($FileNameF, $GPSLatitudeF, $GPSLongitudeF, $GPSAltitudeF, $GPSDateStampF, $GPSTimeStampF) = sp
+lit(' ',$lines[$i+1]);
my( $distanceF, $bearingF ) = $geo->to( $GPSLatitude, $GPSLongitude, $GPSLatitudeF, $GPSLongitud
+eF );
print"\nFirst:\n";
print"$FileName $FileNameF\n";
print"$GPSLatitude $GPSLatitudeF\n";
print"$GPSLongitude $GPSLongitudeF\n";
$bearingF = sprintf("%.2f", $bearingF);
print"bearing: $bearingF\n";
system("exiftool -overwrite_original $ARGV[0]/$FileName \'-GPSImgDirectionRef=T\' \'-GPSImgDirec
+tion=$bearingF\'");
}
elsif($i<$size-1) { # middle streetviews M = Middle
($FileNameF, $GPSLatitudeF, $GPSLongitudeF, $GPSAltitudeF, $GPSDateStampF, $GPSTimeStampF) = sp
+lit(' ',$lines[$i+1]);
my( $distanceF, $bearingF ) = $geo->to( $GPSLatitude, $GPSLongitude, $GPSLatitudeF, $GPSLongitud
+eF );
($FileNameB, $GPSLatitudeB, $GPSLongitudeB, $GPSAltitudeB, $GPSDateStampB, $GPSTimeStampB) = sp
+lit(' ',$lines[$i-1]);
my( $distanceB, $bearingB ) = $geo->to( $GPSLatitude, $GPSLongitude, $GPSLatitudeB, $GPSLongitud
+eB );
$bearingM=abs(($bearingB+$bearingF)/2);
print"\nMiddle:\n";
print"$FileNameB $FileName $FileNameF\n";
print"$GPSLatitudeB $GPSLatitude $GPSLatitudeF\n";
print"$GPSLongitudeB $GPSLongitude $GPSLongitudeF\n";
$bearingM = sprintf("%.2f", $bearingM);
print"bearing: $bearingM\n";
system("exiftool -overwrite_original $ARGV[0]/$FileName \'-GPSImgDirectionRef=T\' \'-GPSImgDirec
+tion=$bearingM\'");
}
elsif($i == $size-1) { # last streetview B = Befores
($FileNameB, $GPSLatitudeB, $GPSLongitudeB, $GPSAltitudeB, $GPSDateStampB, $GPSTimeStampB) = sp
+lit(' ',$lines[$i-1]);
my( $distanceB, $bearingB ) = $geo->to( $GPSLatitude, $GPSLongitude, $GPSLatitudeB, $GPSLongitud
+eB );
$bearingB=abs(180-$bearingB);
print"\nLast:\n";
print"$FileNameB $FileName\n";
print"$GPSLatitudeB $GPSLatitude\n";
print"$GPSLongitudeB $GPSLongitude\n";
$bearingB = sprintf("%.2f", $bearingB);
print"bearing: $bearingB\n";
system("exiftool -overwrite_original $ARGV[0]/$FileName \'-GPSImgDirectionRef=T\' \'-GPSImgDirec
+tion=$bearingB\'");
}
} # end for