-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvisualize.py
More file actions
128 lines (108 loc) · 3.14 KB
/
Copy pathvisualize.py
File metadata and controls
128 lines (108 loc) · 3.14 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from __future__ import annotations
import os
from typing import Annotated
import typer
from t4_devkit import Tier4
from .version import version_callback
cli = typer.Typer(
name="t4viz",
no_args_is_help=True,
context_settings={"help_option_names": ["-h", "--help"]},
pretty_exceptions_enable=False,
)
@cli.command("scene", help="Visualize a specific scene.")
def scene(
data_root: Annotated[str, typer.Argument(help="Root directory path to the dataset.")],
future: Annotated[
float,
typer.Option(
...,
"-f",
"--future",
help="Future time seconds.",
),
] = 0.0,
output: Annotated[
str | None,
typer.Option(
...,
"-o",
"--output",
help="Output directory to save recorded .rrd file.",
),
] = None,
) -> None:
_create_dir(output)
t4 = Tier4(data_root, verbose=False)
t4.render_scene(future_seconds=future, save_dir=output)
@cli.command("instance", help="Visualize a particular instance in the corresponding scene.")
def instance(
data_root: Annotated[str, typer.Argument(help="Root directory path to the dataset.")],
instance: Annotated[list[str], typer.Argument(help="Instance token(s).")],
future: Annotated[
float,
typer.Option(
...,
"-f",
"--future",
help="Future time seconds.",
),
] = 0.0,
output: Annotated[
str | None,
typer.Option(
...,
"-o",
"--output",
help="Output directory to save recorded .rrd file.",
),
] = None,
) -> None:
_create_dir(output)
t4 = Tier4(data_root, verbose=False)
t4.render_instance(instance_token=instance, future_seconds=future, save_dir=output)
@cli.command("pointcloud", help="Visualize pointcloud in the corresponding scene.")
def pointcloud(
data_root: Annotated[str, typer.Argument(help="Root directory path to the dataset.")],
ignore_distortion: Annotated[
bool,
typer.Option(
...,
"-ig",
"--ignore-distortion",
help="Indicates whether to ignore camera distortion",
),
] = True,
output: Annotated[
str | None,
typer.Option(
...,
"-o",
"--output",
help="Output directory to save recorded .rrd file.",
),
] = None,
) -> None:
_create_dir(output)
t4 = Tier4(data_root, verbose=False)
t4.render_pointcloud(ignore_distortion=ignore_distortion, save_dir=output)
def _create_dir(dir_path: str | None) -> None:
"""Create a directory with the specified path.
If the input path is `None` this function does nothing.
Args:
dir_path (str | None): Directory path to create.
"""
if dir_path is not None:
os.makedirs(dir_path, exist_ok=True)
@cli.callback()
def main(
version: bool = typer.Option(
False,
"--version",
"-v",
help="Show the application version and exit.",
callback=version_callback,
is_eager=True,
),
) -> None:
pass