Hey All!
I'm trying to get very precise geocoding for every frame of a video based on a GPX file, which has many fewer trackpoints than there are frames in the video. Because of this, I need to geosync as accurately as possible. Just specifying that the first image and first trackpoint should be at the same time, via
exiftool -overwrite_original -geosync="${gpx_start_time}@path/to/frame/0000001.jpg" -v2 -geotag path/to/track.gpx /path/to/frame_images
isn't getting me the precision I need, so I'm thinking of trying also adding the last trackpoint/frame as a geosync point, and maybe a pair in the middle of the video?
All that's just background -- basically, I'm wondering if there's a way to fetch the data for the last point in a GPX file with exiftool, not just the first. Otherwise, I'll have to use a different tool to get that data, which will be slower, since everything won't all be in one command.
Thanks!
The -geotag feature interpolates between trackpoints based on the time, so it wouldn't give the best results to interpolate between these interpolated values. You could do exactly what you want with a Perl script that uses the ExifTool module, but the exiftool app may not be able to do exactly what you want.
Exactly what do you want to do with the coordinates for each frame of the video? The exiftool app is only designed to geotag images extracted for each frame. If you wanted to (say) output them to a text file, then a Perl script could do this.
- Phil
Ah, good to know re: the interpolation -- you're right that interpolating based on interpolated data wouldn't make a lot of sense.
I'm building a program to visually recognize objects in videos, and associate those objects with a lat/long. For instance, if it's a video from a car driving down the road, I want to be able to detect a stop sign, and record the precise location of that stop sign. It could definitely work to output the GPS data to a CSV, as long as the location data is clearly associated with its corresponding video frame.
Do you think I should be writing this using Image::ExifTool instead of using the command line utility?
Thanks!
Attached is a simple Perl script that uses Image::ExifTool to interpolate the lat/lon given an input track file and timestamp.
You use it like this:
get_gps.pl track_log.gpx "2003:05:24 13:09:30.5Z"
You can modify the script to do whatever you want with the resulting lat/lon values.
- Phil
#!/usr/bin/perl -w
#
# File: get_gps.pl
#
# Description: Get GPS position interpolated from positions in log file
#
# Syntax: get_gps.pl [-v] LOGFILE TIMESTAMP
#
# Options: -v - verbose
#
use strict;
use Image::ExifTool;
use Image::ExifTool::GPS;
my $et = new Image::ExifTool;
if (@ARGV and $ARGV[0] eq '-v') {
shift;
$et->Options(Verbose => 3);
}
my $logFile = shift || 't/images/Geotag.gpx';
my $timeStamp = shift || '2003:05:24 13:09:30.5';
my ($n, $err) = $et->SetNewValue(Geotag => $logFile);
die "$err\n" if $err;
($n, $err) = $et->SetNewValue('XMP:Geotime' => $timeStamp);
die "$err\n" if $err;
my $lat = Image::ExifTool::GPS::ToDegrees($et->GetNewValue('GPSLatitude'),1);
my $lon = Image::ExifTool::GPS::ToDegrees($et->GetNewValue('GPSLongitude'),1);
die "No lat/lon\n" unless defined $lat and defined $lon;
print "$lat $lon\n";
# end
Thank you! I'll play around with that. I'll come back if I have questions (which seems pretty likely).
I appreciate the fast and thorough responses.