1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Backend-agnostic object detection trait.
//!
//! This module defines the `ObjectDetector` trait that provides a common interface
//! for object detection across different inference backends (OpenCV DNN, ONNX Runtime, etc.).
use crateBBox;
/// A trait for object detection models.
///
/// This trait provides a backend-agnostic interface for running object detection.
/// Different backends (OpenCV, ONNX Runtime, etc.) can implement this trait with
/// their own input types and error handling.
///
/// # Type Parameters
/// * `Input` - The input image type (e.g., `opencv::core::Mat`, `ImageBuffer`)
/// * `Error` - The error type for this backend
///
/// # Example
///
/// ```ignore
/// use od_opencv::{ObjectDetector, BBox};
///
/// fn run_detection<D: ObjectDetector>(
/// detector: &mut D,
/// input: &D::Input,
/// ) -> Result<Vec<BBox>, D::Error> {
/// let (bboxes, _class_ids, _confidences) = detector.detect(input, 0.5, 0.4)?;
/// Ok(bboxes)
/// }
/// ```