Apertures and Spots
A point region has no area, so what it measures is decided entirely by its aperture. This page is that mechanism: setting one, seeing what it did, where a spot's emissivity applies, what a sized spot searches for, and how to confine the search.
In Fahrenheit: with the SDK switched to Fahrenheit (SetTemperatureUnit() and its counterparts, see Temperatures in Fahrenheit), every temperature on this page is read and written in Fahrenheit, and every difference in Fahrenheit degrees; the samples are unchanged.
The region chapter is four pages, each answering one question, and the worked examples are a fifth: Region Examples.
| Page | Question |
|---|---|
| Regions | What is a region, what kinds are there, and what do its coordinates mean? |
| Region Shapes | How do I define, compose and edit the shape? |
| Apertures and Spots | What exactly is a spot looking at, and where does its emissivity apply? |
| Region Statistics | What comes back, and how do I read it per frame? |
On this page
Sampling apertures
A point region can average a small neighbourhood instead of trusting one pixel. A single pixel is noisy, and averaging is usually what an operator wants.
optris::sdk::Aperture aperture; aperture.shape = optris::sdk::ApertureShape::kSquare; // or kCircle, kPixel aperture.radius_px = 2.0f; // 5x5 aperture.min_coverage = 0.25f; auto spot = Region::Spot({0.5f, 0.375f}, aperture);
optris_sdk_vec2 at = {0.5F, 0.375F}; optris_sdk_aperture aperture; optris_sdk_region *spot = NULL; optris_sdk_aperture_init(&aperture, sizeof(aperture)); aperture.shape = OPTRIS_SDK_APERTURE_SQUARE; /* or CIRCLE, PIXEL */ aperture.radius_px = 2.0F; /* 5x5 */ aperture.min_coverage = 0.25F; optris_sdk_region_create_spot(at, &aperture, &spot);
var aperture = new Aperture(ApertureShape.Square, // or Circle, Pixel radiusPixels: 2.0f, // 5x5 minimumCoverage: 0.25f); using Region spot = Region.Spot(new Vector2(0.5f, 0.375f), aperture);
aperture = optris_sdk.Aperture( shape=optris_sdk.APERTURE_SQUARE, # or APERTURE_CIRCLE, _PIXEL radius_px=2.0, # 5x5 min_coverage=0.25) spot = optris_sdk.Region.spot((0.5, 0.375), aperture)
let mut aperture = Aperture::square(2.0); // 5x5; also circle, new aperture.min_coverage = 0.25; let spot = Region::spot((0.5, 0.375), Some(aperture))?;
Warning: This changes the temperature the camera reports. The rule below is public behaviour, not an implementation detail.
- The aperture is evaluated in image space and axis-aligned. It is never transformed by the region's matrix, so it is never sheared and never elliptical.
- It is clipped to the owning region's geometry and to the image bounds. A hot spot sitting on a sharp polygon corner averages only the pixels that are actually inside the region, and never pixels from outside it.
RegionStats::coveragereportssampled / nominal. A corner sample is therefore visibly noisier than a centre sample rather than quietly wrong: a 5×5 aperture clipped to 9 pixels reports 0.36.- Below
min_coveragethe sample is marked invalid (RegionStats::valid == false) and any rule watching it goeskOrphanedrather than alarming on two pixels.
The same rule covers a point near the image border, with no extra machinery.
The alternatives were considered and rejected: eroding the parent by the aperture radius makes a genuine corner hot spot unreachable, and letting the aperture stick out measures outside the region. Points default to kPixel, so nothing changes unless a window is asked for.
Setting one, and seeing what it did
Region::aperture is a field, so C++ has always been able to set it on any region at any time. Through the C ABI and the bindings it could only be attached at construction, by optris_sdk_region_create_spot(), and a tracked spot is not built that way. The two documented routes to one are create a point, change its kind and add a geometry-less child, change its kind, and neither had anywhere to put an aperture. Every hot and cold spot built the documented way measured a single pixel, and nothing said so. optris_sdk_region_set_aperture() and optris_sdk_region_get_aperture() close that, additively, at API version 12.
Three numbers make "the size applies" checkable rather than something to take on trust:
| what it answers | |
|---|---|
NominalApertureCount(aperture) |
how many pixels were asked for: 9 for a square of radius 1, 25 for radius 2, 13 for a circle of radius 2 |
Region::samples.size() |
how many survived clipping to the parent and to the image |
RegionStats::pixel_count |
how many of those were measurable |
RegionStats::coverage is the third divided by the first, so a spot that lands on a corner reads 0.36 and the sample list says which nine pixels those were. Set Region::want_samples on a point kind to get them; they arrive in scan order with position NaN, because a point has no distance-along. They survive the min_coverage cut, exactly as pixel_count and coverage do; a sample list is the evidence for why a reading was refused.
RegionStyle::show_aperture draws them: one box per sampled pixel, under the marker, in the region's own colour. Off by default, and it draws the clipped set rather than a (2r+1) box around the marker, which is the whole point, because those two differ exactly when it matters. It needs want_samples; without it nothing is drawn rather than a nominal window the region never measured.
Saying so on the label
An operator looking at a measuring area has no way to tell from the picture that it is being read at a different emissivity from everything around it, and a wrong emissivity silently in force is a measurement error rather than a cosmetic one. Region::emissivity_state is what a label draws to say so, and EmissivityStateOf() is the one definition of the rule so that a label, a display and a test cannot each decide it differently.
RegionEmissivityState |
when | what it means for the picture |
|---|---|---|
kCameras |
not set, equal to the camera's, or the region is not measured | nothing to show |
kOwnValue |
set and differing | the pixels carry it too |
kReadingOnly |
differing, but emissivity_affects_image is off, the value is under 0.1, or the source is a recording or a still (no pipeline) |
the picture is on the camera's value |
kOwnScale |
differing, and emissivity_own_scale is on |
the colours inside the outline no longer mean what the scale bar says |
Differing, not merely set. A region whose emissivity equals the camera's measures identically either way, so it reports kCameras; a display that marked every region would be saying nothing. The comparison is against the emissivity the frame was corrected at, published from the frame's own metadata, not the value currently configured. The two differ on a replayed recording and for a frame or two after a settings change, and a badge compared against the wrong one would flicker for no reason an operator can see. That is why Imager fills this in after measuring rather than RegionStore doing it: a standalone store has no radiation parameters and leaves it at kCameras, which is the honest answer when nothing said otherwise.
kLabel regions and disabled regions are never measured, so neither has an emissivity that means anything and both report kCameras.
A gap reported rather than hidden. The measuring pass honours Region::emissivity from 0.01 up (kMinRegionEmissivity); the image paths only from 0.1. A region set between the two moves its numbers and not its pixels. That has always been true and was invisible; it now reads as kReadingOnly, which is exactly what it is. Whether the two floors should be the same number is a separate question with a measurement change attached to it.
What a display should draw
The SDK renders no text, so this is a recommendation rather than a rule, and the v12 demo is the worked example. It appends e0.60 in the common case: short enough to sit beside a name and a reading on a small camera pane, and carrying the number rather than only the fact, because "which emissivity" is the next question anybody asks. The two unusual states spend more width (e0.60 numbers only, e0.60 own scale), and that is the right way round: they are rare, and each is a case where the picture does not mean what a reader would assume.
Where a spot's emissivity applies
Region::emissivity reaches two places beyond the statistics: the per-pixel emissivity map either pipeline (GPU or CPU) applies while converting energy to temperature, and the own-scale shading that recolours a corrected region on its own range. For a point kind, both use ApertureFootprint(), the same loop and the same clipping rule the measuring pass runs, so the pixels corrected are exactly the pixels the reading was computed over. ApertureCentreOf() says where the aperture sits: a kSpot is at its own centre and is there before the first frame; a tracked spot is at tracked_loc and paints nothing until it has been measured once, because painting it where it was declared would put a patch of foreign emissivity somewhere it may never go.
HasCustomRegionEmissivity() now also ignores disabled regions and kLabel, for the same reason: a region that arms the map and paints nothing is a region whose emissivity is applied nowhere.
What a sized spot is looking for
A hot spot with an aperture has two defensible readings, and they are different measurements. Region::search_mode picks between them:
| what it finds | what it answers | |
|---|---|---|
SpotSearchMode::kAperture (default) |
the position whose aperture average is the extreme | "where is the hottest patch of this size" |
SpotSearchMode::kPixel |
the single extreme pixel, then averages the aperture around it | "how warm is the neighbourhood of the hottest point" |
They differ exactly when the hottest pixel is not in the hottest neighbourhood: a noise spike, an element reading high, a glinting edge. Reported from the field against a heater: the spot sat on a lone spike instead of on the object. Observed on that scene in miniature (a 9×9 block at 60 °C, one isolated pixel at 200 °C, a 5×5 aperture): kPixel reports 27.2 °C and kAperture reports 60.0 °C.
With ApertureShape::kPixel the two modes are identical (the average over one pixel is that pixel), so a spot that was never given a size reads exactly what it always read, whichever mode it is in. That is a test, not an assumption: SpotSearchMode.ASinglePixelApertureMakesTheModesIdentical.
A window that fits beats a clipped one
Candidate positions near the region's edge have their aperture clipped, and a clipped mean is not comparable with a whole one; it drops its own pixels. On a plain gradient the window hanging off the warm edge therefore reads hotter than every window that fits, every frame, wherever the heat actually is, and the spot would live in the corner of the region.
So a window that fits wins, whatever the means say. Only when no position has a whole window does a clipped one count, and then it must still clear Aperture::min_coverage. PIX Connect took the first half of that rule and stopped; it accepted a position only when all W×H pixels were valid (OpSpot.cpp, M == SpotSearchSize) and otherwise reported nothing. Reporting nothing is not viable here, because a region drawn tightly around its object is smaller than a generous aperture more often than not.
What PIX Connect did, and where this differs
PIX Connect also searched over windows: OpSpot::Processing ran separable running sums over W and H, took the maximum of the window mean, and placed the area at the window's top-left plus (W/2, H/2). For comparing numbers during a migration:
- PIX Connect's search was rectangles only. The UI refused to let an ellipse, polygon or spline be a hot spot at all. A circular aperture searching as a disc is new here, and is what a user of that UI expects.
- Its 1×1 case was a plain per-pixel maximum, on a separate fast path. Ours reduces to the same thing by arithmetic rather than by a special case.
- Its displayed value was the maximum pixel inside the winning window, because ticking the hot-spot box forced the area's mode to Max. Ours reports the aperture average as
mean_c, withmax_calongside it, so a number-for-number comparison with PIX Connect should useRegionStats::max_c, and the mean will read lower. - Its search covered the whole image minus a separate exclude-area list. Ours searches the parent region, which is the model this SDK settled on.
- It updated the spot every third frame, splitting the three passes across frames unless the pixel rate was low enough. Ours runs every frame.
- Its score was an integer mean, truncated, so ties were common; ours is a float mean and ties are rare. Where there is a tie, ours is settled by the candidate's own pixel rather than by raster order, so a lone warm pixel puts the marker on it instead of parking it in the corner of one of the nine windows containing it.
Cost
The search is candidates × bands, where a band is a run of aperture rows spanning the same columns: a square is one band whatever its radius, a radius-12 disc is nine. Measured here, 24 cores, Release, per frame, against the single-pixel search on the same scene:
| scene | kPixel |
kAperture |
|---|---|---|
| 640×480 whole frame, square r=2, 5 or 12 | 15.7 ms | 18.2 ms |
| 640×480 whole frame, circle r=12 | 15.6 ms | 30.0 ms |
| 640×480, area 160×120, square r=5 | 0.68 ms | 0.83 ms |
| Xi 80 whole frame, square r=5 | 0.34 ms | 0.38 ms |
Past a budget the search declines and falls back to the single-pixel one (a coarser answer, not a wrong one) rather than letting the frame thread be the thing that breaks.
The correction, and why this mode pays for it
kPixel searches the uncorrected frame deliberately: a monotonic correction cannot change which pixel is the hottest. That argument does not survive the move to neighbourhoods: the mean of a monotonic map is not the monotonic map of the mean, so a per-region emissivity really can change which patch wins. kAperture therefore applies Region::emissivity before it scores, at one resolver lookup per pixel of the parent, and only for a region that set one. Without a per-region emissivity the correction is a pass-through and this is the raw frame exactly as before.
Confining the search to a band
A hot spot follows the warmest pixel, and the warmest pixel is often not the subject: a sun glint off a rail, a reflection in a polished flange, a heater behind the thing being watched. Region::search_range is a temperature band the search is confined to, so "the hottest pixel between 40 and 80 °C" is expressible.
optris::sdk::Region hot; hot.kind = optris::sdk::RegionKind::kHotSpot; hot.search_range.enabled = true; hot.search_range.min_c = 40.0F; // inclusive hot.search_range.max_c = 80.0F; // inclusive
optris_sdk_vec2 anywhere = {0.5F, 0.375F}; optris_sdk_spot_search_range band; optris_sdk_region *hot = NULL; optris_sdk_region_create_spot(anywhere, NULL, &hot); optris_sdk_region_set_kind(hot, OPTRIS_SDK_REGION_HOT_SPOT); optris_sdk_spot_search_range_init(&band, sizeof(band)); band.enabled = 1; band.min_c = 40.0F; /* inclusive */ band.max_c = 80.0F; /* inclusive */ optris_sdk_region_set_search_range(hot, &band);
using Region hot = Region.Spot(new Vector2(0.5f, 0.375f)); hot.Kind = RegionKind.HotSpot; hot.SearchRange = new SpotSearchRange(minimumC: 40.0f, // inclusive maximumC: 80.0f); // inclusive
hot = optris_sdk.Region.spot((0.5, 0.375)) hot.kind = optris_sdk.HOT_SPOT hot.search_range = optris_sdk.SpotSearchRange(min_c=40.0, # inclusive max_c=80.0) # inclusive
let mut hot = Region::spot((0.5, 0.375), None)?; hot.set_kind(RegionKind::HotSpot)?; // Inclusive at both ends. hot.set_search_range(SpotSearchRange::band(40.0, 80.0))?;
The band constrains the search, not the sample. Once the pixel is found, the aperture around it is averaged whole, neighbours outside the band included. The two settings answer different questions: where to measure, and what the measurement is over. Filtering the aperture as well would report the mean of a hand-picked subset of its own window.
When nothing in the parent falls inside the band the spot has found nothing and says so: valid false, NaN temperatures, and a rule on it goes kOrphaned. It deliberately does not fall back to the unbanded extreme, which would be the reflection again. A band the wrong way round admits nothing, and is reported that way rather than silently swapped.
The band is read against the frame as the camera reports it, before Region::emissivity is applied, which is what makes it affordable, and which cannot change which pixel is the extreme because the correction is monotonic. A fixed bound is different: a region with its own emissivity can have pixels move across min_c or max_c. Write the band in the numbers the display shows.
Off by default, honoured by kHotSpot and kColdSpot, stored and ignored on every other kind, the same contract BlobConfig has.