types/
cv.rs

1//! All computer vision related types.
2
3use chrono::{DateTime, Utc};
4use ort::session::Session;
5use serde::{Deserialize, Serialize};
6
7/// A GPS coordinate. Contains latitude, longitude, altitude, heading, and timestamp.
8#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
9pub struct Gps {
10    pub lat: f64,
11    pub long: f64,
12    pub alt: f64,
13    pub heading: f64,
14
15    #[serde(with = "chrono::serde::ts_milliseconds")]
16    pub time: DateTime<Utc>,
17}
18
19/// A object detection model.
20pub struct Model {
21    pub model: Session,
22    pub input_size: i32,
23}
24
25/// An object detection represented by a bounding box.
26#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
27pub struct BoxDetection {
28    pub x1: f32,          // bounding box left-top x
29    pub y1: f32,          // bounding box left-top y
30    pub x2: f32,          // bounding box right-bottom x
31    pub y2: f32,          // bounding box right-bottom y
32    pub class_index: i32, // class index
33    pub conf: f32,        // confidence score
34}
35pub type Detections = Vec<BoxDetection>;
36
37/// Dimensional info regarding the image being processed.
38pub struct MatInfo {
39    pub width: f32,       // original image width
40    pub height: f32,      // original image height
41    pub scaled_size: f32, // effective size fed into the model
42}
43
44/// A detected object.
45#[derive(Debug, Clone)]
46pub struct Object {
47    pub lat: f64,
48    pub long: f64,
49    pub class: i32,
50    pub confidence: f32,
51}