nicetoolbox.detectors.feature_detectors.proximity.body_distance.BodyDistance

class nicetoolbox.detectors.feature_detectors.proximity.body_distance.BodyDistance(io, data, sequence_context, algorithm_instance: str)[source]

Bases: BaseFeature

The 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.

Initialize base detector with references.

Subclasses should call super().__init__() and set inference_config.

Methods

compute

Computes the proximity component.

compute_output_folders

Compute extra output folders for all components.

compute_result_folders

Compute result folders for all components.

compute_viz_folders

Compute visualization folders for all components.

get_input_file

Get the input file path for a specific upstream detector.

run

Execute feature detector: compute() + post_compute().

visualization

Creates visualizations for the computed proximity component.

Attributes

algorithm_type

components

predictions_mapping

Access predictions mapping from runtime config.

requires_out_folder

data

io

sequence_context

detector_config

algorithm_instance

inference_config

visualize

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)

compute_output_folders(requires_out_folder: bool) Dict[str, str]

Compute extra output folders for all components.

compute_result_folders() Dict[str, str]

Compute result folders for all components.

compute_viz_folders(visualize: bool) Dict[str, str]

Compute visualization folders for all components.

get_input_file(component: str, algorithm: str) Path

Get the input file path for a specific upstream detector.

Parameters:
  • component – Component name (e.g., ‘body_joints’)

  • algorithm – Algorithm name (e.g., ‘hrnetw48’)

Returns:

Path to the .npz result file

property predictions_mapping

Access predictions mapping from runtime config.

run() Any

Execute feature detector: compute() + post_compute().

Returns computed data for visualization.

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.