OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::Region

A measuring region: geometry, what to do with it, the alarms on it, and its current readings.

Public attributes

id

uint64_t id = 0

Assigned by RegionStore. Do not set by hand.

name

std::string name

Free text, shown in the overlay when RegionStyle::show_label is set. Not required to be unique; the id identifies the region.

enabled

bool enabled = true

A disabled region keeps its definition but is not measured, and its rules do not evaluate.

geometry

Composite geometry

the shape, as a boolean tree

kind

RegionKind kind = RegionKind::kArea

what the region is for

aperture

Aperture aperture

kSpot / kHotSpot / kColdSpot. See Aperture; this changes reported temperatures.

search_range

SpotSearchRange search_range

kHotSpot / kColdSpot: confine the search to a temperature band, so a reflection cannot take the spot. See SpotSearchRange. Off by default; stored and ignored on every other kind.

search_mode

SpotSearchMode search_mode = SpotSearchMode::kAperture

kHotSpot / kColdSpot: whether the search is over aperture averages or over single pixels. See SpotSearchMode. Defaults to averages, which is the same answer for a single-pixel aperture and the one asked for on a sized one. Stored and ignored on every other kind.

emissivity

float emissivity = 0.0F

0 means "use the imager's global emissivity".

children

std::vector< Region > children

Hot/cold-spot children, blob children, nested areas.

rules

std::vector< Rule > rules

Alarms are part of the region, not a parallel system that references it.

style

RegionStyle style

how it is drawn in the overlay

motion

std::optional< MotionPath > motion

Set to move the region along a path over time; unset leaves it where it was placed.

blobs

BlobConfig blobs

kBlobGroup only; ignored otherwise

want_percentiles

bool want_percentiles = false

Compute percentiles as well as the base statistics.

It keeps every measured pixel of the region and selects the percentiles from them on every frame, which is why it is opt-in. RegionStats::median_c comes from the same selection, so a caller that wants only the median sets this.

On a point kind: On a point kind A spot, a hot spot and a cold spot answer this too, over the pixels their Aperture reached -- nine for a 3x3, one for ApertureShape::kPixel, where all five values are that pixel. They did not in an earlier release: the value collector was built and handed only to the area branch, so a tracking hot spot with a 5x5 aperture measured twenty-five pixels, reported their minimum, maximum, mean and standard deviation, and reported no median.

A sample refused by Aperture::min_coverage reports none of them, the same way it reports no temperatures: percentiles.valid is false and median_c is NaN beside the rest.

threshold

ThresholdConfig threshold

Count the pixels past a limit, as well as the base statistics.

Off by default. Unlike want_percentiles this costs no selection and no storage -- one comparison per pixel on the pass that is already running -- so it is opt-in only because a threshold nobody chose has no meaningful value. Honoured by every kind that measures pixels, including the point kinds, where it describes the aperture. See RegionThresholdShare.

want_samples

bool want_samples = false

Keep the individual pixel readings, so samples below can be read back and plotted as a profile.

Off by default, and opt-in for the same reason want_percentiles is: an area region can cover the whole frame, and keeping every pixel of it costs four bytes per pixel per frame that a region nobody plots should not pay. Honoured by kArea and kBlobGroup regions -- which is what Region::Line() builds -- and by the point kinds, where it is the only way to learn which pixels an aperture reached rather than how many.

On a point kind: On a point kind The samples are the aperture's clipped set, in scan order, with position NaN because a point has no distance-along. They are what RegionStyle::show_aperture draws and what makes RegionStats::coverage falsifiable: samples.size() is the window that survived clipping, RegionStats::pixel_count is how much of that was measurable, and NominalApertureCount() is what was asked for. An aperture costs at most a few dozen samples a frame, so the storage argument above barely applies -- it stays opt-in so that a display polling every region does not start allocating because a spot exists.

They survive the Aperture::min_coverage cut, exactly as pixel_count and coverage do: a sample list is the evidence for why the reading was refused, so blanking it with the temperatures would remove the one thing left to look at.

stats

RegionStats stats

this frame's measurement

emissivity_state

