Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions mapillary_tools/blackvue_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,6 @@ def extract_blackvue_info(fp: T.BinaryIO) -> BlackVueInfo | None:
return BlackVueInfo(model=model, gps=points)


def extract_camera_model(fp: T.BinaryIO) -> str:
try:
cprt_bytes = sparser.parse_mp4_data_first(fp, [b"free", b"cprt"])
except sparser.ParsingError:
return ""

if cprt_bytes is None:
return ""

return _extract_camera_model_from_cprt(cprt_bytes)


def _extract_camera_model_from_cprt(cprt_bytes: bytes) -> str:
"""
>>> _extract_camera_model_from_cprt(b' {"model":"DR900X Plus","ver":0.918,"lang":"English","direct":1,"psn":"","temp":34,"GPS":1}')
Expand Down
11 changes: 0 additions & 11 deletions mapillary_tools/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,22 +279,11 @@ def extract_specified_frames(
*["-filter_script:v", select_file.name],
# Each frame is passed with its timestamp from the demuxer to the muxer
*["-vsync", "0"],
# vsync is deprecated by fps_mode,
# but fps_mode is not avaliable on some older versions ;(
# *[f"-fps_mode:{stream_specifier}", "passthrough"],
# Set the number of video frames to output (this is an optimization to let ffmpeg stop early)
*["-frames:v", str(len(frame_indices))],
# Disabled because it doesn't always name the sample images as expected
# For example "select(n\,1)" we expected the first sample to be IMG_001.JPG
# but it could be IMG_005.JPG
# https://www.ffmpeg.org/ffmpeg-formats.html#Options-21
# If set to 1, expand the filename with pts from pkt->pts. Default value is 0.
# *["-frame_pts", "1"],
],
# Video quality level (or the alias -q:v)
# -q:v=1 is the best quality but larger image sizes
# see https://stackoverflow.com/a/10234065
# *["-qscale:v", "1", "-qmin", "1"],
*["-qscale:v", "2"],
# output
output_template,
Expand Down
16 changes: 0 additions & 16 deletions mapillary_tools/gpmf/gpmf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,6 @@ def extract_gopro_info(
return None


def extract_camera_model(fp: T.BinaryIO) -> str:
moov = MovieBoxParser.parse_stream(fp)
for track in moov.extract_tracks():
if _contains_gpmd_description(track):
gpmd_samples = _filter_gpmd_samples(track)
dvnm_by_dvid: dict[int, bytes] = {}
device_found = _load_telemetry_from_samples(
fp, gpmd_samples, dvnm_by_dvid=dvnm_by_dvid
)
if not device_found:
return ""
return _extract_camera_model_from_devices(dvnm_by_dvid)

return ""


def _gps5_timestamp_to_epoch_time(dtstr: str):
# yymmddhhmmss.sss
dt = datetime.datetime.strptime(dtstr, "%y%m%d%H%M%S.%f").replace(
Expand Down
4 changes: 1 addition & 3 deletions mapillary_tools/serializer/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ class ErrorDescription(TypedDict, total=False):
"description": "Arbitrary key for grouping images",
"pattern": "[a-zA-Z0-9_-]+",
},
# deprecated since v0.10.0; keep here for compatibility
"MAPMetaTags": {"type": "object"},
"MAPDeviceMake": {"type": "string"},
"MAPDeviceModel": {"type": "string"},
"MAPGPSAccuracyMeters": {"type": "number"},
Expand Down Expand Up @@ -439,7 +437,7 @@ def _as_image_desc(cls, metadata: ImageMetadata) -> ImageDescription:
value = getattr(metadata, field.name)
if value is not None:
# ignore error: TypedDict key must be a string literal;
# expected one of ("MAPMetaTags", "MAPDeviceMake", "MAPDeviceModel", "MAPGPSAccuracyMeters", "MAPCameraUUID", ...)
# expected one of ("MAPDeviceMake", "MAPDeviceModel", "MAPGPSAccuracyMeters", "MAPCameraUUID", ...)
desc[field.name] = value # type: ignore
return desc

Expand Down
1 change: 0 additions & 1 deletion mapillary_tools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class ImageMetadata(geo.Point):
MAPGPSAccuracyMeters: float | None = None
MAPCameraUUID: str | None = None
MAPOrientation: int | None = None
MAPMetaTags: dict | None = None
MAPFilename: str | None = None

def update_md5sum(self, image_data: T.BinaryIO | None = None) -> None:
Expand Down
20 changes: 6 additions & 14 deletions mapillary_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,12 @@ def configure_logger(

logger.setLevel(level)

try:
# Disable globally for now. TODO Disable it in non-interactive mode only
raise ImportError
from rich.console import Console # type: ignore[import]
from rich.logging import RichHandler # type: ignore[import]
except ImportError:
formatter = logging.Formatter(
"%(asctime)s.%(msecs)03d - %(levelname)-7s - %(message)s",
datefmt="%H:%M:%S",
)
handler: logging.Handler = logging.StreamHandler()
handler.setFormatter(formatter)
else:
handler = RichHandler(console=Console(stderr=True), rich_tracebacks=True) # type: ignore
formatter = logging.Formatter(
"%(asctime)s.%(msecs)03d - %(levelname)-7s - %(message)s",
datefmt="%H:%M:%S",
)
handler: logging.Handler = logging.StreamHandler()
handler.setFormatter(formatter)

logger.addHandler(handler)

Expand Down
3 changes: 0 additions & 3 deletions schema/image_description_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@
"description": "Arbitrary key for grouping images",
"pattern": "[a-zA-Z0-9_-]+"
},
"MAPMetaTags": {
"type": "object"
},
"MAPDeviceMake": {
"type": "string"
},
Expand Down
3 changes: 2 additions & 1 deletion tests/cli/blackvue_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def _convert_to_track(path: pathlib.Path):
segment = _convert_points_to_gpx_segment(blackvue_info.gps or [])
track.segments.append(segment)
with path.open("rb") as fp:
model = blackvue_parser.extract_camera_model(fp)
blackvue_info = blackvue_parser.extract_blackvue_info(fp)
model = blackvue_info.model if blackvue_info else ""
track.description = f"Extracted from {model}"

return track
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def test_desc():
alt=3,
angle=4,
time=5,
MAPMetaTags={"foo": "bar", "baz": 1.2},
MAPSequenceUUID="MAPSequenceUUID",
MAPDeviceMake="MAPDeviceMake",
MAPDeviceModel="MAPDeviceModel",
Expand All @@ -40,7 +39,6 @@ def test_desc():
alt=3,
angle=4,
time=5,
MAPMetaTags={"foo": "bar", "baz": 1.2},
MAPOrientation=1,
),
]
Expand Down