use serde::{Deserialize, Serialize};
use std::path::PathBuf;
pub use data_contracts::{DetectionLabel as Label, LabelSource};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Frame {
pub id: u64,
pub timestamp: f64,
pub rgba: Option<Vec<u8>>,
pub size: (u32, u32),
pub path: Option<PathBuf>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DetectionResult {
pub frame_id: u64,
pub positive: bool,
pub confidence: f32,
pub boxes: Vec<[f32; 4]>,
pub scores: Vec<f32>,
}
#[derive(Debug)]
pub struct FrameRecord<'a> {
pub frame: Frame,
pub labels: &'a [Label],
pub camera_active: bool,
pub label_seed: u64,
}
pub trait FrameSource {
fn next_frame(&mut self) -> Option<Frame>;
}
pub trait Detector {
fn detect(&mut self, frame: &Frame) -> DetectionResult;
fn set_thresholds(&mut self, _obj: f32, _iou: f32) {}
}
pub trait Recorder {
fn record(&mut self, record: &FrameRecord) -> std::io::Result<()>;
}
pub trait BurnDetectorFactory {
type Detector: Detector;
fn load(model_path: &std::path::Path) -> anyhow::Result<Self::Detector>;
}