Skip to content

Commit

Permalink
feat: enable to switch interpolation function and update comments
Browse files Browse the repository at this point in the history
Signed-off-by: yoshiri <[email protected]>
  • Loading branch information
YoshiRi committed Jan 25, 2024
1 parent 3f8dbec commit 21f0fd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion perception_eval/perception_eval/common/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
<perception_eval.common.dataset.FrameGroundTruth object at 0x7f66040c36a0>
"""
# extract closest two frames
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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."""
Expand Down

0 comments on commit 21f0fd2

Please sign in to comment.