Skip to content

Commit

Permalink
some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpt committed Jun 12, 2023
1 parent 5bcbc9b commit 29dbe31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mapillary_tools/geotag/geotag_images_from_exiftool.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def to_description(self) -> T.List[types.ImageMetadataOrError]:
image_metadata_or_errors = list(
tqdm(
image_metadatas_iter,
desc="Extracting geotags from images",
desc="Extracting geotags from ExifTool XML",
unit="images",
disable=LOG.getEffectiveLevel() <= logging.DEBUG,
total=len(self.image_paths),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from .. import types, utils
from . import (
geotag_videos_from_exiftool_video,
geotag_images_from_exiftool,
geotag_images_from_video,
geotag_videos_from_exiftool_video,
)
from .geotag_from_generic import GeotagImagesFromGeneric
from .geotag_images_from_gpx import GeotagImagesFromGPXWithProgress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def to_description(self) -> T.List[types.VideoMetadataOrError]:
video_metadata_or_errors = list(
tqdm(
video_metadatas_iter,
desc="Extracting GPS tracks from videos",
desc="Extracting GPS tracks from ExifTool XML",
unit="videos",
disable=LOG.getEffectiveLevel() <= logging.DEBUG,
total=len(self.video_paths),
Expand Down
1 change: 0 additions & 1 deletion mapillary_tools/process_geotag_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
geotag_from_generic,
geotag_images_from_exif,
geotag_images_from_exiftool_both_image_and_video,
geotag_images_from_exiftool,
geotag_images_from_gpx_file,
geotag_images_from_nmea_file,
geotag_images_from_video,
Expand Down
19 changes: 15 additions & 4 deletions mapillary_tools/sample_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ def sample_video(

if rerun:
for video_path in video_list:
# need to resolve video_path because video_dir might be absolute
# Example:
# - import_path: mapillary_sampled_video_frames
# - video_dir: foo/
# - video_path: foo/bar/zzz.mp4
# Then:
# - sample_dir: mapillary_sampled_video_frames/bar/zzz.mp4/
sample_dir = Path(import_path).joinpath(
video_path.resolve().relative_to(video_dir)
)
Expand All @@ -84,7 +89,7 @@ def sample_video(
geotag_source = "exif"

# If it is not exif, then we use the legacy interval-based sample and geotag them in "process" for backward compatibility
if geotag_source != "exif":
if geotag_source not in ["exif"]:
if 0 <= video_sample_distance:
raise exceptions.MapillaryBadParameterError(
f'Geotagging from "{geotag_source}" works with the legacy interval-based sampling only. To switch back, rerun the command with "--video_sample_distance -1 --video_sample_interval 2"'
Expand Down Expand Up @@ -126,9 +131,15 @@ def sample_video(
# fatal error
raise exceptions.MapillaryFFmpegNotFoundError(str(ex)) from ex

except Exception:
except Exception as ex:
if skip_sample_errors:
LOG.warning("Skipping the error sampling %s", video_path, exc_info=True)
exc_info = LOG.getEffectiveLevel() <= logging.DEBUG
LOG.warning(
"Skipping the error sampling %s: %s",
video_path,
str(ex),
exc_info=exc_info,
)
else:
raise

Expand Down

0 comments on commit 29dbe31

Please sign in to comment.