use std::path::PathBuf;
use crate::models::yolo::yolo26::Yolo26Variant;
#[derive(Clone, Debug)]
pub struct Detection {
pub bbox: [f32; 4],
pub class: String,
pub confidence: f32,
}
#[derive(Clone, Debug)]
pub struct Yolo26DetectorConfig {
pub variant: Yolo26Variant,
pub weights: PathBuf,
pub class_names: Vec<String>,
pub conf_threshold: f32,
pub nms_iou_threshold: f32,
pub img_size: usize,
}
impl Yolo26DetectorConfig {
pub fn new(
variant: Yolo26Variant,
weights: impl Into<PathBuf>,
class_names: Vec<String>,
) -> Self {
Self {
variant,
weights: weights.into(),
class_names,
conf_threshold: 0.25,
nms_iou_threshold: 0.45,
img_size: 640,
}
}
}
#[derive(Clone, Debug)]
pub enum DetectorConfig {
Yolo26(Yolo26DetectorConfig),
}
pub struct ObjectDetector {
inner: DetectorInner,
}
impl ObjectDetector {
pub fn new(config: DetectorConfig) -> anyhow::Result<Self> {
let inner = match config {
DetectorConfig::Yolo26(cfg) => DetectorInner::Yolo26(Yolo26Detector { config: cfg }),
};
Ok(Self { inner })
}
pub async fn detect(&self, image_bytes: &[u8]) -> anyhow::Result<Vec<Detection>> {
match &self.inner {
DetectorInner::Yolo26(d) => d.detect(image_bytes).await,
}
}
}
enum DetectorInner {
Yolo26(Yolo26Detector),
}
struct Yolo26Detector {
config: Yolo26DetectorConfig,
}
impl Yolo26Detector {
async fn detect(&self, _image_bytes: &[u8]) -> anyhow::Result<Vec<Detection>> {
let _ = &self.config;
todo!("YOLO26 inference")
}
}