-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add CLI tool for visualization
Signed-off-by: ktro2828 <[email protected]>
- Loading branch information
Showing
6 changed files
with
177 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Command Line Tools for T4 Dataset | ||
|
||
Following command line tools are supported: | ||
|
||
- `t4viz`: Visualize T4 dataset features. | ||
|
||
## `t4viz` | ||
|
||
### Visualize a Scene | ||
|
||
```shell | ||
# [...] is optional arguments | ||
t4viz scene <DATA_ROOT> [-o <OUTPUT_DIR> --no-show] | ||
``` | ||
|
||
Arguments | ||
|
||
- `<DATA_ROOT>`: Root directory path to T4 dataset. | ||
- `-o <OUTPUT_DIR>`: Directory path to save recording `.rrd` file. | ||
- `--no-show`: Indicates whether not to show viewer. | ||
|
||
### Visualize a Specific Instance | ||
|
||
```shell | ||
# [...] is optional arguments | ||
t4viz instance <DATA_ROOT> <INSTANCE_TOKEN> [-o <OUTPUT_DIR> --no-show] | ||
``` | ||
|
||
Arguments | ||
|
||
- `<DATA_ROOT>`: Root directory path to T4 dataset. | ||
- `<INSTANCE_TOKEN>`: Unique identifier token of an instance record. | ||
- `-o <OUTPUT_DIR>`: Directory path to save recording `.rrd` file. | ||
- `--no-show`: Indicates whether not to show viewer. | ||
|
||
### Visualize PointCloud | ||
|
||
```shell | ||
# [...] is optional arguments | ||
t4viz pointcloud <DATA_ROOT> [--distortion -o <OUTPUT_DIR> --no-show] | ||
``` | ||
|
||
- `<DATA_ROOT>`: Root directory path to T4 dataset. | ||
- `<INSTANCE_TOKEN>`: Unique identifier token of an instance record. | ||
- `--distortion`: Indicates whether not to ignore camera distortion. | ||
- `-o <OUTPUT_DIR>`: Directory path to save recording `.rrd` file. | ||
- `--no-show`: Indicates whether not to show viewer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def main(): | ||
print("Hello from t4cli!") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[project] | ||
name = "t4-devkit-cli" | ||
version = "0.1.0" | ||
description = "Command line tools for T4 dataset using t4-devkit." | ||
readme = "README.md" | ||
requires-python = ">=3.10, <3.13" | ||
dependencies = ["click>=8.1.8"] | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[tool.ruff] | ||
line-length = 100 | ||
|
||
[tool.ruff.lint.isort] | ||
required-imports = ["from __future__ import annotations"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from __future__ import annotations | ||
|
||
import click | ||
|
||
from t4_devkit import Tier4 | ||
|
||
from .common import create_dir | ||
|
||
|
||
@click.group(invoke_without_command=True) | ||
@click.pass_context | ||
def main(ctx: click.Context) -> None: | ||
if ctx.invoked_subcommand is None: | ||
print(ctx.get_help()) | ||
else: | ||
ctx.invoked_subcommand | ||
|
||
|
||
@main.command(name="scene", help="Visualize a specific scene.") | ||
@click.argument("data_root", type=click.Path(exists=True)) | ||
@click.option( | ||
"-o", | ||
"--output", | ||
type=click.Path(writable=True), | ||
help="Output directory to save recoding .rrd file.", | ||
) | ||
@click.option("--no-show", is_flag=True, help="Indicates whether not to show viewer.") | ||
def scene(data_root: str, output: str | None, no_show: bool) -> None: | ||
create_dir(output) | ||
|
||
t4 = Tier4("annotation", data_root, verbose=False) | ||
scene_token = t4.scene[0].token | ||
t4.render_scene(scene_token, save_dir=output, show=not no_show) | ||
|
||
|
||
@main.command(name="instance", help="Visualize a particular instance in a corresponding scene") | ||
@click.argument("data_root", type=click.Path(exists=True)) | ||
@click.argument("instance", type=click.STRING) | ||
@click.option( | ||
"-o", | ||
"--output", | ||
type=click.Path(writable=True), | ||
help="Output directory to save recoding .rrd file.", | ||
) | ||
@click.option("--no-show", is_flag=True, help="Indicates whether not to show viewer.") | ||
def instance(data_root: str, instance: str, output: str | None, no_show: bool) -> None: | ||
create_dir(output) | ||
|
||
t4 = Tier4("annotation", data_root, verbose=False) | ||
t4.render_instance(instance_token=instance, save_dir=output, show=not no_show) | ||
|
||
|
||
@main.command(name="pointcloud", help="Visualize pointcloud in a corresponding scene.") | ||
@click.argument("data_root", type=click.Path(exists=True)) | ||
@click.option( | ||
"--distortion", | ||
is_flag=True, | ||
help="Indicates whether not to ignore camera distortion.", | ||
) | ||
@click.option( | ||
"-o", | ||
"--output", | ||
type=click.Path(writable=True), | ||
help="Output directory to save recoding .rrd file.", | ||
) | ||
@click.option("--no-show", is_flag=True, help="Indicates whether not to show viewer.") | ||
def pointcloud(data_root: str, distortion: bool, output: str | None, no_show: bool) -> None: | ||
create_dir(output) | ||
|
||
t4 = Tier4("annotation", data_root, verbose=False) | ||
scene_token = t4.scene[0].token | ||
t4.render_pointcloud( | ||
scene_token, | ||
ignore_distortion=not distortion, | ||
save_dir=output, | ||
show=not no_show, | ||
) |