vision_core/
interfaces.rs1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4pub use data_contracts::{DetectionLabel as Label, LabelSource};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct Frame {
10 pub id: u64,
11 pub timestamp: f64,
13 pub rgba: Option<Vec<u8>>,
15 pub size: (u32, u32),
17 pub path: Option<PathBuf>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct DetectionResult {
24 pub frame_id: u64,
25 pub positive: bool,
26 pub confidence: f32,
27 pub boxes: Vec<[f32; 4]>,
29 pub scores: Vec<f32>,
31}
32
33#[derive(Debug)]
35pub struct FrameRecord<'a> {
36 pub frame: Frame,
37 pub labels: &'a [Label],
38 pub camera_active: bool,
39 pub label_seed: u64,
40}
41
42pub trait FrameSource {
44 fn next_frame(&mut self) -> Option<Frame>;
45}
46
47pub trait Detector {
49 fn detect(&mut self, frame: &Frame) -> DetectionResult;
50 fn set_thresholds(&mut self, _obj: f32, _iou: f32) {}
52}
53
54pub trait Recorder {
56 fn record(&mut self, record: &FrameRecord) -> std::io::Result<()>;
57}
58
59pub trait BurnDetectorFactory {
61 type Detector: Detector;
62 fn load(model_path: &std::path::Path) -> anyhow::Result<Self::Detector>;
63}