OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Rust API referencev12.0

MotionZone

pub struct MotionZone

An area watched for movement, by frame differencing within a temperature band.

The zone publishes what it sees as signals, so an alarm on movement is an ordinary crate::Rule, with delay frames, latching, inhibit sources and actions like any other.

A note on struct_size and the defaults

As ColorWindow: optris_sdk_motion_zone_init is declared (sdk_c.h:3763) and is what fills the field in. The note here used to say it did not exist.

That mattered more than the comment did. Writing the struct by hand meant writing the defaults by hand too, and this crate's had drifted from the SDK's: min_area was 16 against the SDK's 10, and the overlay alpha 0.5 against the SDK's 0.8. Both are measured, and both are what C, C# and Python callers got. MotionZone::new now takes the SDK's, and rust/tests/camera_diagnostics.rs pins them against the initialiser so they cannot drift again.

MotionZone — fields

temp_min_c: f32

Only pixels in this band take part, in the SDK's temperature unit (Celsius unless crate::set_temperature_unit chose Fahrenheit).

A zone watching for people uses roughly 30..40 °C (86..104 °F).

temp_max_c: f32

Upper edge of that band.

sensitivity: f32

How much a pixel must change between consecutive frames to count as moving: an absolute temperature difference, not a 0 to 1 knob, and higher means less sensitive. The test is abs(T_now - T_prev) > sensitivity.

A difference in degrees of the SDK's temperature unit (kelvin-sized in Celsius, Fahrenheit-sized in Fahrenheit). The default, read in that unit by MotionZone::defaults, is 0.5 in Celsius and 0.9 in Fahrenheit, the same threshold: above sensor noise and below a real scene change. Around 0.05 K the zone trips on noise. Not clamped: a negative value marks every in-band pixel as moving, on every frame.

min_area: u32

The smallest blob, in pixels, that counts.

Raising it is how sensor noise is rejected.

visualize: bool

Draw the zone into the colorized picture.

overlay_color: [f32; 4]

The overlay's red, green, blue and alpha, each 0 to 1.

MotionZone — methods

pub fn new(temp_min_c: f32, temp_max_c: f32) -> Self

A zone watching a temperature band, in the SDK's temperature unit, with the SDK's defaults.

Read out of optris_sdk_motion_zone_init rather than written here, so this crate cannot be the one binding that disagrees about what a default zone is -- which it was. The temperature band is the caller's, because there is none that is right for every scene; the SDK leaves it at zero for the same reason, and a zone with a zero band matches nothing.

pub fn defaults() -> Self

The SDK's own defaults, with a zero temperature band (32 to 32 once crate::set_temperature_unit has chosen Fahrenheit: the defaults are read in the unit in force).

Infallible by design: the initialiser fails only on a NULL pointer, which cannot happen here, so a Result would be a case no caller can hit standing in front of a builder chain. A debug_assert catches it in a test build, the same shape crate::SimulatedConfig::new uses.

pub fn with_sensitivity(mut self, sensitivity: f32) -> Self

How much a pixel must change to count as moving: a difference in degrees of the SDK's temperature unit, higher meaning less sensitive. See MotionZone::sensitivity.

pub fn with_min_area(mut self, pixels: u32) -> Self

The smallest blob, in pixels, that counts.

pub fn visualized(mut self, rgba: [f32; 4]) -> Self

Draw the zone into the colorized picture, in this colour.