Resolution of GPS Position and Time

Started by Sam H, January 15, 2018, 06:19:33 PM

Previous topic - Next topic

Sam H

Hi,

I'm new to Exiftool having just set it up a few days ago.  I'm a surveyor by profession, not a programmer. I have no experience with Perl and I'm using the command prompts.

Question1: Can the time used for synchronizing GPS positions have a resolution of milliseconds?  It appears my workflow is rounding to the nearest second.  It seems the EXIF standard might limit GPS Time Stamp to whole seconds?

Question2: Can GPS positions have higher resolution than what is displayed in my output example EXIF?

Question3: The NMEA format might also limit the position resolution... can exiftool read a custom defined trajectory format? text or csv?

Question4: Can Exiftool read GPS time (gps seconds as a decimal number from 0h 6-Jan-1980)


I have an accurate trajectory (typically 50mm or better but can achieve relative accuracies of 10mm) and JPG imagery with millisecond resolution timing (extracted from MOV video) that I am wanting to sync and geo-position to 100mm or better.  Info was captured at about 50kph using a mobile mapping vehicle to provide the accurate trajectory.

I have converted my trajectory positions to NMEA format until I understand a more practical/custom format that Exiftool will be happy with.

My current solution for geotag and geosync is this:
exiftool -geotag NMEAGPGGAZtime.nmea -geosync="13:10:59.000@14:50:29.792" "-Geotime<SubSecDateTimeOriginal" *.jpg

EXIF of input file example:
ExifTool Version Number         : 10.74
File Name                       : DJI_0002_frame00002.jpg
Directory                       : E:/MLS/StreetCam1/DJIImagery
File Size                       : 4.0 MB
File Modification Date/Time     : 2018:01:08 14:50:31+13:00
File Access Date/Time           : 2018:01:12 13:27:45+13:00
File Creation Date/Time         : 2018:01:12 13:27:45+13:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Exif Byte Order                 : Little-endian (Intel, II)
Date/Time Original              : 2018:01:08 14:50:29
Sub Sec Time Original           : 832
Image Width                     : 4096
Image Height                    : 2160
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 4096x2160
Megapixels                      : 8.8
Date/Time Original              : 2018:01:08 14:50:29.832
-- press RETURN --




EXIF of output file example:
ExifTool Version Number         : 10.74
File Name                       : DJI_0002_frame01924.jpg
Directory                       : E:/MLS/StreetCam1/DJIImagery/JPGframes
File Size                       : 2.2 MB
File Modification Date/Time     : 2018:01:15 12:59:28+13:00
File Access Date/Time           : 2018:01:15 12:59:28+13:00
File Creation Date/Time         : 2018:01:09 09:15:27+13:00
File Permissions                : rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
Exif Byte Order                 : Little-endian (Intel, II)
Date/Time Original              : 2018:01:08 14:51:46
Sub Sec Time Original           : 712
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : South
GPS Longitude Ref               : East
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 00:12:16
Image Width                     : 4096
Image Height                    : 2160
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
GPS Altitude                    : 105.7 m Above Sea Level
GPS Latitude                    : 36 deg 51' 59.34" S
GPS Longitude                   : 174 deg 45' 57.91" E
GPS Position                    : 36 deg 51' 59.34" S, 174 deg 45' 57.91" E
Image Size                      : 4096x2160
Megapixels                      : 8.8
Date/Time Original              : 2018:01:08 14:51:46.712
-- press RETURN --

Example line of NMEA trajectory I've created:
$GPGGA,001219.246,3652,S,17445.9602,E,2,,10.58330701,105.6558663,M,-31,M,,,


Thanks in advance for any guidance!
Sam

Phil Harvey

Hi Sam,

Quote from: Sam H on January 15, 2018, 06:19:33 PM
Question1: Can the time used for synchronizing GPS positions have a resolution of milliseconds?  It appears my workflow is rounding to the nearest second.  It seems the EXIF standard might limit GPS Time Stamp to whole seconds?

