Skip to content

Functions

app.domain.helpers.functions

View source code

Domain utility functions for string handling and validation.

See Also

Layer: Domain. Context: Defines application concepts independently of UI and infrastructure implementations.

str_iterable_as_set_without_null_values(iterable: Iterable[str]) -> set[str]

Convert string iterable to set, filtering falsy values.

PARAMETER DESCRIPTION
iterable

Input values to clean and deduplicate.

TYPE: Iterable[str]

RETURNS DESCRIPTION
set[str]

set[str]: A set containing only truthy string values from iterable.

RAISES DESCRIPTION
EmptySetGeneratedFromKeysError

If every item in iterable is falsy.

Note

Filters out empty or otherwise falsy values, deduplicates the remaining strings by converting them to a set, and validates that at least one usable value remains.

Example

keys = ["person", "car", "", None, "person"] # With empties result = str_iterable_as_set_without_null_values(keys)

→ {"person", "car"} (deduplicated, cleaned)

empty_keys = ["", "", ""] result = str_iterable_as_set_without_null_values(empty_keys)

→ EmptySetGeneratedFromKeysError (all were falsy)

map_detections_to_bbox(detections: list[DetectionResult]) -> ListOfBoxes

Maps a list of DetectionResult objects to a list of BBoxViewModel objects for UI display.

Note

DetectionResult ≡ BBoxViewModel But,

BBoxViewModel is used for UI representation and, includes literal attributes source and key.

PARAMETER DESCRIPTION
detections

List of DetectionResult objects to be mapped.

TYPE: list[DetectionResult]

RETURNS DESCRIPTION
ListOfBoxes

List of BBoxViewModel objects representing the mapped detections.

new_passes_filter(layer_name: VideoDataLayer, box: BBoxViewModel, settings: ProcessingSettings) -> bool

Determines if a detection item passes the filter criteria for Layer B/D based on confidence and label settings.

Filter Criteria
  • Confidence: The detection's confidence must be greater than or equal to the minimum detection confidence.
  • Label: If specific labels are chosen, the detection's label must be in the chosen labels list.
PARAMETER DESCRIPTION
layer_name

The layer name for which the filter is applied.

TYPE: VideoDataLayer

box

The detection item to be evaluated.

TYPE: BBoxViewModel

settings

The processing settings containing filter criteria.

TYPE: ProcessingSettings

RETURNS DESCRIPTION
bool

True if the detection passes the filter, False otherwise.

TYPE: bool