KITTI-C2L-Dataset / code /scripts /check_sequence_mapping.py
mcocheteux's picture
Release KITTI-C2L v1.0.0: documented self-contained benchmark, loader and baselines
db613b6 verified
Raw History Blame Contribute Delete
2.12 kB
#!/usr/bin/env python
"""Cross-checks configs/sequence_mapping.yaml against local raw drive frame counts.
For every sequence whose raw drive is present locally, compares the
mapping's `frame_count` (the odometry-benchmark sub-range) against the
number of image_02 files actually on disk for that drive (which may be
larger, since a raw drive can extend beyond the packaged sub-range -- see
sequence_mapping.yaml's header comment). Sequences whose raw drive isn't
present locally are reported as "not available" rather than failing.
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
from kitti_c2l.sequence_mapping import load_sequence_mapping # noqa: E402
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--kitti-raw-root", required=True, help="Root directory containing <date>/<date>_drive_*_sync/")
args = parser.parse_args()
root = Path(args.kitti_raw_root)
mapping = load_sequence_mapping()
all_ok = True
for seq_id, seq_info in mapping.items():
if not seq_info.available:
print(f"seq {seq_id}: SKIPPED -- raw drive not publicly available upstream (not a local-download issue)")
continue
drive_dir = root / seq_info.date / seq_info.drive_name
image_dir = drive_dir / "image_02" / "data"
if not image_dir.is_dir():
print(f"seq {seq_id}: NOT DOWNLOADED locally yet ({drive_dir})")
all_ok = False
continue
num_images = len(list(image_dir.glob("*.png")))
required_last_frame = seq_info.end # 0-based raw frame index
status = "OK" if num_images > required_last_frame else "INSUFFICIENT FRAMES"
if status != "OK":
all_ok = False
print(
f"seq {seq_id}: {seq_info.drive_name} -- {num_images} raw frames on disk, "
f"need up to raw frame {required_last_frame} (0-based) -- {status}"
)
return 0 if all_ok else 1
if __name__ == "__main__":
sys.exit(main())