nicetoolbox.detectors.feature_detectors.leaning.utils¶
Utility functions for visualizing leaning angles and calculating the angle between three points.
Functions
Calculate the angle between three points in a 3D space. |
|
Create a matplotlib figure and canvas for creating a video with two subplots for PersonL and PersonR. |
|
Combine a video frame with the plots for PersonL and PersonR up to the current frame. |
|
Visualize the leaning angle between midpoint of shoulders, hips, and knees for each person. |
- nicetoolbox.detectors.feature_detectors.leaning.utils.calculate_angle_btw_three_points(data)[source]¶
Calculate the angle between three points in a 3D space.
- Parameters:
data (numpy.ndarray) – A 4D numpy array with shape (num_subjects, num_frames, num_points, num_coordinates) representing the coordinates of points A, B, and C for each subject and frame.
- Returns:
- A 4D numpy array with shape (num_subjects, num_frames,
num_points, 1) containing the angle between the three points for each subject and frame.
- Return type:
numpy.ndarray
- nicetoolbox.detectors.feature_detectors.leaning.utils.create_video_canvas(num_of_frames, global_min, global_max)[source]¶
Create a matplotlib figure and canvas for creating a video with two subplots for PersonL and PersonR.
- Parameters:
num_of_frames (int) – The total number of frames in the video.
global_min (float) – The global minimum value for the y-axis.
global_max (float) – The global maximum value for the y-axis.
- Returns:
The matplotlib figure object. canvas (matplotlib.backends.backend_agg.FigureCanvasAgg): The matplotlib canvas
object.
axL (matplotlib.axes._subplots.AxesSubplot): The left subplot axis for PersonL. axR (matplotlib.axes._subplots.AxesSubplot): The right subplot axis for PersonR.
- Return type:
fig (matplotlib.figure.Figure)
- nicetoolbox.detectors.feature_detectors.leaning.utils.frame_with_linegraph(frame, current_frame, data, fig, canvas, axL, axR)[source]¶
Combine a video frame with the plots for PersonL and PersonR up to the current frame.
- Parameters:
frame (numpy.ndarray) – The current video frame as a numpy array.
current_frame (int) – The index of the current frame.
data (list) – A list containing two numpy arrays, dataL and dataR, representing the leaning angles for PersonL and PersonR respectively.
fig (matplotlib.figure.Figure) – The matplotlib figure object.
canvas (matplotlib.backends.backend_agg.FigureCanvasAgg) – The matplotlib canvas object.
axL (matplotlib.axes._subplots.AxesSubplot) – The left subplot axis for PersonL.
axR (matplotlib.axes._subplots.AxesSubplot) – The right subplot axis for PersonR.
- Returns:
A numpy array representing the combined video frame and the plots.
- Return type:
numpy.ndarray
- nicetoolbox.detectors.feature_detectors.leaning.utils.visualize_lean_in_out_per_person(hip_angle, person_list, output_folder, camera_names=None)[source]¶
Visualize the leaning angle between midpoint of shoulders, hips, and knees for each person.
- Parameters:
hip_angle (numpy.ndarray) – A 4D numpy array with shape (num_subjects, num_cameras, num_frames, 2) representing the leaning angles (axis angle and derivative) for each subject, camera, and frame.
person_list (list) – A list of strings representing the names of the persons in frame.
output_folder (str) – The path to the output folder where the plots will be saved.
camera_names (list, optional) – A list of strings representing the names of the cameras. Defaults to None.
- Returns:
None