Source code for nav.feature.feature

"""NavFeature — the smallest independently-navigable scene element.

Every scene that the orchestrator considers is decomposed into NavFeatures by
the registered feature extractors.  Each feature carries everything a
technique needs to know to use it or ignore it: identity, geometry,
uncertainty, a preferred filter, a reliability score, and which technique
types are allowed to consume it.
"""

import math
from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any

import numpy as np

from nav.feature.feature_type import NavFeatureType
from nav.feature.flags import NavFeatureFlags
from nav.feature.geometry import NavFeatureGeometry
from nav.support.filters import NavFilterSpec
from nav.support.types import NDArrayBoolType, NDArrayFloatType

__all__ = [
    'NavFeature',
    'NavReliabilityBreakdown',
    'body_names_from_features',
]










[docs] def body_names_from_features(features: Iterable[NavFeature]) -> frozenset[str]: """Return the set of non-empty body names across ``features``. Uses each feature's structured :attr:`NavFeature.body_name` rather than parsing ``feature_id`` strings, so the source-body identity a technique reports cannot silently diverge from a change to the feature-id format. """ return frozenset(bn for f in features if (bn := f.body_name))