use nalgebra::{Point2, Vector2};
use serde::{Deserialize, Serialize};
pub use projective_grid::GridIndex as GridCoords;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Corner {
pub position: Point2<f32>,
pub orientation: f32,
pub orientation_cluster: Option<usize>,
pub strength: f32,
}
impl Corner {
pub fn as_vec2(&self) -> Vector2<f32> {
Vector2::new(self.position.x, self.position.y)
}
}
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TargetKind {
Chessboard,
Charuco,
CheckerboardMarker,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct LabeledCorner {
pub position: Point2<f32>,
pub grid: Option<GridCoords>,
pub id: Option<u32>,
#[serde(default)]
pub target_position: Option<Point2<f32>>,
#[serde(alias = "confidence")]
pub score: f32,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct TargetDetection {
pub kind: TargetKind,
pub corners: Vec<LabeledCorner>,
}