nicetoolbox.detectors.feature_detectors.proximity.body_distance.BodyDistance¶
- class nicetoolbox.detectors.feature_detectors.proximity.body_distance.BodyDistance(config, io, data)[source]¶
Bases:
BaseFeatureThe BodyDistance class is a feature detector that computes the proximity component.
The BodyDistance feature detector calculates the Euclidean distance between keypoints of different individuals in the scene, essentially determining the proximity between individuals from one frame to the next.
Component: proximity
- components¶
A list containing the name of the component this class is responsible for: proximity.
- Type:
list
- algorithm¶
The name of the algorithm used to compute the proximity component. body_distance: the Euclidean distance between individuals in the scene
- Type:
str
- valid_run¶
A boolean value indicating whether the feature detector can run with the given input data.
- Type:
bool
- predictions_mapping¶
A dictionary containing the mapping of body parts to their respective indices, used to identify the keypoints for distance calculation.
- Type:
dict
- camera_names¶
A list containing the names of the cameras used to capture the original input data.
- Type:
list
- used_keypoints¶
A list containing the names of the keypoints used for calculating the distance.
- Type:
list
- keypoint_index¶
A list containing the indices of the keypoints used for
- Type:
list
- calculating¶
Initialize Movement class. Setup the BodyDistance feature detector and extract gaze component from method detector output.
This method initializes the BodyDistance 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.
Methods
Computes the proximity component.
Post-processing after computation.
Creates visualizations for the computed proximity component.
Attributes
- compute()[source]¶
Computes the proximity component.
This method calculates the Euclidean distance between the keypoints of personL and personR. If the length of the keypoint index list is greater than 1, the midpoint of the keypoints will be used in the proximity measure.
The results are saved in a numpy .npz file with the following structure: - body_distance_2d: A numpy array containing the proximity scores in 2D. - body_distance_3d: A numpy array containing the proximity scores in 3D. - 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 proximity scores (2D and/or 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 proximity component.
The visualization includes a line graph of the proximity scores over time, and the proximity scores are also displayed on top of the original video frames. The video is saved as ‘proximity_score_on_video.mp4’ in the visualization folder.
- Parameters:
out_dict (dict) – A dictionary containing the proximity scores computed by the feature detector. It should contain keys ‘body_distance_2d’ and/or
'body_distance_3d' – scores for the respective dimension.
proximity (each mapping to a numpy array containing the) – scores for the respective dimension.