RegionEmissivityState emissivity_state = RegionEmissivityState::kCameras

Whether this region is being read at an emissivity of its own, and what that does to the picture. See RegionEmissivityState.

Recomputed every frame by whatever owns the radiation parameters -- Imager does it after measuring -- because the comparison is against the value the frame was corrected at, which a RegionStore has no way to know. A standalone store leaves it at kCameras, which is the honest answer when nothing said otherwise.

percentiles

RegionPercentiles percentiles

This frame's percentiles, when want_percentiles is set.

threshold_share

RegionThresholdShare threshold_share

This frame's threshold share, when threshold.enabled is set.

samples

std::vector< RegionSample > samples

This frame's individual pixel readings, when want_samples is set; empty otherwise.

Ordered along the path for a line or an open spline region, and in scan order for anything else -- see RegionSample. On a point kind these are the pixels the Aperture actually reached after clipping. The storage is reused from frame to frame rather than reallocated, so a steady region costs no allocation after the first.

detected_blobs

std::vector< RegionBlob > detected_blobs

The blobs a RegionKind::kBlobGroup region found this frame.

Always empty for any other kind. Rebuilt every frame, and the storage is reused rather than reallocated, so a steady region costs no allocation after the first. These are results, not children: nothing is added to children, no ids churn, and no rule is orphaned -- see RegionBlob.

SignalField::kBlobCount publishes this vector's size for a kBlobGroup region, which is what makes an alarm on it mean "how many hot areas are there" rather than "how many children did I add".

alarm

AlarmState alarm = AlarmState::kUnknown

The worst state across this region's rules and its children's.

active_rule_count

uint16_t active_rule_count = 0

How many of this region's own rules were raised when the alarm engine last evaluated them. Children are not included; the roll-up into RegionState::active_rules adds them.

Kept here because per-rule state lives in the engine and RegionStore deliberately does not know about the engine. The engine writes both counters onto the region on the same pass that writes alarm, so all three describe the same frame.

warning_rule_count

uint16_t warning_rule_count = 0

The same, for rules sitting in their warning band. Note that a region can have a warning rule and still report alarm as kActive, because alarm is the worst state and these are a tally -- which is exactly why one cannot be derived from the other.

tracked_loc

Vec2 tracked_loc

Where a tracked spot currently sits, in region coordinates.

Public static functions

Rect

static auto Rect(Vec2 centre, Vec2 size, float rotation_rad=0.0F) -> Region

A rectangle of size centred at centre, optionally turned.

Circle

static auto Circle(Vec2 centre, float radius) -> Region

A circle. Radius is in region-space units, where x runs 0..1 across the frame.

Ellipse

static auto Ellipse(Vec2 centre, Vec2 radii, float rotation_rad=0.0F) -> Region

An ellipse with independent radii, optionally turned.

Line

static auto Line(Vec2 a, Vec2 b) -> Region

A line between two points -- measured along the pixels it crosses.

Spot

static auto Spot(Vec2 at, Aperture aperture={}) -> Region

A point measurement. The default aperture is a single pixel; pass one to average a neighbourhood instead, which is usually what an operator wants because one pixel is noisy.

Polygon

static auto Polygon(Span< const Vec2 > points) -> Region

A closed polygon through points. Do not repeat the first point.

Spline

static auto Spline(Span< const Vec2 > points) -> Region

An open curved path through points -- a weld, a pipe, an edge.

The curved sibling of Line(): no area, measured along the pixels it runs through, and its samples carry arc length in RegionSample::position so a curved profile can be plotted. At least two control points; two is a straight line and measures exactly the pixels Line() does. See MakeSplineShape().

Passing points whose last equals the first produces a closed area rather than a path, because closure is in the data -- use ClosedSpline() when that is what you mean, so the call site says so.

ClosedSpline

static auto ClosedSpline(Span< const Vec2 > points) -> Region

A closed curved area through points. Do not repeat the first point; this appends it.

The curved sibling of Polygon(): it measures the pixels it encloses. At least three control points.

