11from __future__ import annotations
22
3- from typing import TYPE_CHECKING
3+ from typing import TYPE_CHECKING , TypeVar
44
55from attrs import define
66
77from t4_devkit import Tier4
8- from t4_devkit .dataclass import HomogeneousMatrix , TransformBuffer
8+ from t4_devkit .dataclass import BoxLike , HomogeneousMatrix , SegmentationPointCloud , TransformBuffer
9+ from t4_devkit .typing import NDArrayU8
910
1011from .task import EvaluationTask
1112
1213if TYPE_CHECKING :
13- from t4_devkit .dataclass import BoxLike
1414 from t4_devkit .schema import EgoPose , Sensor
1515
1616
17+ EvaluationObjectLike = TypeVar (
18+ "EvaluationObjectLike" ,
19+ list [BoxLike ], # boxes
20+ SegmentationPointCloud , # pointcloud
21+ NDArrayU8 , # mask
22+ )
23+
24+
1725__all__ = ["load_dataset" , "FrameGroundTruth" , "SceneGroundTruth" ]
1826
1927
@@ -31,12 +39,16 @@ def load_dataset(data_root: str, task: EvaluationTask) -> SceneGroundTruth:
3139
3240 frames : list [FrameGroundTruth ] = []
3341 for i , sample in enumerate (t4 .sample ):
34- # annotation boxes
35- boxes = (
36- list (map (t4 .get_box3d , sample .ann_3ds ))
37- if task .is_3d ()
38- else list (map (t4 .get_box2d , sample .ann_2ds ))
39- )
42+ # annotations
43+ if task .is_segmentation ():
44+ # TODO(ktro2828): add support of segmentation object
45+ raise NotImplementedError ("Segmentation task is under construction." )
46+ else :
47+ annotations = (
48+ list (map (t4 .get_box3d , sample .ann_3ds ))
49+ if task .is_3d ()
50+ else list (map (t4 .get_box2d , sample .ann_2ds ))
51+ )
4052
4153 # transformation matrix from ego to map
4254 ego_pose = _closest_ego_pose (t4 , sample .timestamp )
@@ -51,7 +63,7 @@ def load_dataset(data_root: str, task: EvaluationTask) -> SceneGroundTruth:
5163 FrameGroundTruth (
5264 unix_time = sample .timestamp ,
5365 frame_index = i ,
54- boxes = boxes ,
66+ annotations = annotations ,
5567 ego2map = ego2map ,
5668 )
5769 )
@@ -84,13 +96,13 @@ class FrameGroundTruth:
8496 Attributes:
8597 unix_time (int): Unix timestamp.
8698 frame_index (int): Index number of the frame.
87- boxes (list[BoxLike] ): List of ground truth instances.
99+ annotations (EvaluationObjectLike ): Set of ground truth instances.
88100 ego2map (HomogeneousMatrix): Transformation matrix from ego to map coordinate.
89101 """
90102
91103 unix_time : int
92104 frame_index : int
93- boxes : list [ BoxLike ]
105+ annotations : EvaluationObjectLike
94106 ego2map : HomogeneousMatrix
95107
96108
0 commit comments