Skip to content

Commit e7ff738

Browse files
committed
Switch to seconds for creation ts, fixes
1 parent 07092af commit e7ff738

File tree

9 files changed

+39
-22
lines changed

9 files changed

+39
-22
lines changed

mapillary_tools/exiftool_read_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def _aggregate_float_values_same_length(
182182
gps_fix=None,
183183
gps_precision=None,
184184
gps_ground_speed=ground_speed,
185-
unix_timestamp_ms=int(timestamp * 1000),
185+
unix_timestamp=timestamp,
186186
)
187187
)
188188

mapillary_tools/geo.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
@dataclasses.dataclass(order=True)
1818
class Point:
19+
"""
20+
5-dimensional point. Its coordinates will also be dumped to the JSON description.
21+
"""
22+
1923
# For reducing object sizes
2024
# dataclass(slots=True) not available until 3.10
2125
__slots__ = (
@@ -41,11 +45,15 @@ class GPSFix(Enum):
4145

4246
@dataclasses.dataclass
4347
class GpsPoint(Point):
48+
"""
49+
Extends Point with GPS data for filtering etc.
50+
"""
51+
4452
gps_fix: T.Optional[GPSFix] = None
4553
gps_precision: T.Optional[float] = None
4654
gps_ground_speed: T.Optional[float] = None
47-
unix_timestamp_ms: T.Optional[int] = None
4855
gps_horizontal_accuracy: T.Optional[float] = None
56+
unix_timestamp: T.Optional[int] = None
4957

5058

5159
def _ecef_from_lla_DEPRECATED(

mapillary_tools/geotag/blackvue_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def _parse_gps_box(gps_data: bytes) -> T.Generator[geo.GpsPoint, None, None]:
5050
lon=nmea.longitude,
5151
alt=nmea.altitude,
5252
angle=None,
53+
unix_timestamp=int(epoch_ms / 1000),
5354
)
5455

5556

mapillary_tools/geotag/camm_parser.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ def _parse_point_from_sample(
107107
lon=box.data.longitude,
108108
alt=box.data.altitude,
109109
angle=None,
110-
unix_timestamp_ms=int(
111-
_gps_timestamp_to_unix(box.data.time_gps_epoch) * 1000
112-
),
110+
unix_timestamp=int(_gps_timestamp_to_unix(box.data.time_gps_epoch)),
113111
gps_fix=geo.GPSFix(box.data.gps_fix_type),
114112
gps_ground_speed=speed,
115113
gps_horizontal_accuracy=box.data.horizontal_accuracy,

mapillary_tools/geotag/geotag_images_from_gpx_file.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,8 @@ def parse_gpx(gpx_file: Path) -> T.List[Track]:
146146
lon=point.longitude,
147147
alt=point.elevation,
148148
angle=None,
149-
gps_fix=None,
150-
gps_precision=None,
151149
gps_ground_speed=point.speed,
152-
unix_timestamp_ms=int(time * 1000),
150+
unix_timestamp=int(time),
153151
)
154152
)
155153

mapillary_tools/geotag/geotag_images_from_nmea_file.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ def get_lat_lon_time_from_nmea(nmea_file: Path) -> T.List[geo.GpsPoint]:
5858
lon=lon,
5959
alt=alt,
6060
angle=None,
61-
unix_timestamp_ms=int(time * 1000),
62-
gps_fix=None,
63-
gps_ground_speed=None,
64-
gps_precision=None,
61+
unix_timestamp=int(time),
6562
)
6663
)
6764

mapillary_tools/types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class VideoMetadata:
8181
points: T.Sequence[geo.Point]
8282
make: T.Optional[str] = None
8383
model: T.Optional[str] = None
84-
last_unix_ts: T.Optional[int] = None # GPS time of the last point as Unix ts
84+
last_unix_ts: T.Optional[int] = None # GPS time of the last point as Unix ts
8585

8686
def update_md5sum(self) -> None:
8787
if self.md5sum is None:
@@ -332,8 +332,8 @@ def describe_error_metadata(
332332
},
333333
"MAPLastUnixTimestamp": {
334334
"type": "integer",
335-
"description": "UNIX timestamp of the last GPS point"
336-
}
335+
"description": "UNIX timestamp of the last GPS point",
336+
},
337337
},
338338
"required": [
339339
"MAPGPSTrack",
@@ -602,7 +602,7 @@ def _from_video_desc(desc: VideoDescription) -> VideoMetadata:
602602
points=[_decode_point(entry) for entry in desc["MAPGPSTrack"]],
603603
make=desc.get("MAPDeviceMake"),
604604
model=desc.get("MAPDeviceModel"),
605-
last_unix_ts=desc.get("MAPLastUnixTimestamp")
605+
last_unix_ts=desc.get("MAPLastUnixTimestamp"),
606606
)
607607

608608

mapillary_tools/video_data_extraction/extract_video_data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def process_file(self, file: Path) -> VideoMetadataOrError:
8484
{**log_vars, "e": e},
8585
)
8686

87-
last_ts = points[-1].unix_timestamp_ms if len(points) > 0 else None
88-
last_unix_ts = int(last_ts/1000) if last_ts else None
87+
last_ts = points[-1].unix_timestamp if len(points) > 0 else None
88+
last_ts_int = int(last_ts / 1000) if last_ts else None
8989

9090
# After trying all parsers, return the points if we found any, otherwise
9191
# the last exception thrown or a default one.
@@ -99,7 +99,7 @@ def process_file(self, file: Path) -> VideoMetadataOrError:
9999
points=self._gps_points_to_points(points),
100100
make=make,
101101
model=model,
102-
last_unix_ts=last_unix_ts
102+
last_unix_ts=last_ts_int,
103103
)
104104
video_metadata.update_md5sum()
105105
return video_metadata

tests/unit/test_blackvue_parser.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,27 @@ def test_parse_points():
4545
assert x is not None
4646
assert [
4747
geo.GpsPoint(
48-
time=0.0, lat=38.8861575, lon=-76.99239516666667, alt=10.2, angle=None
48+
time=0.0,
49+
lat=38.8861575,
50+
lon=-76.99239516666667,
51+
alt=10.2,
52+
angle=None,
53+
unix_timestamp=1623057129,
4954
),
5055
geo.GpsPoint(
51-
time=0.968, lat=38.88615816666667, lon=-76.992434, alt=7.7, angle=None
56+
time=0.968,
57+
lat=38.88615816666667,
58+
lon=-76.992434,
59+
alt=7.7,
60+
angle=None,
61+
unix_timestamp=1623057130,
5262
),
5363
geo.GpsPoint(
54-
time=0.968, lat=38.88615816666667, lon=-76.992434, alt=7.7, angle=None
64+
time=0.968,
65+
lat=38.88615816666667,
66+
lon=-76.992434,
67+
alt=7.7,
68+
angle=None,
69+
unix_timestamp=1623057130,
5570
),
5671
] == list(x)

0 commit comments

Comments
 (0)