From 21f0fd2068797633636ca6f4d1b74d8c1c66ad1b Mon Sep 17 00:00:00 2001 From: yoshiri Date: Thu, 25 Jan 2024 10:10:00 +0900 Subject: [PATCH] feat: enable to switch interpolation function and update comments Signed-off-by: yoshiri --- .../perception_eval/common/dataset.py | 3 ++- .../manager/_evaluation_manager_base.py | 21 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/perception_eval/perception_eval/common/dataset.py b/perception_eval/perception_eval/common/dataset.py index a46e7687..dcafa58b 100644 --- a/perception_eval/perception_eval/common/dataset.py +++ b/perception_eval/perception_eval/common/dataset.py @@ -301,6 +301,7 @@ def get_interpolated_now_frame( threshold_min_time: int, ) -> Optional[FrameGroundTruth]: """Get interpolated ground truth frame in specified unix time. + It searches before and after frames which satisfy the time difference condition and if found both, interpolate them. Args: ground_truth_frames (List[FrameGroundTruth]): FrameGroundTruth instance list. @@ -316,7 +317,7 @@ def get_interpolated_now_frame( Examples: >>> ground_truth_frames = load_all_datasets(...) - >>> get_now_frame(ground_truth_frames, 1624157578750212, 7500) + >>> get_interpolated_now_frame(ground_truth_frames, 1624157578750212, 7500) """ # extract closest two frames diff --git a/perception_eval/perception_eval/manager/_evaluation_manager_base.py b/perception_eval/perception_eval/manager/_evaluation_manager_base.py index 9f1c035c..39cffe9d 100644 --- a/perception_eval/perception_eval/manager/_evaluation_manager_base.py +++ b/perception_eval/perception_eval/manager/_evaluation_manager_base.py @@ -92,6 +92,7 @@ def get_ground_truth_now_frame( self, unix_time: int, threshold_min_time: int = 75000, + interpolate_ground_truth: bool = True, ) -> Optional[FrameGroundTruth]: """Returns a FrameGroundTruth instance that has the closest timestamp with `unix_time`. @@ -105,12 +106,20 @@ def get_ground_truth_now_frame( Optional[FrameGroundTruth]: FrameGroundTruth instance at current frame. If there is no corresponding ground truth, returns None. """ - ground_truth_now_frame: FrameGroundTruth = get_interpolated_now_frame( - ground_truth_frames=self.ground_truth_frames, - unix_time=unix_time, - threshold_min_time=threshold_min_time, - ) - return ground_truth_now_frame + if not interpolate_ground_truth: + ground_truth_now_frame: FrameGroundTruth = get_now_frame( + ground_truth_frames=self.ground_truth_frames, + unix_time=unix_time, + threshold_min_time=threshold_min_time, + ) + return ground_truth_now_frame + else: + ground_truth_now_frame: FrameGroundTruth = get_interpolated_now_frame( + ground_truth_frames=self.ground_truth_frames, + unix_time=unix_time, + threshold_min_time=threshold_min_time, + ) + return ground_truth_now_frame def visualize_all(self) -> None: """Visualize object result in BEV space for all frames."""