The EXIF standard does support GPS fractional seconds, and ExifTool can will write this if the Geotime you set is fractional.

QuoteQuestion2: Can GPS positions have higher resolution than what is displayed in my output example EXIF?

Yes, the -c option controls the displayed coordinate format, or -n may be used to show decimal degrees.

QuoteQuestion3: The NMEA format might also limit the position resolution... can exiftool read a custom defined trajectory format? text or csv?

NMEA limits to 4 decimal places for minutes.  There is no limit on the precision for coordinates in GPX files -- maybe try this format.

QuoteQuestion4: Can Exiftool read GPS time (gps seconds as a decimal number from 0h 6-Jan-1980)

I don't recall any log file format that uses this.  So the answer would be no.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Sam H

Hi Phil,

Thanks for the answers.  A bit more time and research now and I think I've made progress, or at least learnt a bit more!

I've developed a command line that seems to do the geotagging I require for now, however doesn't seem to work as expected with subseconds. It may have an issue with reading subseconds coming from the Composite:SubSecDateTimeOriginal. I've tried quite a few variations of this command line, plus tried concatenating another entry of subsectime on the geotime value, but think i'm just grasping a bit there....

exiftool -geotag NMEAGPGGAZtime.nmea DJI_0002_frame02067.jpg -v2 "-Geotime<${Composite:SubSecDateTimeOriginal#}+13:00" -geosync=-01:39:30.792

It appears tool is reading the subseconds as 000ms, which is evidenced by all my resulting JPG files having a subsecond value of 208ms, which I think is simply the result of subtracting 792ms in the geosync value from a null millisecond value. (i.e 1000-792 = 208ms).  I noticed in another post that -d doesn't manage subseconds, and on one of your examples you simply have "-Geotime<SubSecDateTimeOriginal", so I thinking I'm missing something.  Do I have the syntax incorrect in my example or am I missing a step?  Or can -d manage subseconds with something added?



Data in example JPG
E:\MLS\StreetCam1\DJIImagery\JPGframes\ReformatTrial>exiftool DJI_0002_frame02067.jpg all:all -g0 -g
1
======== DJI_0002_frame02067.jpg
---- ExifTool ----
ExifTool Version Number         : 10.74
---- System ----
File Name                       : DJI_0002_frame02067.jpg
Directory                       : .
File Size                       : 2.8 MB
File Modification Date/Time     : 2018:01:17 21:04:54+13:00
File Access Date/Time           : 2018:01:17 21:04:54+13:00
File Creation Date/Time         : 2018:01:17 20:17:31+13:00
File Permissions                : rw-rw-rw-
---- File ----
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)
Image Width                     : 4096
Image Height                    : 2160
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
---- JFIF ----
JFIF Version                    : 1.01
Resolution Unit                 : None
X Resolution                    : 1
Y Resolution                    : 1
---- ExifIFD ----
Date/Time Original              : 2018:01:08 14:51:52
Sub Sec Time Original           : 432
---- GPS ----
GPS Version ID                  : 2.3.0.0
GPS Latitude Ref                : South
GPS Longitude Ref               : East
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 00:12:21.208
---- Composite ----
GPS Altitude                    : 105.5 m Above Sea Level
GPS Latitude                    : 36 deg 51' 59.78" S
GPS Longitude                   : 174 deg 45' 56.94" E
GPS Position                    : 36 deg 51' 59.78" S, 174 deg 45' 56.94" E
Image Size                      : 4096x2160
Megapixels                      : 8.8
Date/Time Original              : 2018:01:08 14:51:52.432
File not found: all:all
    1 image files read
    1 files could not be read



Result of command line (has been run multiple times so shows previous GPS info being removed)

