nicetoolbox.detectors.feature_detectors.leaning.body_angle¶
Body Angle feature detector class for the leaning component.
Classes
The BodyAngle class is a feature detector that computes the leaning component. |
- class nicetoolbox.detectors.feature_detectors.leaning.body_angle.BodyAngle(config, io, data)[source]¶
The BodyAngle class is a feature detector that computes the leaning component.
The BodyAngle feature detector accepts the body_joints component as input, which is computed using the human_pose method detector. The leaning component of this feature detector calculates the angle between the midpoints of specified keypoint pairs on the body. The feature detector outputs the angle and its gradient with respect to the frames/time.
Component: leaning
- components¶
List of components associated with the feature detector.
- Type:
list
- algorithm¶
The algorithm used for detecting leaning.
- Type:
str
- predictions_mapping¶
Mapping of the keypoint names to their indices.
- Type:
dict
- camera_names¶
List of camera names.
- Type:
list
- used_keypoints¶
List of keypoint pairs to calculate the leaning index.
- Type:
list
- keypoint_index¶
List of keypoint indices to calculate the leaning index.
- Type:
list
Setup input/output folders and data for the BodyAngle feature detector.
This method initializes the BodyAngle class by setting up the necessary configurations, input/output handler, and data. It extracts the body_joints component and prepares the used keypoints and keypoint indices given the predictions mapping.
- Parameters:
config (dict) – The method-specific configurations dictionary.
io (class) – A class instance that handles input and output folders.
data (class) – A class instance that stores all input file locations.
- compute()[source]¶
Computes the leaning component.
This method calculates the Euclidean distance between the keypoints of personL and personR. It first calculates the midpoint of each pair of keypoints, then computes the angle between these midpoints. The leaning angle is calculated for each frame, and its gradient with respect to time is computed as well.
The results are saved in a numpy .npz file with the following structure: - body_angle_2d: A numpy array containing the leaning angle for 2D data. - body_angle_3d: A numpy array containing the leaning angle for 3D data. - data_description: A dictionary containing the data description for the above
output numpy arrays. See the documentation of the output for more details.
- Returns:
- A dictionary containing the leaning angle and its gradient
for each dimension (2D and 3D).
- Return type:
out_dict (dict)
- post_compute(distance_data)[source]¶
Post-processing after computation.
This method is intended to perform any necessary post-processing tasks after the main computation method (compute) has been executed. It is designed to be overridden in derived classes to provide specific post-processing logic.
- visualization(out_dict)[source]¶
Creates visualizations for the computed leaning component.
This method takes the output dictionary of the compute method, extracts the 2D and 3D body angle data, and calls the visualization utility to create visualizations for each dimension.
Args: out_dict (dict): The output dictionary from the compute method. It contains the
calculated leaning angles and their gradients for each dimension (2D and 3D).
- Returns:
None