Skip to main content

yscv_detect/
error.rs

1use thiserror::Error;
2use yscv_tensor::TensorError;
3use yscv_video::VideoError;
4
5#[derive(Debug, Clone, PartialEq, Error)]
6pub enum DetectError {
7    #[error("invalid map shape: expected rank {expected_rank}, got {got:?}")]
8    InvalidMapShape {
9        expected_rank: usize,
10        got: Vec<usize>,
11    },
12    #[error("invalid channel count: expected {expected}, got {got}")]
13    InvalidChannelCount { expected: usize, got: usize },
14    #[error("invalid threshold: {threshold}; expected finite threshold in [0, 1]")]
15    InvalidThreshold { threshold: f32 },
16    #[error("invalid iou_threshold: {iou_threshold}; expected finite threshold in [0, 1]")]
17    InvalidIouThreshold { iou_threshold: f32 },
18    #[error("invalid min_area: {min_area}; expected min_area > 0")]
19    InvalidMinArea { min_area: usize },
20    #[error("invalid max_detections: {max_detections}; expected max_detections > 0")]
21    InvalidMaxDetections { max_detections: usize },
22    #[error("rgb8 frame dimensions overflow for width={width}, height={height}")]
23    Rgb8DimensionsOverflow { width: usize, height: usize },
24    #[error("invalid rgb8 frame buffer size: expected {expected} bytes, got {got}")]
25    InvalidRgb8BufferSize { expected: usize, got: usize },
26    #[error(transparent)]
27    Tensor(#[from] TensorError),
28    #[error(transparent)]
29    Video(#[from] VideoError),
30    #[cfg(feature = "onnx")]
31    #[error("onnx error: {0}")]
32    Onnx(#[from] yscv_onnx::OnnxError),
33}