E:\MLS\StreetCam1\DJIImagery\JPGframes\ReformatTrial>exiftool -geotag NMEAGPGGAZtime.nmea DJI_0002_f
rame02067.jpg -v2 -n "-Geotime<${Composite:SubSecDateTimeOriginal#}+13:00" -geosync=-01:39:30.792
Warning = Some fixes are date-less -- may use time-only interpolation
Loaded 70077 points from NMEA-format GPS track log file 'NMEAGPGGAZtime.nmea'
  GPS track start: 1970:01:01 00:02:31.231 UTC
  GPS track end:   1970:01:01 00:21:20.854 UTC
Writing File:Geotag
Writing File:Geosync
======== DJI_0002_frame02067.jpg
Setting new values from DJI_0002_frame02067.jpg
  Geotime value:   1970:01:01 00:12:21.208 UTC (incl. Geosync offset of -5970.792 sec)
Writing MIE-GPS:GPSLatitude
Writing XMP-exif:GPSLatitude if tag exists
Writing GPS:GPSLatitude
Writing MIE-GPS:GPSLongitude
Writing XMP-exif:GPSLongitude if tag exists
Writing GPS:GPSLongitude
Writing MIE-GPS:GPSAltitude
Writing XMP-exif:GPSAltitude if tag exists
Writing GPS:GPSAltitude
Writing XMP-exif:GPSAltitudeRef if tag exists
Writing GPS:GPSAltitudeRef
Writing GPS:GPSLatitudeRef
Writing GPS:GPSLongitudeRef
Deleting GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
Rewriting DJI_0002_frame02067.jpg...
  Editing tags in: APP0 APP1 File GPS IFD0 JFIF MIE-GPS XMP
  Creating tags in: APP1 File GPS IFD0 MIE-GPS
JPEG APP0 (14 bytes):
  Rewriting JFIF