Sugar over Spline() with the first point repeated as the last, kept for the reason Ring() is kept: that is the discoverable name. Somebody looking for a closed spline finds this, not a convention about repeating a point that they would have to know to look for. There is no second Primitive behind it -- see MakeSplineShape().

Ring

static auto Ring(Vec2 centre, float outer, float inner) -> Region

A ring: an outer circle with an inner one subtracted. The shape this was added for.

Equivalent to Circle(centre, outer).Subtracted(Circle(centre, inner)), and kept as its own constructor because that is the discoverable name -- someone looking for a ring finds Ring(), not a boolean operation they have to know to reach for.

FromDrag

static auto FromDrag(Primitive primitive, Vec2 anchor, Vec2 cursor) -> Region

Drag-to-create. The two points are opposite corners in any order, so a drag up-and-left works exactly like a drag down-and-right.

Public functions

SetCentre

void SetCentre(Vec2 c)

SetSize

void SetSize(Vec2 s)

SetRadius

void SetRadius(float r)

Resizes a circle. On a non-circular region this sets both extents.

SetRotation

void SetRotation(float radians)

Turns the region about its own centre.

Translate

void Translate(Vec2 delta)

Moves the region by delta, leaving size and rotation alone.

Scale

void Scale(Vec2 factor)

Scales about the region's centre, so it grows in place rather than drifting towards the origin.

Centre

auto Centre() const -> Vec2

The region's centre in region space.

Size

auto Size() const -> Vec2

Full width and height, not half-extents.

Rotation

auto Rotation() const -> float

Rotation in radians. See HasShear() for when this is approximate.

HasShear

auto HasShear() const -> bool

True when the geometry carries a shear the friendly accessors cannot represent. Centre()/Size()/Rotation() are exact for regions built by the constructors above and best-effort otherwise; the friendly setters preserve only translation, rotation and scale.

Transform

auto Transform() const -> const Matrix3 &

The transform of the first shape leaf, for the common single-shape region.

SetTransform

void SetTransform(const Matrix3 &m)

Replaces that transform outright, shear included. The friendly setters above cannot express everything this can.

LeafTransforms

auto LeafTransforms() const -> std::vector< Matrix3 >

Every leaf transform, in tree order: the form the per-frame recording uses, and the form to drive an animation from.

SetLeafTransforms

auto SetLeafTransforms(Span< const Matrix3 > transforms) -> bool

Returns false when the count does not match the leaf count.

Transformed

auto Transformed(const Matrix3 &m) const -> Region

A copy of this region expressed in another coordinate space: m is applied on the left of every leaf transform, of this region and of its children, so the whole family moves as one body. Readings, alarm state and styling come across unchanged.

United

auto United(const Region &other) const -> Region

This region with other's area added -- the union of the two. Geometry is symmetric, everything else is the receiver's; see the notes above.

Intersected

auto Intersected(const Region &other) const -> Region

Just the area where this region and other overlap. Geometry is symmetric, everything else is the receiver's; see the notes above. An empty other leaves the receiver's geometry alone rather than emptying it -- an absent operand means "nothing to intersect with", not "intersect with nothing".

Subtracted

auto Subtracted(const Region &other) const -> Region

This region with other's area removed -- a circle minus a smaller circle is a ring. Inherently ordered: a.Subtracted(b) and b.Subtracted(a) are different shapes.

Contains

auto Contains(Vec2 p) const -> bool

True when p falls inside the geometry -- hit-testing for a click, and the same test the measurement uses per pixel.

Contains

auto Contains(Vec2 p, uint32_t frame_width) const -> bool

The same test, sized for a frame frame_width pixels across.

Use this one when walking pixels. A line region has no area, so which pixels lie on it is decided by rasterising it on the frame's own lattice -- see LineTolerance(). Given the wrong width a line lands on the wrong rows. Every other shape ignores the width.

BoundingBox

auto BoundingBox() const -> Bounds

The axis-aligned box enclosing the geometry, in region space.

BoundingBox

auto BoundingBox(uint32_t frame_width) const -> Bounds

The same box, widened for a line region's rasterisation on a frame frame_width pixels across. Pair it with the matching Contains() overload so the box cannot clip the band away.