vision_core/
interfaces.rs1use serde::{Deserialize, Serialize};
2use std::path::PathBuf;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Frame {
7 pub id: u64,
8 pub timestamp: f64,
10 pub rgba: Option<Vec<u8>>,
12 pub size: (u32, u32),
14 pub path: Option<PathBuf>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct DetectionResult {
21 pub frame_id: u64,
22 pub positive: bool,
23 pub confidence: f32,
24 pub boxes: Vec<[f32; 4]>,
26 pub scores: Vec<f32>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct Label {
33 pub center_world: [f32; 3],
34 pub bbox_px: Option<[f32; 4]>,
35 pub bbox_norm: Option<[f32; 4]>,
36}
37
38#[derive(Debug)]
40pub struct FrameRecord<'a> {
41 pub frame: Frame,
42 pub labels: &'a [Label],
43 pub camera_active: bool,
44 pub polyp_seed: u64,
45}
46
47pub trait FrameSource {
49 fn next_frame(&mut self) -> Option<Frame>;
50}
51
52pub trait Detector {
54 fn detect(&mut self, frame: &Frame) -> DetectionResult;
55 fn set_thresholds(&mut self, _obj: f32, _iou: f32) {}
57}
58
59pub trait Recorder {
61 fn record(&mut self, record: &FrameRecord) -> std::io::Result<()>;
62}
63
64pub trait BurnDetectorFactory {
66 type Detector: Detector;
67 fn load(model_path: &std::path::Path) -> anyhow::Result<Self::Detector>;
68}