JPEG APP1 (276 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
  Rewriting GPS
    - GPS:GPSLatitudeRef = 'S'
    + GPS:GPSLatitudeRef = 'S'
    - GPS:GPSLatitude = '36 51 59.77872745'
    + GPS:GPSLatitude = '36 51 59.778727357425'
    - GPS:GPSLongitudeRef = 'E'
    + GPS:GPSLongitudeRef = 'E'
    - GPS:GPSLongitude = '174 45 56.94157741'
    + GPS:GPSLongitude = '174 45 56.9415775664652'
    - GPS:GPSAltitudeRef = '0'
    + GPS:GPSAltitudeRef = '0'
    - GPS:GPSAltitude = '105.5929769'
    + GPS:GPSAltitude = '105.592976734316'
    - GPS:GPSTimeStamp = '0 12 21.208'
    + GPS:GPSTimeStamp = '00 12 21.208000000001'
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0:
JPEG DHT (28 bytes):
JPEG DHT (89 bytes):
JPEG DHT (23 bytes):
JPEG DHT (36 bytes):
JPEG SOS
    1 image files updated
E:\MLS\StreetCam1\DJIImagery\JPGframes\ReformatTrial>


Second question If I can: At one point I noticed I could report group0 times in posix time formatt.  Is there some format switch that would allow me to enter info in posix? or would this require something more in Perl?

Thanks

Sam

Phil Harvey

Hi Sam,

I can't reproduce your observations.  When I use a SubSecTimeOriginal of "432" the same GeoSync as you, I get a GPSTimeStamp ending in .64:

> exiftool a.jpg -datetimeoriginal='2018:01:08 14:51:52'
    1 image files updated
> exiftool a.jpg -subsectimeoriginal=432
    1 image files updated
> exiftool a.jpg -geotag DATETIMEONLY -'geotime<${Composite:SubSecDateTimeOriginal#}+13:00' -geosync=-01:39:30.792
    1 image files updated
> exiftool a.jpg -gps'*'
GPS Version ID                  : 2.3.0.0
GPS Time Stamp                  : 00:12:21.64
GPS Date Stamp                  : 2018:01:08
GPS Date/Time                   : 2018:01:08 00:12:21.64Z


Quote from: Sam H on January 17, 2018, 03:52:05 AM
I noticed in another post that -d doesn't manage subseconds, and on one of your examples you simply have "-Geotime<SubSecDateTimeOriginal", so I thinking I'm missing something.  Do I have the syntax incorrect in my example or am I missing a step?  Or can -d manage subseconds with something added?

I don't understand.  You are not using the -d option.  But you are correct, the -d formatting doesn't deal with subseconds.

QuoteSecond question If I can: At one point I noticed I could report group0 times in posix time formatt.  Is there some format switch that would allow me to enter info in posix? or would this require something more in Perl?

Group0 times?  Are you talking about using -d to specify the input time format.  That should be possible.  See FAQ 5 for some notes on input date/time formats.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Sam H

Hi Phil,

I just tried using the DATETIMEONLY option as you did and it works with a 64ms result as you show.  Using the GPS nmea track option still shows 208ms value.



E:\MLS\StreetCam1\DJIImagery\JPGframes\ReformatTrial>exiftool -geotag DATETIMEONLY DJI_0002_frame020
67.jpg -v2 "-Geotime<${Composite:SubSecDateTimeOriginal}+13:00" -geosync=-01:39:30.792 -k
Geotagging date/time only
Writing File:Geotag
Writing File:Geosync
======== DJI_0002_frame02067.jpg
Setting new values from DJI_0002_frame02067.jpg
  Geotime value:   2018:01:08 00:12:21.640 UTC (incl. Geosync offset of -5970.792 sec)
Deleting MIE-GPS:GPSLatitude
Deleting XMP-exif:GPSLatitude
Deleting GPS:GPSLatitude
Deleting MIE-GPS:GPSLongitude
Deleting XMP-exif:GPSLongitude
Deleting GPS:GPSLongitude
Deleting MIE-GPS:GPSAltitude
Deleting XMP-exif:GPSAltitude
Deleting GPS:GPSAltitude
Deleting XMP-exif:GPSAltitudeRef
Deleting GPS:GPSAltitudeRef
Deleting GPS:GPSLatitudeRef
Deleting GPS:GPSLongitudeRef
Writing GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
Rewriting DJI_0002_frame02067.jpg...
  Editing tags in: APP0 APP1 File GPS IFD0 JFIF MIE-GPS XMP
  Creating tags in: APP1 File GPS IFD0
JPEG APP0 (14 bytes):
  Rewriting JFIF
JPEG APP1 (172 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
  Rewriting GPS
    - GPS:GPSTimeStamp = '0 12 21.64'
    + GPS:GPSTimeStamp = '00 12 21.64'
    - GPS:GPSDateStamp = '2018:01:08'
    + GPS:GPSDateStamp = '2018:01:08'
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0:
JPEG DHT (28 bytes):
JPEG DHT (89 bytes):
JPEG DHT (23 bytes):
JPEG DHT (36 bytes):
JPEG SOS
    1 image files updated
-- press RETURN --


I tried using the result GPS time as the source for position tagging and it seems to revert back to a rounded value for the input:

E:\MLS\StreetCam1\DJIImagery\JPGframes\ReformatTrial>exiftool -geotag NMEAGPGGAZtime.nmea  DJI_0002_
frame02067.jpg -v2  "-Geotime<${GPSTimeStamp}+00:00" -k
Warning = Some fixes are date-less -- may use time-only interpolation
Loaded 70077 points from NMEA-format GPS track log file 'NMEAGPGGAZtime.nmea'
  GPS track start: 1970:01:01 00:02:31.231 UTC
  GPS track end:   1970:01:01 00:21:20.854 UTC
Writing File:Geotag
======== DJI_0002_frame02067.jpg
Setting new values from DJI_0002_frame02067.jpg
  Geotime value:   1970:01:01 00:12:21.000 UTC
Writing MIE-GPS:GPSLatitude
Writing XMP-exif:GPSLatitude if tag exists
Writing GPS:GPSLatitude
Writing MIE-GPS:GPSLongitude
Writing XMP-exif:GPSLongitude if tag exists
Writing GPS:GPSLongitude
Writing MIE-GPS:GPSAltitude
Writing XMP-exif:GPSAltitude if tag exists
Writing GPS:GPSAltitude
Writing XMP-exif:GPSAltitudeRef if tag exists
Writing GPS:GPSAltitudeRef
Writing GPS:GPSLatitudeRef
Writing GPS:GPSLongitudeRef
Deleting GPS:GPSDateStamp
Writing GPS:GPSTimeStamp
Writing XMP-exif:GPSDateTime if tag exists
Rewriting DJI_0002_frame02067.jpg...
  Editing tags in: APP0 APP1 File GPS IFD0 JFIF MIE-GPS XMP
  Creating tags in: APP1 File GPS IFD0 MIE-GPS
JPEG APP0 (14 bytes):
  Rewriting JFIF
JPEG APP1 (172 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
  Rewriting GPS
    + GPS:GPSLatitudeRef = 'S'
    + GPS:GPSLatitude = '36 51 59.7621684220565'
    + GPS:GPSLongitudeRef = 'E'
    + GPS:GPSLongitude = '174 45 56.995238403033'
    + GPS:GPSAltitudeRef = '0'
    + GPS:GPSAltitude = '105.601753718093'
    - GPS:GPSTimeStamp = '0 12 21.64'
    + GPS:GPSTimeStamp = '00 12 21'
    - GPS:GPSDateStamp = '2018:01:08'
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0:
JPEG DHT (28 bytes):
JPEG DHT (89 bytes):
JPEG DHT (23 bytes):
JPEG DHT (36 bytes):
JPEG SOS
    1 image files updated
-- press RETURN --


Notepad++ says my track file is UTF-8.  The track format looks like:
$GPGGA,000233.961,3652.070474,S,17445.77973,E,2,,0.264557603,105.8676224,M,-31,M,,,
$GPGGA,000233.991,3652.070474,S,17445.77973,E,2,,0.264093542,105.8676155,M,-31,M,,,
$GPGGA,000234.011,3652.070474,S,17445.77973,E,2,,0.263790707,105.8676205,M,-31,M,,,
$GPGGA,000234.041,3652.070474,S,17445.77973,E,2,,0.263347767,105.8676293,M,-31,M,,,


At a loss why it would be different.

JPG and NMEA track attached if you had any idea.

Phil Harvey

Hi Sam,

Ah, OK.  I can reproduce this now.

It happens only when you try to geotag from a track log that doesn't contain a date (like the NMEA GGA you are using).  If you had used NMEA RMC (preferred), this wouldn't have happened.

Geotagging with a time-only timestamp is a bit problematic, because it is easy to get the wrong day, and extra logic is necessary to try to guess the day of the track log entries.

However, this does reveal a bug in ExifTool that I will fix in the next release.  Thanks for pointing this out!

I do recommend, however, that you use NMEA RMC if possible.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Sam H

Hi Phil,

Thanks for that, I have switched to RMC for this trial and it is working!  RMC isn't quite adequate for my overall objective so I will look at converting my trajectory log to one of the other formats that Exiftool supports.  Hoping to include roll/pitch/yaw from trajectory (or at least orientation/yaw), but can probably populate these values in surplus fields of a trajectory format and change tag name later in the exif if required.

Thanks for the help

Sam

Phil Harvey

Hi Sam,

You can include roll/pitch/yaw by interleaving GPRMC with PTNTHPR (the PTNTHPR should come first).

            # $PTNTHPR,85.9,N,-0.9,N,0.8,N*HH
            # $PTNTHPR,heading,heading status,pitch,pitch status,roll,roll status,*cs
            # status: L=low alarm, M=low warning, N=normal, O=high warning
            #         P=high alarm, C=tuning analog circuit
            # (ignore this information on any alarm status)


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).