OptrisOptrisDocumentation

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

optris::sdk::SimulatedConfig

Configuration for creating a simulated imager.

Some of this describes the device -- what it is and what shape its frames are -- and some describes the scene it points at. Only the scene can change once the camera is open; see Imager::UpdateSimulatedScene(), which names the offending field and throws rather than quietly keeping the old value.

Fixed for the life of the camera: device_type, width, height, framerate, serial, seed and frame_file_path. Each is marked below. They are fixed for reasons, not for tidiness: the frame dimensions size buffers a caller may still be holding, framerate sets the frame clock and the time base a moving hot spot is drawn against, seed is a reproducibility promise that re-seeding would break, and device_type and serial are the camera's identity -- an open handle that changed either would be a different camera.

Everything else is scene and may change while frames are running: pattern, gradient_direction, temp_min_c, temp_max_c, flag_interval_s, flag_duration_s, checker_size, hotspot_radius, hotspot_speed, hotspot_position and frame_cycle_steps.

So a user interface offering "model" and "frame rate" alongside the scene controls still has to close and reopen for those two. It now gets told so, which is the point: the previous shape accepted every field at open time and offered no way to change any of them, and the failure mode being designed away here is a setter that appears to work and does nothing.

temp_min_c and temp_max_c are in the SDK's temperature unit (Celsius unless SetTemperatureUnit() chose Fahrenheit). Their defaults, 20 and 40, are compile-time Celsius numbers, so in Fahrenheit a default-constructed SimulatedConfig asks for a 20..40 F scene. Set both, or start from Imager::GetSimulatedOptions() on an open simulated camera.

Public attributes

device_type

DeviceType device_type = DeviceType::kPi160

Simulated device type (determines default resolution).

FIXED once the camera is open: it is the camera's identity, and it chooses the default resolution.

width

uint32_t width = 0

Frame width in pixels (0 = use device type default).

FIXED once the camera is open: it sizes every frame buffer.

height

uint32_t height = 0

Frame height in pixels (0 = use device type default).

FIXED once the camera is open: it sizes every frame buffer.

framerate

uint32_t framerate = 32

Frame rate in Hz.

FIXED once the camera is open: it is the frame clock, and it is the time base a moving hot spot is drawn against, so changing it mid-run would make the spot jump.

Evenly spaced up to about 500 Hz; above that the spacing is a property of the host, not of this setting. Any rate is accepted and the number of frames per second is delivered at every rate the machine can actually draw that many frames at, because the frame loop makes up frames it owes rather than dropping them. On the count there is a second ceiling, and it belongs to the machine rather than to this setting; it is described below the spacing one. The gaps between them are another matter: the loop waits for each frame's due time, and no operating system honours a deadline perfectly. Once the frame period approaches how precisely the host can wake, frames begin to arrive in bursts -- several together, then a gap -- while the average stays exactly right.

Measured: at 500 Hz and below, on Windows and on Linux, essentially no gap is shorter than half a frame period. At 1000 Hz on Windows between 5% and 27% of the gaps are, because the most precise timer that platform offers still wakes 0.6 to 0.8 ms late and a frame period there is 1.0 ms. Linux measures 1.4% at the same rate.

So above 500 Hz, do not measure the simulated camera's own frame spacing and expect it to mean anything; for a chart, a log or a jitter measurement, use 500 Hz or less.

The frame count has its own ceiling: whether the machine can draw that many frames a second at all. Below it, counting frames and timing a whole run are unaffected by any of the spacing above. Above it the camera delivers what the machine can manage and no more, which is fewer frames than the rate asked for. Nothing is dropped and no sequence number is skipped; the frames are simply never drawn, because no loop can generate them faster than the processor computes them.

Where that ceiling sits is a property of the host and of the pattern, so it has to be measured and not assumed. Two measurements for scale, both on the cheapest pattern (TestPattern::kUniform) on a simulated PI 160: a 14-core Windows desktop holds 99% of the request at 250 Hz and 500 Hz even with 56 busy loops on it, and falls to 52% of the request at 1000 Hz under that load; a smaller continuous-integration agent measured about 213 Hz for a requested 500. A bigger frame, a costlier pattern or a busier machine all lower it.

