Skip to main content

FrameInclusion

Enum FrameInclusion 

Source
pub enum FrameInclusion {
    Never,
    Always,
    Sampled {
        interval: u32,
    },
    TargetFps {
        target: f32,
        fallback_interval: u32,
    },
}
Expand description

Controls whether the source FrameEnvelope is included in the OutputEnvelope.

Default is Never — output contains only perception artifacts. Use Always when downstream consumers need access to the pixel data (e.g., annotation overlays, frame archival, or visual debugging).

Sampled provides a middle ground: frames are included every interval outputs, keeping metadata (detections, tracks, signals) at full rate while reducing the cost of host materialization and downstream pixel processing in the sink thread. For example, Sampled { interval: 6 } on a 30 fps source yields ~5 fps of frame delivery while perception runs at full rate.

Because FrameEnvelope is Arc-backed, inclusion is zero-copy.

Variants§

§

Never

Never include frames in output (default).

§

Always

Always include the source frame in output.

§

Sampled

Include the source frame every interval outputs.

Perception artifacts (detections, tracks, signals, provenance) flow at full rate regardless. Only the pixel payload is gated.

An interval of 1 behaves like Always. An interval of 0 behaves like Never.

Fields

§interval: u32

Include a frame every N-th output envelope.

§

TargetFps

Include frames at a target preview FPS, resolved dynamically from the observed source rate.

During a warmup window (first ~30 frames), fallback_interval is used. Once the source FPS is estimated, the interval is computed as round(source_fps / target_fps) and the variant is resolved in-place to Sampled.

This avoids hardcoding an assumed source FPS at config time.

Fields

§target: f32

Desired preview frames per second.

§fallback_interval: u32

Interval to use before the source rate is known.

Implementations§

Source§

impl FrameInclusion

Source

pub fn sampled(interval: u32) -> Self

Create a sampled frame inclusion policy with edge-case normalization.

Prefer this over constructing Sampled directly to avoid footgun values that silently alias other variants.

Source

pub fn target_fps(target: f32, fallback_interval: u32) -> Self

Create a target-FPS frame inclusion that resolves dynamically from the observed source rate.

Until the source rate is known (warmup window), falls back to fallback_interval. Once observed, resolves to Sampled.

fallback_interval is normalized: 0 → Never, 1 → Always.

Source

pub fn from_target_fps(target_fps: f32, assumed_source_fps: f32) -> Self

Compute a sampled frame inclusion from a target preview FPS and an assumed source FPS.

The interval is round(source / target), clamped to valid range.

For runtime-adaptive behavior, prefer target_fps which resolves from observed source rate instead of a static assumption.

§Examples
assert_eq!(
    FrameInclusion::from_target_fps(5.0, 30.0),
    FrameInclusion::Sampled { interval: 6 },
);
assert_eq!(
    FrameInclusion::from_target_fps(60.0, 30.0),
    FrameInclusion::Always,
);
Source

pub fn effective_interval(&self) -> u32

The effective sample interval.

  • Never0
  • Always1
  • Sampled → the configured interval
  • TargetFps → the fallback interval (actual interval is determined at runtime)
Source

pub fn resolve_with_source_fps(self, source_fps: f32) -> Self

Resolve a TargetFps variant to a concrete Sampled interval given the observed source FPS.

Returns the resolved variant. Non-TargetFps variants are returned unchanged.

Trait Implementations§

Source§

impl Clone for FrameInclusion

Source§

fn clone(&self) -> FrameInclusion

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FrameInclusion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FrameInclusion

Source§

fn default() -> FrameInclusion

Returns the “default value” for a type. Read more
Source§

impl PartialEq for FrameInclusion

Source§

fn eq(&self, other: &FrameInclusion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FrameInclusion

Source§

impl StructuralPartialEq for FrameInclusion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more