nav.annotation
- class Annotation(obs: ObsSnapshot, overlay: ndarray[tuple[Any, ...], dtype[bool]], overlay_color: tuple[int, int, int], *, thicken_overlay: int = 0, text_info: AnnotationTextInfo | list[AnnotationTextInfo] | tuple[AnnotationTextInfo, ...] | None = None, avoid_mask: ndarray[tuple[Any, ...], dtype[bool]] | None = None, config: Config | None = None)[source]
Bases:
objectRepresents an annotation for an observation image.
This class handles overlays and text annotations to be displayed on observation images.
- Parameters:
obs – The observation snapshot to annotate
overlay – Boolean mask indicating where the overlay should appear
overlay_color – RGB color tuple for the overlay
thicken_overlay – Number of pixels to thicken the overlay by
text_info – Text annotation information
avoid_mask – Boolean mask indicating areas where text should not be placed
config – Configuration object
- add_text_info(text_info: AnnotationTextInfo | list[AnnotationTextInfo] | tuple[AnnotationTextInfo, ...]) → None[source]
Adds text annotation information to this annotation.
- Parameters:
text_info – One or more text annotation information objects to add
- property avoid_mask: ndarray[tuple[Any, ...], dtype[bool]] | None
Returns the mask indicating areas where text should not be placed, if any.
- property obs: ObsSnapshot
Returns the observation snapshot associated with this annotation.
- property overlay: ndarray[tuple[Any, ...], dtype[bool]]
Returns the boolean mask representing the overlay area.
- property text_info_list: list[AnnotationTextInfo]
Returns the list of text annotation information objects.
- class Annotations(*, config: Config | None = None)[source]
Bases:
NavBaseManages a collection of annotation objects for an observation.
This class provides functionality to combine multiple annotations into a single overlay image and handle text placement.
- add_annotations(annotations: Annotation | list[Annotation] | Annotations | None) → None[source]
Adds one or more annotations to this collection.
- Parameters:
annotations – The annotation(s) to add. Can be a single Annotation, a list of Annotations, another Annotations object, or None.
- Raises:
ValueError – If an annotation is for a different observation than existing
annotations. –
- property annotations: list[Annotation]
Return the list of annotations.
- combine(offset: tuple[float, float] = (0.0, 0.0), include_text: bool = True, text_use_avoid_mask: bool = True, text_avoid_other_text: bool = True, text_show_all_positions: bool = False) → ndarray[tuple[Any, ...], dtype[integer[Any]]] | None[source]
Combines all annotations into a single graphic overlay image.
- Parameters:
offset – Optional offset (dv,du) to apply to all annotations
include_text – Whether to include text annotations
text_use_avoid_mask – Whether to use avoid masks for text placement
text_avoid_other_text – Whether text should avoid other text
text_show_all_positions – Whether to show all possible text positions
- Returns:
A combined RGB array containing all annotations, or None if no annotations exist.
- class AnnotationTextInfo(text: str, text_loc: list[TextLocInfo], ref_vu: tuple[int, int] | None, *, color: tuple[int, ...], font: str, font_size: int)[source]
Bases:
object- property ref_vu: tuple[int, int] | None
Returns the reference point (v, u) that the text is associated with.
- property text_loc: list[TextLocInfo]
Returns the list of possible text locations.