Skip to content

Commit

Permalink
Plot image with visualize
Browse files Browse the repository at this point in the history
  • Loading branch information
brukew committed Jan 18, 2025
1 parent 9e2c82e commit 294739c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/senselab/video/tasks/pose_estimation/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from typing import Any, Optional

import cv2
import matplotlib.pyplot as plt
import numpy as np

from senselab.video.data_structures.pose import ImagePose
Expand Down Expand Up @@ -61,7 +63,7 @@ def estimate_pose(image_path: str, model: str, **kwargs: Any) -> ImagePose: # n


def visualize_pose(pose_image: ImagePose, output_path: Optional[str] = None) -> np.ndarray:
"""Visualize pose estimation results.
"""Visualize pose estimation results and optionally save the image.
Args:
pose_image (ImagePose): The pose estimation result.
Expand All @@ -70,4 +72,16 @@ def visualize_pose(pose_image: ImagePose, output_path: Optional[str] = None) ->
Returns:
np.ndarray: Annotated image.
"""
return visualize(pose_image, output_path=output_path)
annotated_image = visualize(pose_image, output_path=output_path)

plt.imshow(cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.show()

return annotated_image


if __name__ == "__main__":
image_path = "src/tests/data_for_testing/pose_data/single_person.jpg"
pose_image = estimate_pose(image_path, model="mediapipe", model_type="lite", num_individuals=1)
visualize_pose(pose_image, "annotate/mp.jpg")

0 comments on commit 294739c

Please sign in to comment.