Skip to content
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ mapillary_tools supports videos (.mp4, .360) that contain any of the following t
- [DR900S-1CH](https://shop.blackvue.com/product/dr900x-1ch-plus/)
- [DR900X Plus](https://shop.blackvue.com/product/dr900x-2ch-plus/)
- Novatek-based dashcams, such as Viofo, Vantrue and Anker Roav dashcams
- 70mai dashcams, from the GPS log (`GPSData000001.txt`) that they write beside the videos: keep it in the folder of the
videos, or a copy of it in each folder of videos, front and rear, and set the camera's clock to local time (see the
command reference)

Other videos can be geotagged from the GPS that [ExifTool](https://exiftool.org/) reads, if it is installed,
or from a GPX or NMEA track recorded along with them (see [Geotagging with GPX](#geotagging-with-gpx)).
Expand Down
6 changes: 5 additions & 1 deletion docs/command_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Repeat the option or separate sources with commas. The default is `native`, then

| Source | Images | Videos |
| ------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------ |
| `native` | EXIF | The GPS of the video: GoPro (GPMF), CAMM, BlackVue, and Novatek-based dashcams |
| `native` | EXIF | The GPS of the video: GoPro (GPMF), CAMM, BlackVue, and Novatek-based dashcams; for a 70mai dashcam, its GPS log (`GPSData*.txt`) in the folder of the video (see below) |
| `exif` | EXIF | Cannot read videos |
| `exiftool_runtime` (`exiftool`) | Runs ExifTool on the image | Runs ExifTool on the video |
| `exiftool_xml` | Reads the output of `exiftool -X`, by default `%g.xml` beside the file | The same |
Expand All @@ -241,6 +241,10 @@ Gotchas:
videos, and a source limited with `"filetypes": ["image"]` leaves the videos without one.
- `gpx` and `nmea` for images need a single track file, given with `--geotag_source_path`. Without it, the
command stops (exit code 2) when an image reaches the source.
- The GPS log of a 70mai dashcam is in UTC on some cameras and 8 hours behind UTC on others. The names of the
clips, which have the time of the camera's clock, tell which, if that clock is set to local time. A clip whose
log can't be told fails with a warning, as do the clips of a clock set to UTC with a log 8 hours behind, except
from about 60°E to 180°E: there they are taken as a log in UTC in a zone at UTC+8, and get times 8 hours early.

### --video_geotag_source

Expand Down
31 changes: 31 additions & 0 deletions mapillary_tools/geotag/video_extractors/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
exceptions,
geo,
novatek_parser,
seventymai_log_parser,
telemetry,
types,
utils,
Expand Down Expand Up @@ -150,6 +151,28 @@ def extract(self) -> types.VideoMetadata:
)


class SeventymaiLogVideoExtractor(BaseVideoExtractor):
"""
Reads the GPS log that 70mai dashcams write beside their clips
"""

@override
def extract(self) -> types.VideoMetadata:
points = seventymai_log_parser.extract_points(self.video_path)

if not points:
raise exceptions.MapillaryVideoGPSNotFoundError(
"No GPS data found from the video"
)

return types.VideoMetadata(
filename=self.video_path,
filesize=utils.get_file_size(self.video_path),
filetype=types.FileType.VIDEO,
points=T.cast(T.List[geo.Point], points),
)


class NativeVideoExtractor(BaseVideoExtractor):
def __init__(
self,
Expand Down Expand Up @@ -220,6 +243,14 @@ def extract(self) -> types.VideoMetadata:
except exceptions.MapillaryVideoGPSNotFoundError:
pass

# A video without GPS of its own may be a 70mai clip with a GPS log beside it
if ft is None or types.FileType.VIDEO in ft:
extractor = SeventymaiLogVideoExtractor(self.video_path)
try:
return extractor.extract()
except exceptions.MapillaryVideoGPSNotFoundError:
pass

raise exceptions.MapillaryVideoGPSNotFoundError(
"No GPS data found from the video"
)
Loading
Loading