nv_perception/scene.rs
1//! Scene-level features — observations about the entire visible scene.
2//!
3//! Unlike per-detection or per-track features, scene features describe whole-scene
4//! properties such as complexity estimates, ambient conditions, or scene embeddings.
5//!
6//! Scene features are domain-agnostic: names and semantics are chosen by stage
7//! authors. The core provides the structural type only.
8
9use nv_core::MonotonicTs;
10
11/// A single scene-level feature observation produced by a perception stage.
12///
13/// # Example
14///
15/// ```
16/// use nv_perception::{SceneFeature, SceneFeatureValue};
17/// use nv_core::MonotonicTs;
18///
19/// let complexity = SceneFeature {
20/// name: "scene_complexity",
21/// value: SceneFeatureValue::Scalar(0.82),
22/// confidence: Some(0.95),
23/// ts: MonotonicTs::from_nanos(1_000_000),
24/// };
25/// ```
26#[derive(Clone, Debug)]
27pub struct SceneFeature {
28 /// Feature name — compile-time constant chosen by the stage author.
29 pub name: &'static str,
30 /// The observed value.
31 pub value: SceneFeatureValue,
32 /// Optional confidence in `[0.0, 1.0]` (`None` = not applicable).
33 pub confidence: Option<f32>,
34 /// Timestamp at which this feature was computed.
35 pub ts: MonotonicTs,
36}
37
38/// Possible values for a scene feature.
39#[derive(Clone, Debug)]
40pub enum SceneFeatureValue {
41 /// A single scalar (e.g., density = 0.73).
42 Scalar(f64),
43 /// A numeric vector (e.g., scene embedding).
44 Vector(Vec<f64>),
45 /// A boolean flag (e.g., daytime = true).
46 Boolean(bool),
47 /// A categorical label (e.g., "indoor").
48 Categorical(&'static str),
49 /// A distribution over named categories.
50 Distribution(Vec<(&'static str, f64)>),
51}