CanvasMap
class optris_sdk.canvas.CanvasMap
Which placement covers which output pixel.
Recomputed by update, which is the only call that reads the
canvas -- so a map is a snapshot and goes stale deliberately rather
than tracking a canvas it does not own. A context manager.
CanvasMap — properties
size
The mapped area, as (width, height).
is_empty
Whether nothing has been mapped yet.
fill
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 it
by width * height and you get 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 -- read_coverage
gives a part-covered pixel a fraction of 255, and
read_indices gives one a source even where its centre
missed. The three disagree around the perimeter only.
An earlier version of this docstring 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.
CanvasMap — methods
update(canvas, frame_width, frame_height)
Recompute against canvas for a frame of that size.
read_indices()
The source pixel index behind each canvas pixel.
A flat row-major list, width * height long, where each
entry indexes the camera's frame -- not the placement. So a
382x288 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.
read_coverage()
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 whole point of it: it is why a turned
picture has a clean boundary instead of a staircase, and
composite blends with the void colour by it. The edge
is the only place this is neither 0 nor 255.
composite(src_bgra)
Composite src_bgra through this map, returning BGRA bytes.
src_bgra is the camera's frame as BGRA; the result is the
canvas, with the void colour wherever no placement covers.
close()
Release the handle. Closing twice is a no-op.