SimulatedCameraOptions
public sealed class SimulatedCameraOptions
What a simulated camera should produce.
Every property has a working default, so ThermalCamera.OpenSimulated() with no arguments gives a usable camera. Set only what matters to the test you are writing.
Some of this describes the device and some describes the scene it points at, and only the scene can change once the camera is open. Fixed for the life of the camera: SimulatedCameraOptions.DeviceType, SimulatedCameraOptions.Width, SimulatedCameraOptions.Height, SimulatedCameraOptions.FrameRate, SimulatedCameraOptions.Serial, SimulatedCameraOptions.Seed and SimulatedCameraOptions.FrameFilePath. Everything else, including SimulatedCameraOptions.FrameCycleSteps, may move while frames are running -- see ThermalCamera.UpdateSimulatedScene(…), which names the offending property and throws rather than quietly keeping the old value.
Example A deterministic camera, for a test that asserts on pixel values:
var options = new SimulatedCameraOptions { Width = 64, Height = 48, FrameRate = 64, Pattern = TestPattern.Gradient, MinTemperature = 20.0f, MaxTemperature = 40.0f, Seed = 1, // same frames every run }; await using var camera = ThermalCamera.OpenSimulated(options);
SimulatedCameraOptions: constructors
public SimulatedCameraOptions()
SimulatedCameraOptions: constants
public const int MaxFrameCycleSteps = 8
The most temperatures a TestPattern.FrameCycle can step through. Past this, two neighbouring steps come too close in colour to tell apart by eye, which is how the pattern is read.
public const int MinFrameCycleSteps = 2
The fewest temperatures a TestPattern.FrameCycle can step through.
SimulatedCameraOptions: properties
public int CheckerSize { get; set; }
Block size of a TestPattern.Checkerboard, in pixels.
public DeviceType DeviceType { get; set; }
The model to impersonate, which sets the default resolution.
public TimeSpan FlagDuration { get; set; }
How long the simulated shutter stays closed.
public TimeSpan FlagInterval { get; set; }
How often the simulated shutter closes.
Set this to exercise code that watches the shutter through ThermalCamera.OnShutterState(…): the simulated camera runs the same sequence of states a real one does, starting with the shutter reporting open as the first frames arrive rather than only once the first cycle comes round.
The simulated camera keeps delivering frames while its shutter is closed, with FrameMetadata.IsFlagOpen false, and so does a real one, which is what makes this a usable stand-in for the frame-flag path as well as the notification. This note used to read "a real camera does not: it withholds them … that code will pass here and fail on hardware", which was true when it was written and false since version 12: the SDK now holds the last frame taken with the shutter open and delivers it through the closed window on every source, so the flag reads false there rather than the cycle being a gap.
One difference remains, and it is about the pixels rather than the flag: a real camera delivers the held open-shutter frame again, so its closed-window frames also carry FrameMetadata.IsRepeatedFrame, while the simulated camera produces every frame afresh and leaves that false. Code that counts how often the scene was really measured needs a real camera or a recording to exercise it.
public int FrameCycleSteps { get; set; }
How many temperatures a TestPattern.FrameCycle steps through, from SimulatedCameraOptions.MinFrameCycleSteps to SimulatedCameraOptions.MaxFrameCycleSteps.
A scene property, so it may change while frames are running. The step a frame shows is always its FrameMetadata.Sequence 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 SdkConfigurationException naming frame_cycle_steps -- by ThermalCamera.OpenSimulated(…), ThermalCamera.UpdateSimulatedScene(…) and Sdk.RegisterSimulatedDevice(…), whatever the SimulatedCameraOptions.Pattern, so a value the camera could never draw is refused when it is given.
public string FrameFilePath { get; set; }
Where to read frames from for TestPattern.FromFile.
public int FrameRate { get; set; }
Frames per second.
public GradientDirection GradientDirection { get; set; }
Which way a gradient runs.
public int Height { get; set; }
Frame height in pixels, or zero for the model's own.
public int HotSpotRadius { get; set; }
Radius of a TestPattern.HotSpot, in pixels.
public float HotSpotSpeed { get; set; }
How fast a TestPattern.HotSpot travels its path. Not pixels per second.
It scales an angular rate. The spot wanders about the frame centre by 2 * HotSpotRadius pixels on each axis, horizontally as cos(0.1 * HotSpotSpeed * t) and vertically as sin(0.13 * HotSpotSpeed * t) for t in seconds. So it changes how long a lap takes and never how far the spot goes, and the two rates differ, so the path is not a circle.
Zero is the only way to hold the spot still from.NET, and it parks it 2 * HotSpotRadius to the right of centre rather than at it. This said "in pixels per second" until it was measured.
public float MaxTemperature { get; set; }
The warmest temperature in the scene, in the SDK's temperature unit when the camera is opened.
public float MinTemperature { get; set; }
The coolest temperature in the scene, in the SDK's temperature unit (Celsius unless Sdk.TemperatureUnit chose Fahrenheit) when the camera is opened.
public TestPattern Pattern { get; set; }
The scene to generate.
public ulong Seed { get; set; }
The generator's seed, so a run is reproducible.
public string Serial { get; set; }
The serial number the camera should report.
public int Width { get; set; }
Frame width in pixels, or zero for the model's own.