SimulatedConfig
pub struct SimulatedConfig
How a simulated camera should behave.
A simulated camera needs no hardware and supports everything in this crate that does not require a physical device. It is the supported way to test an integration, and it is what this crate's own test suite runs against.
Examples
use optris_sdk::{Camera, SimulatedConfig, TestPattern};
# fn main() -> optris_sdk::Result<()> {
let config = SimulatedConfig::new()
.pattern(TestPattern::HotSpot)
.temperature_range(20.0, 120.0)
.seed(42);
let camera = Camera::simulated(&config)?;
# Ok(())
# }
SimulatedConfig — methods
pub fn new() -> Self
The SDK's defaults: a PI 160 at its native resolution, 32 Hz, a horizontal gradient from 20 to 40 °C, serial "9990001", seed 1, no flag cycles.
The scene's temperatures are read in the SDK's temperature unit
at the time of this call, so once crate::set_temperature_unit
has chosen Fahrenheit the gradient reads 68 to 104, the same
scene. They are taken in the unit in force when the camera is
opened, so set the unit before building one.
pub fn device_type(mut self, device_type: DeviceType) -> Self
Impersonate a particular model, which sets the default resolution.
pub fn resolution(mut self, width: u32, height: u32) -> Self
Override the frame size. Zero means the model's default.
pub fn framerate(mut self, hz: u32) -> Self
Frames per second.
pub fn pattern(mut self, pattern: TestPattern) -> Self
Which pattern to generate.
pub fn gradient_direction(mut self, direction: GradientDirection) -> Self
Direction of a gradient pattern.
pub fn temperature_range(mut self, min_c: f32, max_c: f32) -> Self
The coolest and warmest temperatures in the generated scene, in
the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit).
pub fn seed(mut self, seed: u64) -> Self
Seed the generator, so a run is reproducible. Zero seeds it randomly.
pub fn flag_cycle(mut self, interval_s: f32, duration_s: f32) -> Self
Simulate shutter cycles: how often, and for how long.
pub fn checker_size(mut self, pixels: u32) -> Self
Block size of a checkerboard pattern, in pixels.
pub fn hotspot(mut self, radius_px: u32, speed_px_per_s: f32) -> Self
Radius and speed of a hot-spot pattern.
pub fn frame_cycle_steps(mut self, steps: u32) -> Self
How many temperatures a TestPattern::FrameCycle steps
through, FRAME_CYCLE_MIN_STEPS to FRAME_CYCLE_MAX_STEPS.
Zero means the default, 4.
Frame n is uniform at step n % steps, so a frame that is not
uniform was mixed from two frames and a step that skips or
repeats is a dropped or a repeated frame. Any other count is
refused when the camera is opened, with
Status::Configuration naming the field.
pub fn serial(mut self, serial: &str) -> Result<Self>
The serial number the simulated device reports.
Any UTF-8 string up to 31 bytes, including a name such as
"TEST-0001": the simulated camera reports it back unchanged.
In earlier releases a serial that was not a number was
accepted and then silently replaced with "9990001".
Errors
Returns Status::InvalidArgument if serial contains an
interior NUL byte.
pub fn frame_file(mut self, path: &str) -> Result<Self>
Read frames from a file, for
TestPattern::FromFile.
Errors
Returns Status::InvalidArgument if path contains an
interior NUL byte.
pub fn model(&self) -> DeviceType
The model it is impersonating.
pub fn size(&self) -> (u32, u32)
Its frame size, as (width, height).
pub fn rate_hz(&self) -> u32
Its frame rate in Hz.
pub fn test_pattern(&self) -> TestPattern
The pattern it is generating.
pub fn direction(&self) -> GradientDirection
A gradient pattern's direction.
pub fn temperatures_c(&self) -> (f32, f32)
The coolest and warmest temperatures in the scene, in the SDK's
temperature unit despite the name: as they were set, or as
SimulatedConfig::new read them.
pub fn seed_value(&self) -> u64
The generator's seed.
pub fn flag_cycle_s(&self) -> (f32, f32)
The simulated flag cycle, as (interval_s, duration_s).
pub fn checker_size_px(&self) -> u32
A checkerboard's block size in pixels.
pub fn hotspot_params(&self) -> (u32, f32)
A hot spot's radius in pixels and speed in pixels per second.
pub fn frame_cycle_step_count(&self) -> u32
How many steps a TestPattern::FrameCycle steps through.
pub fn serial_number(&self) -> String
The serial it reports.
pub fn frame_file_path(&self) -> String
The file it reads frames from, or empty.