nicetoolbox.visual.media.viewer.Viewer

class nicetoolbox.visual.media.viewer.Viewer(visualizer_config: dict)[source]

Bases: object

Class for visualizing the components.

config

Configuration settings for the viewer.

Type:

dict

Initializes the Viewer class with the given configuration.

Parameters:

config (dict) – Configuration settings for the viewer.

Methods

check_multiview

Checks the consistency of the multi-view parameter in the visualizer config.

generate_component_entity_path

Generates the entity path for a given component.

get_camera_pos_entity_path

Returns the entity path for the camera position.

get_end_frame

Returns the end frame for visualization specified in the visualizer config.

get_images_entity_path

Returns the entity path for the images of a specific camera.

get_is_camera_position

Returns a boolean indicating whether to display the camera position in the viewer.

get_start_frame

Returns the start frame for visualization specified in the visualizer config.

get_step

Returns the frame step size for visualization specified in the visualizer config.

get_video_start

Returns the start time of the video in seconds.

go_to_timestamp

Go to the specified frame index in the rerun viewer.

log_camera

Logs the camera calibration in the viewer.

log_image

Logs an image in the viewer.

spawn

Spawns a rerun application with the given app_id.

check_multiview() None[source]

Checks the consistency of the multi-view parameter in the visualizer config.

Raises:

ValueError – If the multi-view parameter is set to False but a 3D canvas is present.

generate_component_entity_path(component: str, is_3d: bool = True, cam_name: str | None = None, alg_name: str | None = None, subject_name: str | None = None, bodypart: str | None = None) str[source]

Generates the entity path for a given component.

Parameters:
  • component (str) – The name of the component.

  • is_3d (bool, optional) – Flag indicating if the component is 3D. Defaults to True.

  • cam_name (str, optional) – The name of the camera. Defaults to None.

  • alg_name (str, optional) – The name of the algorithm. Defaults to None.

  • subject_name (str, optional) – The name of the subject. Defaults to None.

  • bodypart (str, optional) – The name of the body part. Defaults to None.

Returns:

The generated entity path.

Return type:

str

Raises:

ValueError – If the component is not implemented.

get_camera_pos_entity_path(camera_name: str) str[source]

Returns the entity path for the camera position.

Parameters:

camera_name (str) – The name of the camera.

Returns:

The entity path for the camera position.

Return type:

str

get_end_frame() int[source]

Returns the end frame for visualization specified in the visualizer config.

Returns:

The end frame for visualization.

Return type:

int

get_images_entity_path(camera_name)[source]

Returns the entity path for the images of a specific camera.

Parameters:

camera_name (str) – The name of the camera.

Returns:

The entity path for the images of the specified camera.

Return type:

str

get_is_camera_position()[source]

Returns a boolean indicating whether to display the camera position in the viewer.

Returns:

Whether to display the camera position in the viewer.

Return type:

bool

get_start_frame()[source]

Returns the start frame for visualization specified in the visualizer config.

Returns:

The start frame for visualization.

Return type:

int

get_step() int[source]

Returns the frame step size for visualization specified in the visualizer config.

Only every step-th frame will be visualized.

Returns:

The step for visualization.

Return type:

int

get_video_start() int[source]

Returns the start time of the video in seconds.

Returns:

The start time of the video in seconds.

Return type:

int

go_to_timestamp(frame_idx: int) None[source]

Go to the specified frame index in the rerun viewer.

Parameters:

frame_idx (int) – The index of the frame to go to.

log_camera(camera_calibration, entity_path) None[source]

Logs the camera calibration in the viewer.

Parameters:
  • camera_calibration (dict) – The camera calibration parameters.

  • entity_path (str) – The entity path for the camera.

log_image(image: array, entity_path: str, img_quality: int = 75) None[source]

Logs an image in the viewer.

Parameters:
  • image (np.array) – The image to log.

  • entity_path (str) – The entity path for the image.

  • img_quality (int, optional) – The quality of the image. Defaults to 75.

spawn(app_id: str = 'NICE Toolbox Visualization') None[source]

Spawns a rerun application with the given app_id.

Parameters:

app_id (str) – The ID of the visualization application. Defaults to “NICE Toolbox Visualization”.