Skip to main content

nv_perception/
signal.rs

1//! Generic derived signals — named scalar/vector/boolean/categorical values.
2//!
3//! Signals are domain-agnostic. Stage authors define the names and semantics.
4//! Multiple stages may emit different signals per frame.
5
6use nv_core::MonotonicTs;
7
8/// A generic named signal produced by a perception stage.
9///
10/// Signals carry a name, a value, and the timestamp at which they were computed.
11/// The name is a `&'static str` — signal names are fixed at compile time in
12/// the stage implementation.
13///
14/// # Examples
15///
16/// ```
17/// use nv_perception::{DerivedSignal, SignalValue};
18/// use nv_core::MonotonicTs;
19///
20/// let signal = DerivedSignal {
21///     name: "scene_complexity",
22///     value: SignalValue::Scalar(0.73),
23///     ts: MonotonicTs::from_nanos(1_000_000),
24/// };
25/// ```
26#[derive(Clone, Debug)]
27pub struct DerivedSignal {
28    /// Signal name — compile-time constant chosen by the stage author.
29    pub name: &'static str,
30    /// The signal value.
31    pub value: SignalValue,
32    /// Timestamp at which this signal was computed.
33    pub ts: MonotonicTs,
34}
35
36/// The value of a derived signal.
37#[derive(Clone, Debug)]
38pub enum SignalValue {
39    /// A single scalar value.
40    Scalar(f64),
41    /// A numeric vector (feature vector, histogram, etc.).
42    Vector(Vec<f64>),
43    /// A boolean flag.
44    Boolean(bool),
45    /// A categorical value — a compile-time label.
46    Categorical(&'static str),
47}