Skip to main content

lift_tile_boxes

Function lift_tile_boxes 

Source
pub fn lift_tile_boxes(
    boxes: Vec<DetectBox>,
    placement: &TilePlacement,
) -> Vec<DetectBox>
Expand description

Lift tile-local normalized [0,1] xyxy detections (over the model input) to full-frame pixel xyxy. Mirrors metrics/tiled.py::lift_tile_boxes: optionally invert the letterbox, then full = origin + norm * crop_size. Consumes and rewrites boxes in place.

ยงExamples

use edgefirst_decoder::tiling::{lift_tile_boxes, TilePlacement};
use edgefirst_decoder::{BoundingBox, DetectBox};

let placement = TilePlacement {
    index: 0, count: 1,
    origin: (100.0, 200.0), crop_size: (640.0, 640.0),
    letterbox: None, frame_dims: (3840.0, 2160.0),
};
let tile_local = DetectBox { bbox: BoundingBox::new(0.0, 0.0, 1.0, 1.0), score: 0.9, label: 0 };
let lifted = lift_tile_boxes(vec![tile_local], &placement);
assert_eq!(lifted[0].bbox, BoundingBox::new(100.0, 200.0, 740.0, 840.0));