mapillary-tools 0.13.1a1__py3-none-any.whl → 0.13.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- VERSION = "0.13.1a1"
1
+ VERSION = "0.13.2"
@@ -25,7 +25,13 @@ class GeotagImagesFromGPXFile(GeotagImagesFromGeneric):
25
25
  num_processes: T.Optional[int] = None,
26
26
  ):
27
27
  super().__init__()
28
- tracks = parse_gpx(source_path)
28
+ try:
29
+ tracks = parse_gpx(source_path)
30
+ except Exception as ex:
31
+ raise RuntimeError(
32
+ f"Error parsing GPX {source_path}: {ex.__class__.__name__}: {ex}"
33
+ )
34
+
29
35
  if 1 < len(tracks):
30
36
  LOG.warning(
31
37
  "Found %s tracks in the GPX file %s. Will merge points in all the tracks as a single track for interpolation",
@@ -13,8 +13,12 @@ class CammParser(BaseParser):
13
13
  parser_label = "camm"
14
14
 
15
15
  @functools.cached_property
16
- def __camera_info(self) -> T.Tuple[str, str]:
17
- with self.videoPath.open("rb") as fp:
16
+ def _camera_info(self) -> T.Tuple[str, str]:
17
+ source_path = self.geotag_source_path
18
+ if not source_path:
19
+ return "", ""
20
+
21
+ with source_path.open("rb") as fp:
18
22
  return camm_parser.extract_camera_make_and_model(fp)
19
23
 
20
24
  def extract_points(self) -> T.Sequence[geo.Point]:
@@ -28,15 +32,7 @@ class CammParser(BaseParser):
28
32
  return []
29
33
 
30
34
  def extract_make(self) -> T.Optional[str]:
31
- source_path = self.geotag_source_path
32
- if not source_path:
33
- return None
34
- with source_path.open("rb") as _fp:
35
- return self.__camera_info[0] or None
35
+ return self._camera_info[0] or None
36
36
 
37
37
  def extract_model(self) -> T.Optional[str]:
38
- source_path = self.geotag_source_path
39
- if not source_path:
40
- return None
41
- with source_path.open("rb") as _fp:
42
- return self.__camera_info[1] or None
38
+ return self._camera_info[1] or None
@@ -20,7 +20,13 @@ class GpxParser(BaseParser):
20
20
  if not path:
21
21
  return []
22
22
 
23
- gpx_tracks = geotag_images_from_gpx_file.parse_gpx(path)
23
+ try:
24
+ gpx_tracks = geotag_images_from_gpx_file.parse_gpx(path)
25
+ except Exception as ex:
26
+ raise RuntimeError(
27
+ f"Error parsing GPX {path}: {ex.__class__.__name__}: {ex}"
28
+ )
29
+
24
30
  if 1 < len(gpx_tracks):
25
31
  LOG.warning(
26
32
  "Found %s tracks in the GPX file %s. Will merge points in all the tracks as a single track for interpolation",
@@ -32,40 +38,71 @@ class GpxParser(BaseParser):
32
38
  if not gpx_points:
33
39
  return gpx_points
34
40
 
41
+ offset = self._synx_gpx_by_first_gps_timestamp(gpx_points)
42
+
43
+ self._rebase_times(gpx_points, offset=offset)
44
+
45
+ return gpx_points
46
+
47
+ def _synx_gpx_by_first_gps_timestamp(
48
+ self, gpx_points: T.Sequence[geo.Point]
49
+ ) -> float:
50
+ offset: float = 0.0
51
+
52
+ if not gpx_points:
53
+ return offset
54
+
35
55
  first_gpx_dt = datetime.datetime.fromtimestamp(
36
56
  gpx_points[0].time, tz=datetime.timezone.utc
37
57
  )
38
58
  LOG.info("First GPX timestamp: %s", first_gpx_dt)
39
59
 
40
60
  # Extract first GPS timestamp (if found) for synchronization
41
- offset: float = 0.0
42
- parser = GenericVideoParser(self.videoPath, self.options, self.parserOptions)
61
+ # Use an empty dictionary to force video parsers to extract make/model from the video metadata itself
62
+ parser = GenericVideoParser(self.videoPath, self.options, {})
43
63
  gps_points = parser.extract_points()
44
- if gps_points:
45
- first_gps_point = gps_points[0]
46
- if isinstance(first_gps_point, telemetry.GPSPoint):
47
- if first_gps_point.epoch_time is not None:
48
- first_gps_dt = datetime.datetime.fromtimestamp(
49
- first_gps_point.epoch_time, tz=datetime.timezone.utc
50
- )
51
- LOG.info("First GPS timestamp: %s", first_gps_dt)
52
- offset = gpx_points[0].time - first_gps_point.epoch_time
53
- if offset:
54
- LOG.warning(
55
- "Found offset between GPX %s and video GPS timestamps %s: %s seconds",
56
- first_gpx_dt,
57
- first_gps_dt,
58
- offset,
59
- )
60
64
 
61
- self._rebase_times(gpx_points, offset=offset)
65
+ if not gps_points:
66
+ LOG.warning(
67
+ "Skip GPX synchronization because no GPS found in video %s",
68
+ self.videoPath,
69
+ )
70
+ return offset
62
71
 
63
- return gpx_points
72
+ first_gps_point = gps_points[0]
73
+ if isinstance(first_gps_point, telemetry.GPSPoint):
74
+ if first_gps_point.epoch_time is not None:
75
+ first_gps_dt = datetime.datetime.fromtimestamp(
76
+ first_gps_point.epoch_time, tz=datetime.timezone.utc
77
+ )
78
+ LOG.info("First GPS timestamp: %s", first_gps_dt)
79
+ offset = gpx_points[0].time - first_gps_point.epoch_time
80
+ if offset:
81
+ LOG.warning(
82
+ "Found offset between GPX %s and video GPS timestamps %s: %s seconds",
83
+ first_gpx_dt,
84
+ first_gps_dt,
85
+ offset,
86
+ )
87
+ else:
88
+ LOG.info(
89
+ "GPX and GPS are perfectly synchronized (all starts from %s)",
90
+ first_gpx_dt,
91
+ )
92
+ else:
93
+ LOG.warning(
94
+ "Skip GPX synchronization because no GPS epoch time found in video %s",
95
+ self.videoPath,
96
+ )
97
+
98
+ return offset
64
99
 
65
100
  def extract_make(self) -> T.Optional[str]:
66
- parser = GenericVideoParser(self.videoPath, self.options, self.parserOptions)
101
+ # Use an empty dictionary to force video parsers to extract make/model from the video metadata itself
102
+ parser = GenericVideoParser(self.videoPath, self.options, {})
67
103
  return parser.extract_make()
68
104
 
69
105
  def extract_model(self) -> T.Optional[str]:
70
- parser = GenericVideoParser(self.videoPath, self.options, self.parserOptions)
106
+ # Use an empty dictionary to force video parsers to extract make/model from the video metadata itself
107
+ parser = GenericVideoParser(self.videoPath, self.options, {})
71
108
  return parser.extract_model()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mapillary_tools
3
- Version: 0.13.1a1
3
+ Version: 0.13.2
4
4
  Summary: Mapillary Image/Video Import Pipeline
5
5
  Home-page: https://github.com/mapillary/mapillary_tools
6
6
  Author: Mapillary
@@ -1,4 +1,4 @@
1
- mapillary_tools/__init__.py,sha256=Qvs9oGT6nkWrVfCfFMNlCwq4PM3sc2U_WryNkThbhUU,21
1
+ mapillary_tools/__init__.py,sha256=0qmTgs4HlmMGWxh_Upl_6EAbqBbUzX-Mw8rXWm5EO-U,19
2
2
  mapillary_tools/api_v4.py,sha256=zhRtgx3EnzgqtjziRhvFq3ONvsPaB9hROsuKFcf_pFo,5197
3
3
  mapillary_tools/authenticate.py,sha256=LCFcs6LqZmXaYkTUEKgGfmqytWdh5v_L3KXB48ojOZ4,3090
4
4
  mapillary_tools/config.py,sha256=jCjaK4jJaTY4AV4qf_b_tcxn5LA_uPsEWlGIdm2zw6g,2103
@@ -40,7 +40,7 @@ mapillary_tools/geotag/geotag_images_from_exif.py,sha256=hCgBwZABk2tbBQC3cHQBV5p
40
40
  mapillary_tools/geotag/geotag_images_from_exiftool.py,sha256=a-c4H8VIyPdJkfUIvJho0phR0QU0zN8-lSyiCz0wc4s,3981
41
41
  mapillary_tools/geotag/geotag_images_from_exiftool_both_image_and_video.py,sha256=nRVAjgTJwx_eCaSBpPCgcIaZs3EYgGueYxSS9XhKv40,3350
42
42
  mapillary_tools/geotag/geotag_images_from_gpx.py,sha256=S9Pw6FvP5kRSpHUnKUYKXmw0CHa9V92UmrS_MJfbjS4,9053
43
- mapillary_tools/geotag/geotag_images_from_gpx_file.py,sha256=zEbC0kVf_iw9ioIyJLL-gYN_QvAOEdAoEczCBkizl38,5122
43
+ mapillary_tools/geotag/geotag_images_from_gpx_file.py,sha256=-vTbZ1HufZzJCd8VvukdTjsJRcymtfld2W5t65VSG5E,5300
44
44
  mapillary_tools/geotag/geotag_images_from_nmea_file.py,sha256=dDdHnJInQ_WN3ZRf-w44NSBElDLPs7XYBiimvE2iCNo,1651
45
45
  mapillary_tools/geotag/geotag_images_from_video.py,sha256=XsaWOFChGItl-j1UbKM4hNjUqN29pVNbMpGT_BvI-o8,3306
46
46
  mapillary_tools/geotag/geotag_videos_from_exiftool_video.py,sha256=fkkWou1WFt3ft024399vis9No2cxrwot7Pg5HBw7o7s,5225
@@ -60,16 +60,16 @@ mapillary_tools/video_data_extraction/extract_video_data.py,sha256=_2BBdSYeYKR4B
60
60
  mapillary_tools/video_data_extraction/video_data_parser_factory.py,sha256=qaJHvLgwI5lukJncMd8ggxeSxXOiVzBSJO5GlGQYiXY,1134
61
61
  mapillary_tools/video_data_extraction/extractors/base_parser.py,sha256=s7Xuwg4I5JZ27oL4ebMSdo093plAXfZ-6uDQ_h97WHY,2134
62
62
  mapillary_tools/video_data_extraction/extractors/blackvue_parser.py,sha256=jAcGyF6PML2EdJ4zle8cR12QeTRZc5qxlz8_4gcTZPU,1089
63
- mapillary_tools/video_data_extraction/extractors/camm_parser.py,sha256=sr8oDbC9lGyHHp8qkpQBmWOf4U_umlokaJM0kPVKgzw,1314
63
+ mapillary_tools/video_data_extraction/extractors/camm_parser.py,sha256=YMiViocXSVlfn8_qm1jcwSJhnnEaK8v5ADHwo2YXe10,1117
64
64
  mapillary_tools/video_data_extraction/extractors/exiftool_runtime_parser.py,sha256=PFNCRk9pGrPIfVwLMcnzmVNMITVjNHhbrOOMwxaSstg,2270
65
65
  mapillary_tools/video_data_extraction/extractors/exiftool_xml_parser.py,sha256=Tt0h4TiCKocERWMlRXzlpoaA_WJ_4b20MgMLGYNl4AM,1734
66
66
  mapillary_tools/video_data_extraction/extractors/generic_video_parser.py,sha256=34O6Km5kNDoJNJtIUOwtAzzMntuqkSZJfeli7caWSkA,1693
67
67
  mapillary_tools/video_data_extraction/extractors/gopro_parser.py,sha256=IVnTyquSraTUaG9rxbJfVWc1-drdY5PaHn5urh3IBk4,1325
68
- mapillary_tools/video_data_extraction/extractors/gpx_parser.py,sha256=FRysFhN2aa0MGnzLO7pcZkwo8790GUelIZg9pddZvic,2594
68
+ mapillary_tools/video_data_extraction/extractors/gpx_parser.py,sha256=FNrdnXl48k8I1I5fGwYsClhfFEHVsooRLRboUYECv3I,3811
69
69
  mapillary_tools/video_data_extraction/extractors/nmea_parser.py,sha256=raSXavBvP-0LJCB_TwLL0mOv2uHSsB744igTsaKAaGc,658
70
- mapillary_tools-0.13.1a1.dist-info/LICENSE,sha256=l2D8cKfFmmJq_wcVq_JElPJrlvWQOzNWx7gMLINucxc,1292
71
- mapillary_tools-0.13.1a1.dist-info/METADATA,sha256=wc2o92Vqxo1fZ_sjWlV5lvJZByclruFL2h20jK0LxKI,19760
72
- mapillary_tools-0.13.1a1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
73
- mapillary_tools-0.13.1a1.dist-info/entry_points.txt,sha256=A3f3LP-BO_P-U8Y29QfpT4jx6Mjk3sXjTi2Yew4bvj8,75
74
- mapillary_tools-0.13.1a1.dist-info/top_level.txt,sha256=FbDkMgOrt1S70ho1WSBrOwzKOSkJFDwwqFOoY5-527s,16
75
- mapillary_tools-0.13.1a1.dist-info/RECORD,,
70
+ mapillary_tools-0.13.2.dist-info/LICENSE,sha256=l2D8cKfFmmJq_wcVq_JElPJrlvWQOzNWx7gMLINucxc,1292
71
+ mapillary_tools-0.13.2.dist-info/METADATA,sha256=2tmLjwx7V2QhrErmOK9uL1McwGYAaHqXDw-wTIS1N3w,19758
72
+ mapillary_tools-0.13.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
73
+ mapillary_tools-0.13.2.dist-info/entry_points.txt,sha256=A3f3LP-BO_P-U8Y29QfpT4jx6Mjk3sXjTi2Yew4bvj8,75
74
+ mapillary_tools-0.13.2.dist-info/top_level.txt,sha256=FbDkMgOrt1S70ho1WSBrOwzKOSkJFDwwqFOoY5-527s,16
75
+ mapillary_tools-0.13.2.dist-info/RECORD,,