#!/usr/bin/env python3 from __future__ import annotations import argparse from pathlib import Path from urllib.request import urlretrieve from tqdm import tqdm BASE_URL = "https://fenix.ur.edu.pl/~mkepski/ds/data" def download(url: str, destination: Path) -> None: destination.parent.mkdir(parents=True, exist_ok=True) if destination.exists() and destination.stat().st_size > 0: return temporary = destination.with_suffix(destination.suffix + ".part") urlretrieve(url, temporary) temporary.replace(destination) def main() -> None: parser = argparse.ArgumentParser(description="Download official URFD RGB videos") parser.add_argument("--output", type=Path, default=Path("data/videos")) args = parser.parse_args() items: list[tuple[str, Path]] = [] for index in range(1, 31): name = f"fall-{index:02d}-cam0.mp4" items.append((f"{BASE_URL}/{name}", args.output / "fall" / f"fall-{index:02d}" / name)) for index in range(1, 41): name = f"adl-{index:02d}-cam0.mp4" items.append((f"{BASE_URL}/{name}", args.output / "normal" / f"adl-{index:02d}" / name)) items.extend( [ ( f"{BASE_URL}/urfall-cam0-falls.csv", args.output / "annotations" / "urfall-cam0-falls.csv", ), ( f"{BASE_URL}/urfall-cam0-adls.csv", args.output / "annotations" / "urfall-cam0-adls.csv", ), ] ) for url, destination in tqdm(items, desc="Downloading URFD"): download(url, destination) print(f"Downloaded/verified {len(items)} files in {args.output}") print("License: CC BY-NC-SA 4.0, academic non-commercial use.") if __name__ == "__main__": main()