robokudo.vis.visualizer

Base visualization interface for RoboKudo pipelines.

This module provides the base visualization interface and shared state management for RoboKudo pipeline visualization. It implements:

  • Observer pattern for state updates

  • Shared visualization state

  • Visualizer lifecycle management

  • Pipeline data access

  • Common visualization utilities

Dependencies

  • logging for status messages

  • py_trees for behavior tree integration

  • robokudo.annotators for annotator access

  • robokudo.pipeline for pipeline access

See Also

Classes

Visualizer

Base class for RoboKudo pipeline visualizers.

Module Contents

class robokudo.vis.visualizer.Visualizer(pipeline: robokudo.pipeline.Pipeline, shared_visualizer_state=None)

Bases: object

Base class for RoboKudo pipeline visualizers.

This class provides the foundation for implementing pipeline visualizers. It includes:

  • Observer pattern for state updates

  • Shared visualization state

  • Visualizer lifecycle management

  • Pipeline data access

  • Common visualization utilities

Parameters

pipelinerobokudo.pipeline.Pipeline

Pipeline to visualize

shared_visualizer_stateSharedState, optional

Shared state object for coordinating between visualizers

Attributes

pipelinerobokudo.pipeline.Pipeline

Pipeline being visualized

indicate_termination_varbool

Flag indicating if visualization should terminate

shared_visualizer_stateSharedState

Shared state object for coordinating between visualizers

update_outputbool

Flag indicating if display needs updating

new_databool

Flag indicating if new data is available

rk_loggerlogging.Logger

Logger instance

instanceslist

List of all active visualizer instances

Notes

Do not instantiate this class directly. Use new_visualizer_instance() to properly register visualizers.

class Observable

Base class for objects that can be observed.

This class implements the Observable part of the Observer pattern.

_observers = []
register_observer(observer)

Register an observer to receive notifications.

Parameters

observerObserver

The observer to register

notify_observers(*args, **kwargs)

Notify all registered observers.

Parameters

*args

Variable length argument list passed to observers

**kwargs

Arbitrary keyword arguments passed to observers

class Observer

Base class for objects that observe state changes.

This class implements the Observer part of the Observer pattern.

notify(observable, *args, **kwargs)

Handle notification of state changes.

Parameters

observableObservable

The object that sent the notification

*args

Variable length argument list

**kwargs

Arbitrary keyword arguments

Raises

Exception

If not implemented by subclass

class SharedState

Bases: Observable

Shared state for single-view visualizers.

This class manages state shared between visualizers, particularly for single-view visualizers that switch between annotators. It uses the Observer pattern to notify visualizers of state changes.

Notes

The Observer pattern is used for state changes, not for new data.

Attributes

active_annotatorBaseAnnotator

Currently active annotator

active_annotator_iint

Index of currently active annotator

active_annotator = None
active_annotator_i = 0
instances = []
pipeline
indicate_termination_var = False
shared_visualizer_state = None
update_output = True
new_data = False
rk_logger = None
pre_tick()

Prepare for visualization update.

Called before tick(). Override to implement pre-update logic.

tick()

Update the visualization display.

This is the main method for visualizers. Override to implement visualization logic.

post_tick()

Clean up after visualization update.

Called after tick(). Override to implement post-update logic.

static static_post_tick()

Perform static post-update operations.

This method is called once per visualizer type, regardless of how many instances exist. Override to implement static post-update logic.

classmethod new_visualizer_instance(pipeline: robokudo.pipeline.Pipeline, shared_visualizer_state=None)

Create and register a new visualizer instance.

Parameters

pipelinerobokudo.pipeline.Pipeline

Pipeline to visualize

shared_visualizer_stateSharedState, optional

Shared state object for coordinating between visualizers

Returns

Visualizer

New visualizer instance

static clear_visualizer_instances()

Remove all registered visualizer instances.

insert_input()

Handle input insertion.

Override to implement input handling logic.

activate_update_output()

Mark visualizer for update.

Sets the update flag to trigger a redraw.

new_data_available()

Signal that new data is available.

Called by external code to indicate new data is ready for visualization.

indicate_termination()

Check if visualization should terminate.

Returns

bool

True if visualization should terminate, False otherwise

static get_unique_types_of_visualizer_instances()

Get set of unique visualizer types.

Returns

set

Set of visualizer classes that have instances

update_output_flag_for_new_data() None

Update flags when new data arrives.

Sets update flag and clears new data flag when new data is available.

get_visualized_annotator_outputs_for_pipeline() robokudo.annotators.outputs.AnnotatorOutputs

Get annotator outputs for visualization.

Returns

robokudo.annotators.outputs.AnnotatorOutputs

Annotator outputs for the current pipeline

Raises

AssertionError

If outputs are not of the expected type