TIER IV API
DBMetadata
Tier4
Database class for T4 dataset to help query and retrieve information from the database.
Load database and creates reverse indexes and shortcuts.
Parameters:
-
(data_rootstr) –Path to the root directory of dataset.
-
(revisionstr | None, default:None) –You can specify any specific version if you want. If None, search the latest one.
-
(verbosebool, default:True) –Whether to display status during load.
Examples:
>>> from t4_devkit import Tier4
>>> t4 = Tier4("data/tier4")
======
Loading T4 tables in `annotation`...
Reverse indexing...
Done reverse indexing in 0.010 seconds.
======
21 category
8 attribute
4 visibility
31 instance
7 sensor
7 calibrated_sensor
2529 ego_pose
1 log
1 scene
88 sample
2529 sample_data
1919 sample_annotation
0 object_ann
0 surface_ann
0 keypoint
1 map
Done loading in 0.046 seconds.
======
get_table
Return the list of dataclasses corresponding to the schema table.
Parameters:
-
(schemastr | SchemaName) –Name of schema table.
Returns:
-
list[SchemaTable]–List of dataclasses.
get
Return a record identified by the associated token.
Parameters:
-
(schemastr | SchemaName) –Name of schema.
-
(tokenstr) –Token to identify the specific record.
Returns:
-
SchemaTable–Table record of the corresponding token.
get_idx
Return the index of the record in a table in constant runtime.
Parameters:
-
(schemastr | SchemaName) –Name of schema.
-
(tokenstr) –Token of record.
Returns:
-
int–The index of the record in table.
get_sample_data_path
get_sample_data
get_sample_data(
sample_data_token: str,
*,
selected_ann_tokens: list[str] | None = None,
as_3d: bool = True,
as_sensor_coord: bool = True,
future_seconds: float = 0.0,
visibility: VisibilityLevel = VisibilityLevel.NONE,
) -> tuple[str, list[BoxLike], CamIntrinsicLike | None]
Return the data path as well as all annotations related to that sample_data.
Note that output boxes is w.r.t base link or sensor coordinate system.
Parameters:
-
(sample_data_tokenstr) –Token of
sample_data. -
(selected_ann_tokenslist[str] | None, default:None) –Specify if you want to extract only particular annotations.
-
(as_3dbool, default:True) –Whether to return 3D or 2D boxes.
-
(as_sensor_coordbool, default:True) –Whether to transform boxes as sensor origin coordinate system.
-
(visibilityVisibilityLevel, default:NONE) –If
sample_datais an image, this sets required visibility for only 3D boxes.
Returns:
get_semantic_label
get_semantic_label(
category_token: str,
attribute_tokens: list[str] | None = None,
) -> SemanticLabel
Return a SemanticLabel instance from specified category_token and attribute_tokens.
Parameters:
-
(category_tokenstr) –Token of
Categorytable. -
(attribute_tokenslist[str] | None, default:None) –List of attribute tokens.
Returns:
-
SemanticLabel–Instantiated SemanticLabel.
get_box3d
get_box2d
get_box3ds
Rerun a list of Box3D classes for all annotations of a particular sample_data record.
It the sample_data is a keyframe, this returns annotations for the corresponding sample.
Parameters:
-
(sample_data_tokenstr) –Token of
sample_data. -
(future_secondsfloat, default:0.0) –Future time in [s].
Returns:
get_box2ds
box_velocity
Return the velocity of an annotation. If corresponding annotation has a true velocity, this returns it. Otherwise, this estimates the velocity by computing the difference between the previous and next frame. If it is failed to estimate the velocity, values are set to np.nan.
Parameters:
-
(sample_annotation_tokenstr) –Token of
sample_annotation. -
(max_time_difffloat, default:1.5) –Max allowed time difference between consecutive samples.
Returns:
-
Vector3(Vector3) –Velocity in the order of (vx, vy, vz) in m/s.
TODO
Currently, velocity coordinates is with respect to map, but if should be each box.
render_scene
render_instance
render_pointcloud
render_pointcloud(
*,
max_time_seconds: float = np.inf,
ignore_distortion: bool = True,
save_dir: str | None = None,
) -> None
Render pointcloud on 3D and 2D view.
Parameters:
-
(max_time_secondsfloat, default:inf) –Max time length to be rendered [s].
-
(save_dirstr | None, default:None) –Directory path to save the recording.
-
(ignore_distortionbool, default:True) –Whether to ignore distortion parameters.
TODO
Add an option of rendering radar channels.
load_metadata
Load metadata of T4 dataset including root directory path, dataset ID, and version.
Parameters:
-
(db_rootstr) –Path to root directory of database.
-
(revisionstr | None, default:None) –Specify version of the dataset. If None, search the latest one.
Returns:
-
DBMetadata–Metadata of T4 dataset.
load_table
Load schema table from a JSON file.
If the schema is optional and there is no corresponding JSON file in dataset, returns empty list.
Parameters:
-
(annotation_dirstr) –Path to the directory of JSON annotation schema files.
-
(schemaSchemaName) –An enum member of
SchemaName.
Returns:
-
list[SchemaTable]–Loaded table data saved in
.json.