File size: 2,117 Bytes
db613b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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())