OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Rust API referencev12.0

CanvasMap

pub struct CanvasMap

Which source pixel is behind which canvas pixel.

Recomputed by CanvasMap::update, which is the only call that reads a canvas, so a map is a snapshot and goes stale deliberately rather than tracking a canvas it does not own.

CanvasMap — methods

pub fn new() -> Result<Self>

An empty map. CanvasMap::update fills it.

pub fn update(&mut self, canvas: &Canvas, frame_width: u32, frame_height: u32) -> Result<()>

Recompute against canvas for a frame of that size.

pub fn size(&self) -> Result<(u32, u32)>

The mapped area. (0, 0) before the first update.

pub fn is_empty(&self) -> Result<bool>

Whether nothing has been mapped yet.

pub fn fill(&self) -> Result<f32>

The fraction of the canvas with a camera behind it, 0 to 1.

Useful for telling "zoomed out" from "panned away".

One sample per canvas pixel, taken at its centre. A pixel counts in full when the frame is behind that centre and not at all when it is not, so a part-covered edge pixel counts exactly when its own centre is covered.

That makes it a count of pixels, not an area: multiply by width * height and the result is a whole number. It is also totalled before the edge is measured, so it is not the fraction of pixels that have a source either: CanvasMap::coverage gives a part-covered pixel a fraction of 255, and CanvasMap::indices gives one a source even where its centre missed. The three disagree around the perimeter only.

An earlier version of this comment said fill tracked the coverage-weighted area. It does not; centre sampling merely approximates one, which is why the two agree to within a fraction of a percent and why bracketing fill between the whole and touched counts could not tell them apart.

pub fn indices(&self) -> Result<Vec<i32>>

The source pixel index behind each canvas pixel.

Row-major, width * height long, where each entry indexes the camera's frame, not the placement. So a 382×288 camera yields values up to 110015, and a compositor reads its own frame through this table rather than repeating the transform per pixel. NO_SOURCE where the canvas has no camera behind it.

pub fn coverage(&self) -> Result<Vec<u8>>

How much of each canvas pixel the frame covers, 0 to 255.

255 inside, 0 outside, and the real fraction along the edge, which is the point of it: it is why a turned picture has a clean boundary instead of a staircase, and CanvasMap::composite blends with the void colour by it.

pub fn composite(&self, src_bgra: &[u8]) -> Result<Vec<u8>>

Composite src_bgra through this map, returning BGRA bytes.

src_bgra is the camera's frame; the result is the canvas, with the void colour wherever no placement covers.