Region
public sealed class Region : IDisposable
A measuring region: a shape on the frame whose temperatures the camera computes on every frame.
Build one with a factory method, adjust it, then hand it to ThermalCamera.AddRegion(…), which copies it. The Region you built stays yours: dispose it, or reuse it to add the same shape again.
Coordinates are frame-normalized and isotropic. The origin is the frame's top-left, and both axes are divided by the frame width. So X runs 0 to 1 and Y runs 0 to height/width -- 0.75 on a 4:3 sensor, not 1.0. That is what makes Region.Circle(…) a true circle in pixels at any resolution, and gives an aperture radius the same meaning on both axes.
Example
using var region = Region.Rect(centre: new Vector2(0.5f, 0.375f), size: new Vector2(0.4f, 0.3f)); region.Name = "middle"; ulong id = camera.AddRegion(region); // `region` is still ours; the camera has its own copy.
Region: properties
public Aperture Aperture { get; set; }
The sampling neighbourhood of a point region.
- Throws
ObjectDisposedException: The region has been disposed.
This changes the temperature the region reports. See Region.Aperture.
Until API version 12 an aperture could only be attached at construction, by Region.Spot(…). A tracked spot is built the SDK's own way -- a point, then a change of Region.Kind, hung off an area -- and on that path there was nowhere to put one, so every hot and cold spot made that way measured a single pixel with nothing to say so. The getter reads through to the region itself, so a region this object did not build reports the aperture it is actually measuring with.
public BlobDetection BlobDetection { get; set; }
Blob detection settings for a RegionKind.BlobGroup region.
- Throws
ObjectDisposedException: The region has been disposed.
Meaningful only on a RegionKind.BlobGroup; on any other kind the settings are stored, saved and ignored. Setting them does not change Region.Kind -- a region's kind is the caller's decision and not something a setter should infer. The getter reads through to the region itself, so a region this object did not build reports what it actually carries.
public Vector2 Centre { get; set; }
Where the region sits, in region coordinates.
- Throws
ObjectDisposedException: The region has been disposed.
public bool ComputePercentiles { get; set; }
Compute percentiles, including RegionStats.Median, as well as the base statistics.
- Throws
ObjectDisposedException: The region has been disposed.
public float Emissivity { get; set; }
Measure this region at its own emissivity rather than the camera's.
- Throws
ObjectDisposedException: The region has been disposed.
The region's minimum, maximum, mean, median and standard deviation are all reported at this emissivity. It needs a characteristic curve to resolve against, and where that comes from depends on the source:
- a camera answers from the pipeline behind it, a real one and a simulated one alike, because a simulated camera runs a real pipeline on a synthetic calibration;
- a replay and a still answer from the curve their file carries, which recordings and snapshots have written since v12;
- a file written without one has nothing to resolve against and reports at the emissivity the data already carries.
Whether the value reached the picture as well as the numbers is a separate question, and ThermalCamera.GetRegionEmissivityState(…) is what answers it; never assume from the kind of source.
public bool IsEnabled { get; set; }
Whether the region is measured at all.
- Throws
ObjectDisposedException: The region has been disposed.
A disabled region keeps its identity and its rules but is not measured, and its statistics report RegionStats.IsValid false.
public bool KeepSamples { get; set; }
Keep the individual pixel readings, so ThermalCamera.ReadRegionSamples(…) can return them -- the temperature profile along a line region.
- Throws
ObjectDisposedException: The region has been disposed.
Honoured by RegionKind.Area and RegionKind.BlobGroup regions -- which is what Region.Line(…) builds -- and, since API version 12, by the point kinds as well. On a point kind the samples are the Region.Aperture's clipped set, in scan order, with RegionSample.Position NaN because a point has no distance-along. That is the only way to learn which pixels the aperture reached rather than how many, and it is what makes RegionStats.Coverage checkable.
public RegionKind Kind { get; set; }
What the region is for.
- Throws
ObjectDisposedException: The region has been disposed.
Read through to the region itself, so a region this object did not build -- one from Region.Spot(…), or one read back with ThermalCamera.GetRegion(…) -- reports what it is rather than what was last written through this property.
public string Name { get; set; }
A name for the region, used by ThermalCamera.GetRegionId(…).
- Throws
ObjectDisposedException: The region has been disposed.
Names need not be unique, but lookup returns the first match, so unique ones are easier to live with.
public float Rotation { get; set; }
The region's rotation about its centre, anticlockwise, in radians.
- Throws
ObjectDisposedException: The region has been disposed.
public SpotSearchMode SearchMode { get; set; }
Whether a tracked spot searches over aperture averages or over single pixels.
- Throws
ObjectDisposedException: The region has been disposed.
See SpotSearchMode. Defaults to SpotSearchMode.Aperture. With ApertureShape.Pixel the two modes are identical, so a spot that was never given a size is unaffected. Honoured by RegionKind.HotSpot and RegionKind.ColdSpot; stored and ignored on every other kind.
public SpotSearchRange SearchRange { get; set; }
Confine a tracked spot's search to a temperature band, so a reflection cannot take the spot.
- Throws
ObjectDisposedException: The region has been disposed.
See SpotSearchRange. Off by default. Honoured by RegionKind.HotSpot and RegionKind.ColdSpot; stored, saved and ignored on every other kind. Setting it does not change Region.Kind. The getter reads through to the region itself.
public Vector2 Size { get; set; }
How large the region is, in region coordinates.
- Throws
ObjectDisposedException: The region has been disposed.
Setting this keeps the centre and rotation.
public RegionStyle Style { get; set; }
How the region is drawn in the overlay.
- Throws
ObjectDisposedException: The region has been disposed.
See RegionStyle. The style does not change what the region measures. The getter reads through to the region itself, so a region this object did not build reports what it actually carries. Before API version 33 the style did not cross the C ABI at all, so every region added from.NET drew with the defaults and a hot spot was indistinguishable from a cold spot in the picture.
public RegionThreshold Threshold { get; set; }
Count this region's pixels past a limit, as well as measuring them.
- Throws
ObjectDisposedException: The region has been disposed.
Off by default. Honoured by every kind that measures pixels, including the point kinds, where it describes the aperture. The getter reads through to the region itself, so a region this object did not build reports what it actually carries.
Region: methods
public static Region Circle(Vector2 centre, float radius)
A circle.
centre: Its centre, in region coordinates.radius: Its radius, in region coordinates.
Returns: A region you own and should dispose.
Because region coordinates are isotropic, this is a true circle in pixels at any sensor resolution.
Example
using var region = Region.Circle(new Vector2(0.5f, 0.375f), 0.1f);
public static Region ClosedSpline(ReadOnlySpan<Vector2> points)
A closed curve through points. Do not repeat the first point; this appends it.
points: At least three control points, in region coordinates.
Returns: A region you own and should dispose.
- Throws
SdkConfigurationException: Fewer than three control points were given.
Region.Spline(…) with closure settled: it measures the pixels it encloses, as a polygon does.
Example
using var region = Region.ClosedSpline([ new Vector2(0.4f, 0.3f), new Vector2(0.6f, 0.3f), new Vector2(0.5f, 0.5f), ]);
public Region CopyToCanvas(Placement 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. One that should stay put on the canvas while the picture moves under it needs no mapping; that is what a canvas region already is.
A singular placement is accepted here, unlike Region.CopyToFrame(…). This direction uses the forward transform, which is defined even at zoom 0: the region simply collapses, measured as centre (0, 0). Only the inverse direction has nothing to answer.
public Region CopyToFrame(Placement placement)
This region, mapped back through placement into the frame.
- Throws
SdkConfigurationException: 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 withRegion.CopyToCanvas(…), which accepts one.
The inverse of Region.CopyToCanvas(…), and the direction the SDK itself takes every time it measures a canvas region.
public void Dispose()
Release the region's native memory.
A region already added to a camera was copied there, so disposing this does not remove it. Use ThermalCamera.RemoveRegion(…) for that.
public static Region Ellipse(Vector2 centre, Vector2 radii, float rotation = 0)
An ellipse.
centre: Its centre, in region coordinates.radii: Its semi-axes.rotation: Anticlockwise rotation about the centre, in radians.
Returns: A region you own and should dispose.
Example
using var region = Region.Ellipse(new Vector2(0.5f, 0.375f), new Vector2(0.2f, 0.1f), rotation: MathF.PI / 4);
public IReadOnlyList<RegionShape> GetShapes()
The placed shapes this region's geometry is built from, in tree order.
Returns: Its shapes, which may be empty.
- Throws
ObjectDisposedException: The region has been disposed.
One for every region the factory methods build except Region.Ring(…), which is a circle with a smaller circle subtracted and has two. The ABI had getters for centre, size and rotation only, all describing the first shape, so a polygon and an ellipse of the same bounding box were indistinguishable and a polygon's vertices were unreachable.
public static Region Line(Vector2 from, Vector2 to)
A line segment, measured along its length.
from: One end, in region coordinates.to: The other end.
Returns: A region you own and should dispose.
Example
using var region = Region.Line(new Vector2(0.2f, 0.3f), new Vector2(0.8f, 0.3f));
public static Region Polygon(ReadOnlySpan<Vector2> points)
A closed polygon.
points: At least three vertices, in region coordinates.
Returns: A region you own and should dispose.
- Throws
SdkConfigurationException: Fewer than three vertices were given.
Example
using var region = Region.Polygon([ new Vector2(0.4f, 0.3f), new Vector2(0.6f, 0.3f), new Vector2(0.5f, 0.5f), ]);
public IReadOnlyList<Vector2> ReadShapeCurve(int shapeIndex)
The drawable curve of one RegionPrimitive.Spline shape, in region coordinates.
shapeIndex: Which shape, indexingRegion.GetShapes.
Returns: The curve's points, which may be empty.
- Throws
ObjectDisposedException: The region has been disposed.
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 Region.ReadShapePoints(…) reports a polygon's outline in. Empty, and not an error, for any other primitive.
public IReadOnlyList<Vector2> ReadShapePoints(int shapeIndex)
The explicit points of one shape, in region coordinates: a RegionPrimitive.Polygon's vertices, or a RegionPrimitive.Spline's control points.
shapeIndex: Which shape, indexingRegion.GetShapes.
Returns: Its vertices, which may be empty.
- Throws
ObjectDisposedException: The region has been disposed.
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, and not an error, for any other primitive.
For a 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 Region.ReadShapeCurve(…). A closed spline's last control point repeats its first, visibly, because that repeat is what closes it.
public static Region Rect(Vector2 centre, Vector2 size, float rotation = 0)
A rectangle.
centre: Its centre, in region coordinates.size: Its width and height.rotation: Anticlockwise rotation about the centre, in radians.
Returns: A region you own and should dispose.
Example
using var region = Region.Rect(new Vector2(0.5f, 0.375f), new Vector2(0.4f, 0.3f));
public static Region Ring(Vector2 centre, float outerRadius, float innerRadius)
A ring: an outer circle with an inner one subtracted.
centre: Its centre, in region coordinates.outerRadius: The outer radius.innerRadius: The inner radius, which must be smaller thanouterRadius.
Returns: A region you own and should dispose.
- Throws
SdkConfigurationException: The inner radius is not smaller than the outer one.
Example
using var region = Region.Ring(new Vector2(0.5f, 0.375f), outerRadius: 0.2f, innerRadius: 0.1f);
public static Region Spline(ReadOnlySpan<Vector2> points)
A curve through points: a centripetal Catmull-Rom spline, which passes through every control point.
points: At least two control points, in region coordinates.
Returns: A region you own and should dispose.
- Throws
SdkConfigurationException: Fewer than two control points were 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 Region.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. Prefer Region.ClosedSpline(…), which appends the repeat, over doing it by hand.
Example
using var region = Region.Spline([ new Vector2(0.2f, 0.3f), new Vector2(0.4f, 0.2f), new Vector2(0.6f, 0.4f), ]);
public static Region Spot(Vector2 at, Nullable<Aperture> aperture = default)
A point measurement.
at: Where, in region coordinates.aperture: The sampling neighbourhood, ornullfor a single pixel. SeeRegion.Aperture-- anything wider changes the reported temperature.
Returns: A region you own and should dispose.
Example
using var probe = Region.Spot(new Vector2(0.5f, 0.375f));