OptrisOptrisDocumentation

Documentation/OTC SDK/Optris.Sdk — C# API referencev12.0

RegionStats

public readonly struct RegionStats

One region's measurement for one frame.

Check RegionStats.IsValid before using the temperatures. A region that has not been measured yet -- because the camera is not streaming, or because it is disabled -- reports invalid rather than zeroes that look like a real reading.

You can build one. Every property has an init accessor, so an object initialiser makes the reading a test or a fake camera needs without a camera and without the native library since version 12. Before that the only constructor was internal, so a consumer could hold nothing but default(RegionStats) -- all zeroes -- and a test of code that maps these values could only assert that zero maps to zero.

A hand-built one is not checked against the invariants the SDK's own readings keep: it is a value, not a measurement. The SDK reports Single.NaN temperatures and RegionStats.MinimumLocation equal to RegionStats.Centre when RegionStats.IsValid is false, and a fake that means to stand in for a real reading should do the same.

The SDK's readings are in its temperature unit (Celsius unless Sdk.TemperatureUnit chose Fahrenheit) as it was when they were read: the four temperatures as temperatures, and RegionStats.StandardDeviation as a difference in degrees of that unit.

Example

var stats = new RegionStats
{
    Minimum = 19.5f,
    Maximum = 84.25f,
    Mean = 41.0f,
    MinimumLocation = new Vector2(0.10f, 0.20f),
    MaximumLocation = new Vector2(0.80f, 0.55f),
    Centre = new Vector2(0.50f, 0.375f),
    PixelCount = 1024,
    Coverage = 1.0f,
    IsValid = true,
};

RegionStats: properties

public Vector2 Centre { get; init; }

The region's centre, in region coordinates.

public float Coverage { get; init; }

Pixels actually measured divided by pixels the region nominally covers.

One when everything the region asked for had sensor behind it, which is the ordinary case. Below one when part of it did not: an aperture clipped by the region boundary or the image edge, a region hanging off the sensor, or a pixel the SDK could not measure (the border radial distortion correction leaves in Wide mode, which is 15.8 per cent of the field on a G7). The statistics are computed over the measured part only, so this is what separates "20 degrees across this region" from "20 degrees across the 30 per cent of it that had data".

public bool IsValid { get; init; }

Whether the numbers above mean anything.

False for a region with no measurable pixels, one below its aperture's minimum coverage, or one that has not been measured yet. The temperatures are then Single.NaN, so code that forgets to test this gets a blank rather than a plausible reading; every comparison against NaN is false.

public float Maximum { get; init; }

The warmest temperature in the region, in the SDK's temperature unit. Single.NaN when RegionStats.IsValid is false.

public Vector2 MaximumLocation { get; init; }

Where the warmest pixel is, in region coordinates.

Equal to RegionStats.Centre when RegionStats.IsValid is false, for the same reason as RegionStats.MinimumLocation.

public float Mean { get; init; }

The mean temperature over the region, in the SDK's temperature unit. Single.NaN when RegionStats.IsValid is false.

public float Median { get; init; }

The median temperature, in the SDK's temperature unit.

Zero (Single.NaN in Fahrenheit, where a zero would read as 32 F) unless the region was created with percentiles enabled, because computing it costs extra work on every frame.

public float Minimum { get; init; }

The coolest temperature in the region, in the SDK's temperature unit. Single.NaN when RegionStats.IsValid is false.

public Vector2 MinimumLocation { get; init; }

Where the coolest pixel is, in region coordinates.

Equal to RegionStats.Centre when RegionStats.IsValid is false: there is no coolest pixel to point at, and a marker left on the last one found would outlive the reading it belongs to.

public int PixelCount { get; init; }

How many pixels were actually measured.

public float StandardDeviation { get; init; }

The standard deviation of the region's pixels, a difference in degrees of the SDK's temperature unit: kelvin-sized in Celsius, Fahrenheit-sized in Fahrenheit, never offset. Single.NaN when RegionStats.IsValid is false.