algorithms/
lib.rs

1//! This crate contains the algorithms used by the feonix software.
2
3mod localize;
4use types::cv::{BoxDetection, Gps, Object};
5
6// TODO: add different localization functions (accounting camera angle)
7/// Returns the real world latitude and longitude of a detected object given current drone position and detected bounding box.
8pub fn localize(gps: Gps, detection: &BoxDetection) -> Object {
9    let camera_coords = (gps.lat, gps.long);
10    let centerx = (detection.x2 + detection.x1) / 2.0;
11    let centery = (detection.y2 + detection.y1) / 2.0;
12    let (lat, long) = localize::resolve_gps_location(
13        camera_coords,
14        gps.alt,
15        gps.heading,
16        (centerx as i32, centery as i32),
17    );
18
19    Object {
20        lat,
21        long,
22        class: detection.class_index,
23        confidence: detection.conf,
24    }
25}