Skip to content

Commit

Permalink
feat(PerceptionVisualizer): add support of prediction visualization
Browse files Browse the repository at this point in the history
Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 committed Jan 27, 2023
1 parent 82281e1 commit cfd51cb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ def __init__(
self.confidence_threshold_list: Optional[List[float]] = confidence_threshold_list
self.target_uuids: Optional[List[str]] = target_uuids

if max_x_position_list is None:
self.xlim: float = max(max_distance_list)
self.ylim: float = max(max_distance_list)
elif max_distance_list is None:
if max_x_position_list is not None:
self.xlim: float = max(max_x_position_list)
self.ylim: float = max(max_y_position_list)
elif max_distance_list is not None:
self.xlim: float = max(max_distance_list)
self.ylim: float = max(max_distance_list)
else:
self.xlim: float = 100.0
self.ylim: float = 100.0
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,20 @@ def plot_objects(
# tracked path
if self.config.evaluation_task == EvaluationTask.TRACKING:
axes, tracking_artists = self._plot_tracked_path(
object_, is_ground_truth, axes=axes
object_,
is_ground_truth,
axes=axes,
)
artists += tracking_artists

# predicted path
if self.config.evaluation_task == EvaluationTask.PREDICTION:
pass
axes, prediction_artists = self._plot_predicted_path(
object_,
is_ground_truth,
axes=axes,
)
artists += prediction_artists

box_center_x.append(box_center[0])
box_center_y.append(box_center[1])
Expand Down Expand Up @@ -501,22 +508,36 @@ def _plot_tracked_path(

def _plot_predicted_path(
self,
dynamic_objects: List[DynamicObject],
dynamic_object: DynamicObject,
is_ground_truth: bool,
axes: Optional[Axes] = None,
) -> Axes:
"""[summary]
Plot predicted paths for one object.
Args:
dynamic_objects (List[DynamicObject]): The list of object being visualized.
dynamic_object (DynamicObject): The list of object being visualized.
is_ground_truth (bool): Whether ground truth object is.
axes (Axes): The Axes instance.
Returns:
axes (Axes): The Axes instance.
artists (List[plt.Artist]): The list of Artist instance.
"""
pass
if axes is None:
axes: Axes = plt.subplot()

artists: List[plt.Artist] = []

for i, paths in enumerate(dynamic_object.predicted_paths):
path_arr: np.ndarray = np.array([p.position for p in paths])
color_: np.ndarray = (
self.__cmap.get_simple("red") if is_ground_truth else self.__cmap[i] / 255.0
)
plot_ = axes.plot(path_arr[:, 0], path_arr[:, 1], "o--", color=color_, markersize=1)
artists.append(plot_)

return axes, artists

def _save_animation(self, file_name: Optional[str] = None):
"""[summary]
Expand Down
11 changes: 3 additions & 8 deletions perception_eval/test/perception_lsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,9 @@ def visualize(self, frame_result: PerceptionFrameResult):
f"{format_class_for_log(prediction_final_metric_score.prediction_scores[0], 100)}"
)

# # Visualize all frame results
# logging.info("Start visualizing prediction results")
# prediction_lsim.evaluator.visualize_all()

# # Prediction performance report
# prediction_analyzer = PerceptionPerformanceAnalyzer(prediction_lsim.evaluator.evaluator_config)
# prediction_analyzer.add(prediction_lsim.evaluator.frame_results)
# score_df, error_df = prediction_analyzer.analyze()
# Visualize all frame results
logging.info("Start visualizing prediction results")
prediction_lsim.evaluator.visualize_all()

# Clean up tmpdir
if args.use_tmpdir:
Expand Down

0 comments on commit cfd51cb

Please sign in to comment.