File size: 1,769 Bytes
9313a90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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()