Ask the SDK rather than assuming the rate was honoured: Processing::RealFrameRate() reports measured_hz and delivered_hz for the stream that actually arrived. Compare the one you care about against this setting before concluding anything from a count, and prefer a rate with margin if the run has to deliver a known number of frames.

pattern

TestPattern pattern = TestPattern::kGradient

Test pattern to generate.

gradient_direction

GradientDirection gradient_direction = GradientDirection::kHorizontal

Direction for kGradient pattern.

temp_min_c

float temp_min_c = 20.0f

Minimum temperature for pattern generation, in the SDK's temperature unit.

temp_max_c

float temp_max_c = 40.0f

Maximum temperature for pattern generation, in the SDK's temperature unit.

serial

std::string serial = "9990001"

Simulated serial number.

FIXED once the camera is open: it is what the camera is called, and what a registered device is looked up by.

seed

uint64_t seed = 1

RNG seed for deterministic output (0 = random).

FIXED once the camera is open. This field exists to make a run reproducible, and re-seeding midway through one destroys exactly the property it is there to provide: the frames before and after the change would belong to two different sequences, and neither seed would reproduce what the camera actually emitted.

flag_interval_s

float flag_interval_s = 0.0f

Flag cycle interval in seconds (0 = no flag cycles).

flag_duration_s

float flag_duration_s = 0.5f

Flag close duration in seconds.

checker_size

uint32_t checker_size = 8

Checkerboard block size in pixels.

hotspot_radius

uint32_t hotspot_radius = 10

Hot spot radius in pixels.

hotspot_speed

float hotspot_speed = 20.0f

How fast the hot spot travels its path. Not pixels per second, which this said until it was measured.

It is a scale on an angular rate. The centre wanders about the frame centre by 2 * hotspot_radius pixels on each axis, horizontally as cos(0.1 * hotspot_speed * t) and vertically as sin(0.13 * hotspot_speed * t) for t in seconds of frame time. So this changes how long a lap takes and never how far the spot travels, the two rates differ so the path is not a circle, and zero parks the spot 2 * hotspot_radius to the right of centre rather than at it.

Ignored while hotspot_position is set -- a pinned spot does not move.

frame_cycle_steps

uint32_t frame_cycle_steps = 4

How many temperatures TestPattern::kFrameCycle steps through, from kFrameCycleMinSteps (2) to kFrameCycleMaxSteps (8). Zero means the default, 4, the way zero means the default for width, framerate and checker_size, and Imager::GetSimulatedOptions() reports the 4 rather than the zero.

Scene field: it may change while the camera runs. The step a frame shows is always its sequence number modulo this, so a change lands on whichever step the running sequence gives rather than starting the cycle again.

Any other value is refused with ConfigException naming this field, by Imager::Create(), Imager::UpdateSimulatedScene() and RegisterSimulatedDevice() -- whatever the pattern, so a value the camera could never draw is refused when it is given rather than later, when somebody switches to the pattern that would draw it.

raw_detector

RawDetector raw_detector

The raw-detector mode described above. Off unless raw_detector.enabled is set.

hotspot_position

std::optional< std::array< float, 2 > > hotspot_position

Where to pin the hot spot, or empty to let it move on its own.

Coordinates are frame-normalized isotropic, the same space measuring regions use (see region.h): x runs 0..1 and y runs 0..height/width. Normalized rather than pixels because the resolution is not known to a caller who left width at 0, and because the point of placing the spot is to put it inside a region -- which is expressed in exactly these coordinates, so "put the spot in this region" needs no arithmetic.

Scene field: it may be set, moved and cleared while the camera is running. That is what makes alarm behaviour drivable rather than something to wait for -- a test can place the spot, assert the alarm raised, move it away and assert it cleared, deterministically and in a fraction of a second.

frame_file_path

std::string frame_file_path

Path for kFromFile pattern.

FIXED once the camera is open: the file is read when the camera is created, and its header carries the frame dimensions, so a new path is a resolution change wearing a different hat.

A camera created without a file therefore cannot be switched to TestPattern::kFromFile later; it has nothing to read. That is refused rather than silently producing a uniform field.