Skip to main content

visual_cortex_vision/
preprocessor.rs

1use std::sync::Arc;
2
3use visual_cortex_capture::{Frame, FrameView};
4
5use crate::detector::DetectorError;
6
7/// Transforms a watcher's cropped view into the frame the rest of the
8/// pipeline sees. Runs BEFORE the implicit frame-diff gate, so a
9/// preprocessor whose output is static (e.g. a fully-suppressed stability
10/// mask) holds the detector at zero cost until its output actually changes.
11///
12/// Preprocessors run every tick on the async path — they must be cheap
13/// (block math, copies), never heavy inference.
14pub trait Preprocessor: Send + 'static {
15    fn process(&mut self, view: &FrameView<'_>) -> Result<Arc<Frame>, DetectorError>;
16
17    /// Called once at subscribe time with the watcher's name, so stages
18    /// with debug output can label their artifacts. Default: ignore.
19    fn set_label(&mut self, _label: &str) {}
20}