Skip to content

Read NMEA files that log sentences without a fix, or from other talkers - #870

Merged
caglarpir merged 2 commits into
mapillary:mainfrom
caglarpir:read-real-world-nmea
Oct 22, 2026
Merged

caglarpir merged 2 commits into
mapillary:mainfrom
caglarpir:read-real-world-nmea

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Stacked on #869; review the last commit.

Problem

The NMEA reader, which images and (with #869) videos share, fails on files that receivers commonly write:

  • An RMC sentence without a date, such as the last one of a log cut short, crashed images with a TypeError; GGA sentences with no RMC sentence crashed with an UnboundLocalError. A video was failed as if the file were not NMEA.
  • A void RMC sentence, logged before the first fix, gave the date of the receiver's unset clock, and a GGA sentence without a fix added a point at 0, 0.
  • Only $GP sentences were read, so a log of a multi-system receiver, which writes $GN sentences, gave no points.

Fix

Skip RMC sentences that are void or have no date or time, and GGA sentences without a time or a fix. Read the sentences of any talker, keeping the first fix of each time, so a receiver that logs a fix from two talkers gives one point. GGA sentences without the date of any RMC sentence give no points, with a warning. Valid files give the same points.

Verification

  • Two valid NMEA logs (111 and 650 points) parse to the same points; image descriptions are unchanged.
  • A $GN version of the 650-point log, and one starting with void sentences, give the same video track as the original.
  • New unit tests with inline NMEA snippets. Unit and integration tests, doctests, mypy --python-version 3.9, ruff check, ruff format --check and usort diff are clean.

The README lists NMEA among the sources that geotag videos, but no video
was read from an NMEA file: process and video_process gave the video no
description at all, and exited 0, so it was silently left out. Sampling
fell back to the GPS in the video, which a video recorded with an
external logger does not have.

Read the NMEA file into a track and place it on the video exactly as a
GPX track is: synced by the GPS clock of the video, or by
--video_start_time, or assumed to start with the video, with the
interpolation options, the coverage checks and the clipping of process.
GPXVideoExtractor now reads its file through _parse_tracks(), which
NMEAVideoExtractor overrides, and names the format of the file in its
messages. A file that is not valid NMEA is reported as an invalid GPX
file is. Interval sampling checks an NMEA track started with the video
by --interpolation_use_gpx_start_time as it checks a GPX track.

On an action camera video with a GPX and the same track as NMEA, process gives
the same track, and video_process samples the same frames at the same
positions.
Images geotagged from an NMEA file failed with a traceback when the
file had an RMC sentence without a date, such as the last one of a log
cut short (TypeError), or GGA sentences and no RMC sentence at all
(UnboundLocalError), and a video was failed as if the file were not
NMEA. A void RMC sentence, which receivers log before they acquire a
fix, gave the date of their unset clock, and a GGA sentence without a
fix added a point at 0, 0. Only $GP sentences were read, so a log of a
receiver of several systems, which writes $GN sentences, gave no points
at all.

Skip RMC sentences that are void or have no date or time, and GGA
sentences without a time or a fix, and read the sentences of any
talker, keeping the first fix of each time, so that a receiver that logs
a fix from two talkers does not give two points at the same time. GGA
sentences without the date of any RMC sentence give no points, with a
warning. The points read from valid files are the same.
@caglarpir
caglarpir force-pushed the read-real-world-nmea branch from a7efce7 to 5824912 Compare October 22, 2026 20:18
@caglarpir
caglarpir merged commit e7f060c into mapillary:main Oct 22, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant