Region
class optris_sdk.measurement.Region
A shape to measure, before it belongs to a camera.
Built through the class methods -- rect, circle,
ellipse, line, spot, polygon,
spline, closed_spline, ring -- because the
ABI has a constructor per shape and the
arguments genuinely differ. A single constructor taking every
shape's parameters would accept nonsense.
The handle is freed when the object is garbage collected, or at
with block exit. Adding a region to a camera copies it, so the
object may be freed, reused or changed afterwards without affecting
what the camera is measuring.
Region — properties
kind
emissivity
enabled
want_percentiles
want_samples
aperture
The sampling neighbourhood; see Aperture.
This changes the temperature the region reports. Until API
version 12 an aperture could only be handed to spot,
and a tracked spot is built the SDK's own way -- a point, then
a change of kind, hung under an area -- where there was
nowhere to put one. Every hot and cold spot made that way
measured a single pixel and nothing said so.
Reading gives a copy, so assign it back after changing it.
search_range
The band a tracked spot searches in; see
SpotSearchRange.
Honoured by REGION_HOT_SPOT and REGION_COLD_SPOT;
stored and ignored on every other kind. Reading gives a copy,
so assign it back after changing it.
search_mode
Whether a tracked spot searches patches or pixels.
SEARCH_APERTURE (the default) takes the position whose
aperture average is the extreme; SEARCH_PIXEL takes the
single extreme pixel and averages around it. With
APERTURE_PIXEL the two are identical.
blobs
Blob detection settings; see BlobConfig.
Meaningful only on a BLOB_GROUP region; on any other kind
they are stored, saved and ignored. Reading gives a copy, so
assign it back after changing it.
style
How the region is drawn; see RegionStyle.
Reading gives a copy, so assign it back after changing it.
threshold
Threshold counting; see RegionThreshold.
Honoured by every kind that measures pixels. Reading gives a copy, so assign it back after changing it.
centre
size
rotation_rad
name
What the region is called.
Reads through to the region, so one obtained from
Regions.copy reports what the camera holds rather than
an empty string.
shapes
The placed shapes the geometry is built from, in tree order.
One for every region the constructors build except a ring,
which is a circle with a smaller circle subtracted and has two.
Each is a RegionShape.
Region — methods
rect(cls, centre, size, rotation_rad = 0.0)
An axis-aligned or rotated rectangle.
circle(cls, centre, radius)
ellipse(cls, centre, radii, rotation_rad = 0.0)
line(cls, start, end)
A line, which is the only shape that yields samples.
spot(cls, at, aperture = None)
A point, averaged over an Aperture.
polygon(cls, points)
spline(cls, points)
A curve through points -- a centripetal Catmull-Rom
spline, which passes through every control point given.
Open by default, and then it is a path: no area, measuring the
pixels it runs through on the frame's own pixel lattice exactly
as a line does, with arc length in
RegionSample.position. Two control points is a straight
line and measures exactly what line does.
Repeating the first point as the last closes the curve, and a
closed curve is an area -- it measures the pixels it encloses
and its position is NaN. Use closed_spline, which
appends the repeat for you, rather than doing it by hand.
closed_spline(cls, points)
A closed curve through points; do not repeat the first.
spline with the first control point repeated as the
last, which is what closes it. At least three points.
ring(cls, centre, outer, inner)
set_name(name)
Give the region a name, so it can be found without its id.
shape_points(shape_index = 0)
The explicit points of one shape, in region coordinates.
A polygon's vertices, or a spline's control points. Already placed by the shape's own transform, so for a polygon these are the points to draw rather than the unit-space vertices the region was built from. The outline closes implicitly: the first point is not repeated. Empty for any other primitive, which is an answer and not an error.
For PRIMITIVE_SPLINE these are not the points to draw --
they are the handles the curve passes through, and joining them
up draws the control polygon instead of the curve. Use
shape_curve. A closed spline's last control point
repeats its first, visibly, because that repeat is what closes
it.
shape_curve(shape_index = 0)
The drawable curve of one spline shape, in region coordinates.
A polyline through the curve, already placed -- the points to draw, joined in order with straight segments. It is the same polyline the SDK's own containment test walks, so an overlay drawn from this cannot disagree with what was measured.
An open spline's list is to be drawn unclosed; a closed one's is
to be drawn closed, with the first point not repeated at the end
-- the same convention shape_points reports a polygon's
outline in. Empty for any other primitive.
add_child(child)
Not reachable from Python, and not for want of trying.
In C++ a region has std::vector<Region> children, and a hot
or cold spot nested inside an area region tracks the extreme
within that region rather than across the whole frame. That
is the feature this method would expose.
The flat C ABI has no entry point for it. A std::vector of
a recursive type has no flat representation and nothing was
added to stand in for one, so nesting is unreachable from C and
therefore from every binding built on C -- this one, C# and
Rust alike.
The method exists rather than being absent so the limitation is
documented where somebody goes looking for the feature, and so
the failure names the cause instead of surfacing as an
AttributeError about a missing symbol.
Until the ABI carries it: a tracked spot with no parent
searches the whole frame, and an area region's own max_loc
and min_loc already give the extreme inside that region,
which is what nesting is usually wanted for.
copy_to_canvas(placement)
This region, mapped through placement into canvas space.
A new region; the original is untouched and you own both. Use it for a region that should follow the picture as the view moves. A region that should instead stay where it is on the canvas while the picture moves under it needs no mapping -- that is what a canvas region already does.
A singular placement is accepted here, unlike
copy_to_frame. This direction uses the forward
transform, which is defined even at zoom 0 -- the region simply
collapses, measured as centre (0.0, 0.0). Only the inverse
direction has nothing to answer.
copy_to_frame(placement)
This region, mapped back through placement into the frame.
The inverse of copy_to_canvas, and the direction the
SDK itself takes every time it measures a canvas region.
- Raises
InvalidArgumentError— for a singular placement -- zoom 0, or a matrix collapsed to a line. Measured: "the placement is singular, so no canvas point names a frame point and the region has no form in the frame". This is the asymmetry withcopy_to_canvas, which accepts one.