cortenforge-vision-core 0.6.0

Core vision interfaces and capture/overlay helpers for the CortenForge stack.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use vision_core::overlay::{draw_rect, normalize_box};

#[test]
fn normalize_and_draw_box() {
    let bbox = normalize_box([0.1, 0.2, 0.3, 0.4], (100, 200)).expect("bbox");
    assert_eq!(bbox, [10, 40, 30, 80]);

    let mut img = image::RgbaImage::new(40, 40);
    draw_rect(&mut img, [5, 5, 10, 10], image::Rgba([255, 0, 0, 255]), 2);
    // Expect the four corners to be colored.
    assert_eq!(img.get_pixel(5, 5), &image::Rgba([255, 0, 0, 255]));
    assert_eq!(img.get_pixel(10, 5), &image::Rgba([255, 0, 0, 255]));
    assert_eq!(img.get_pixel(5, 10), &image::Rgba([255, 0, 0, 255]));
    assert_eq!(img.get_pixel(10, 10), &image::Rgba([255, 0, 0, 255]));
}