Camera
pub struct Camera
A camera: live hardware, a simulated device, or a recording being replayed.
Destroyed when dropped. Dropping stops streaming, waits for any callback in flight to return, and joins the SDK's threads for this camera, so no callback can fire afterwards.
Threading
Camera is Send but deliberately not Sync. The C API's
rule is that distinct handles may be used concurrently but a single
handle may not, so a camera can be moved to another thread and used
there, and cannot be shared between two. Wrap it in a Mutex if
two threads have to reach one camera.
Callbacks are invoked on the SDK's own threads, never on the thread
that registered them, which is why every callback closure must be
Send.
Camera — methods
pub fn open() -> Result<Self>
Open the first camera found.
Errors
Returns Status::Device if no camera is attached.
Status::Calibration arrives only when the open itself
failed and calibration was found missing along the way.
Calibration that cannot be found is not on its own a failure:
such a camera opens and streams, and nothing about its frames
says they are not measurements. This line used to say "if its
calibration is unavailable", which named the case that
succeeds.
This crate exposes no accessor for that state yet;
optris_sdk_imager_get_calibration_status() in optris-sdk-sys
is the only way to ask from Rust today.
pub fn open_device(device: &DeviceInfo) -> Result<Self>
Open a specific camera, by an entry from crate::enumerate.
Errors
As Camera::open, plus Status::NotConnected if the device
has gone away since it was enumerated.
pub fn simulated(config: &SimulatedConfig) -> Result<Self>
Create a simulated camera.
Needs no hardware and produces frames at the configured rate.
Errors
Returns Status::InvalidArgument if the configuration is not
one the SDK can honour.
pub fn open_network(target: &NetworkTarget) -> Result<Self>
Open a camera over Ethernet.
Never falls back to USB. A caller that asks for a network camera and silently gets a different one over USB has no way to tell, so this refuses instead.
Prefer Camera::open_device on an entry from
crate::enumerate_with with include_network on: that form
works whether the camera is on USB or on the network, which is
the point; an application should not have to be rewritten
because a camera moved onto a network cable. Reach for this one
when the camera cannot be discovered, which means a camera
behind a router or on another VLAN, because discovery is a
broadcast and a broadcast crosses neither.
Errors
Returns Status::Device if no camera answers, which for a
wrong address takes the target's connect timeout rather than
minutes.
Examples
use optris_sdk::{Camera, NetworkTarget};
# fn main() -> optris_sdk::Result<()> {
// By serial, found with a broadcast on this segment.
let camera = Camera::open_network(&NetworkTarget::new().serial("21074191")?)?;
# Ok(())
# }
pub fn from_file(path: &str) -> Result<Self>
Open a recording as a camera, replaying its frames.
Errors
Returns Status::Io if the file cannot be opened.
pub fn from_series(path: &str) -> Result<Self>
Open a multipart recording, from any one of its parts, and replay every part as one recording. Added in 12.0.10.
A recording started with a segment limit is written as
run_part000.mkv, run_part001.mkv and so on.
Camera::from_file replays the one file it is given; this
replays the whole recording from its first frame, whichever part
it is given. The playback duration and position are the whole
recording's and run on across each part boundary, a seek reaches
into any part, and regions and alarm rules carry on across a
boundary. Camera::playback_part says which part is playing.
A whole recording opens exactly as Camera::from_file opens
it.
Errors
Returns Status::Io if the file cannot be opened, or if a
part of the recording is missing; the message names the missing
part and the file it should be.
Examples
use optris_sdk::Camera;
# fn main() -> optris_sdk::Result<()> {
let replay = Camera::from_series("run_part001.mkv")?;
let (part, parts) = replay.playback_part()?;
println!("part {part} of {parts}");
# Ok(())
# }
pub fn open_still(path: &str) -> Result<Self>
Open a saved snapshot and measure it as if it were a camera.
A still this SDK wrote is a measurement, not a picture of one: the file carries the temperatures and the settings they were computed at. This turns it back into something that can be interrogated -- drop a measuring area on it and read what the temperature was.
What comes back is an ordinary Camera, for the reason
Camera::from_file does: a still is the third kind of frame
source rather than a type of its own. Camera::start,
Camera::acquire_frame, the regions, the alarm rules, the
palettes and the colour scaling all work on it unchanged.
A still has exactly one frame and that frame never changes.
Camera::refresh_still measures and delivers it once, on the
calling thread, which is the call for a program that wants an
answer rather than a stream. Camera::start re-delivers it at
Camera::still_redelivery_rate, as a camera pointed at an
unchanging scene would, so a region moved while it runs is
measured without anything being restarted.
Errors
Returns Status::Io if the file cannot be read or carries no
otc:meta document -- which is how a file from before this
format, or from another program, is recognised. Returns
Status::NotSupported if it holds raw detector counts or
energy rather than temperature: there is no radiometric model
beside such pixels, so every temperature would be invented.
pub fn start(&mut self) -> Result<()>
Begin acquiring and processing frames.
Frames reach the callbacks and the acquisition queue only after this returns successfully. Starting a camera that is already running succeeds and does nothing.
Errors
Returns Status::Device if the camera cannot be started.
pub fn stop(&mut self) -> Result<()>
Stop acquiring frames.
Waits for any callback in flight to return, so afterwards no
further callback can fire until the next Camera::start.
Errors
Returns Status::Device if the camera cannot be stopped.
pub fn is_running(&self) -> Result<bool>
Whether frames are being acquired.
Errors
Returns Status::InvalidHandle if the camera is unusable.
pub fn is_connected(&self) -> Result<bool>
Whether the camera is currently reachable.
Errors
pub fn acquire_frame(&self, timeout_ms: u32) -> Result<Option<OwnedFrame>>
Take the next frame from the acquisition queue.
Returns Ok(None) when the wait expired or, with a zero timeout,
when nothing was queued. Those are routine outcomes of a polling
loop rather than failures, so they are not errors here.
The returned frame is owned: its pixels last until it is dropped, unlike the borrowed frame a callback receives.
The queue is bounded and drops its oldest frame when full, so a
slow consumer falls behind in latency rather than in memory;
Camera::dropped_frame_count reports how far.
Examples
# use optris_sdk::Camera;
# fn main() -> optris_sdk::Result<()> {
let mut camera = Camera::open()?;
camera.start()?;
while let Some(frame) = camera.acquire_frame(1000)? {
let info = frame.info()?;
println!("frame {}: max {:.1} C", info.sequence, info.max_temp_c);
}
# Ok(())
# }
Errors
Returns Status::InvalidState if streaming has not been
started.
pub fn serial(&self) -> Result<String>
The camera's serial number.
Errors
pub fn model(&self) -> Result<String>
The camera's model name, for display.
Errors
pub fn connection_interface(&self) -> Result<String>
How the camera is attached, e.g. "USB", for display.
Errors
pub fn device_type(&self) -> Result<DeviceType>
The camera's model as an enumerator.
Errors
pub fn width(&self) -> Result<u32>
Frame width in pixels.
Errors
pub fn height(&self) -> Result<u32>
Frame height in pixels.
Errors
pub fn frame_rate(&self) -> Result<u32>
Nominal frame rate in Hz.
Errors
pub fn hardware_revision(&self) -> Result<u32>
Hardware revision, or 0 if not reported.
Errors
pub fn firmware_revision(&self) -> Result<u32>
Firmware revision, or 0 if not reported.
Errors
pub fn frame_count(&self) -> Result<u64>
How many frames have been delivered.
Errors
pub fn dropped_frame_count(&self) -> Result<u64>
How many frames the acquisition queue discarded because a pull consumer did not keep up.
Counts exactly that and nothing else: not frames the camera never
sent, not frames lost in the transport. Zero while nothing pulls
slowly. Reset by Camera::reset_statistics, not by starting.
Errors
pub fn processing_latency_us(&self) -> Result<u64>
Time from capture to delivery for the most recent frame.
Always an error
The SDK does not measure processing latency. v11 had this call and it returned a hardcoded zero on every camera; the C entry point now refuses instead, so a caller is not handed a zero it would believe. Kept so code written against it still compiles.
If you need a latency figure, measure it in your application.
crate::FrameInfo::timestamp_us comes from the streaming
transport, and which clock it is on differs between transports,
so it cannot simply be subtracted from your own clock.
Errors
Returns Status::NotSupported in this release, always.
pub fn reset_statistics(&mut self) -> Result<()>
Reset the frame and dropped-frame counters to zero.
Resets what Camera::frame_count and
Camera::dropped_frame_count report. It does not affect
Camera::processing_latency_us, which does not work at all in
this release.
Errors
pub fn process_interface(&self) -> Result<ProcessInterface<'_>>
This camera's process interface.
The controller belongs to the camera: obtaining one does not keep
the camera alive, and destroying the camera destroys the
controller with it. The returned handle borrows self, so the
compiler enforces the ordering the C API asks for; you cannot
drop the camera while a ProcessInterface onto it is alive.
Calling this more than once yields handles onto the same controller.
Errors
Returns Status::NotSupported if this camera has no process
interface at all.
pub fn attach_simulated_pif(
Plug an in-memory process interface into this simulated camera.
A simulated camera has no PIF socket, so
Camera::process_interface answered
Status::NotSupported on one and no process-interface
behaviour could be tested without hardware at all.
After this call it hands back a real controller over a
memory-backed port: the same channel table, the same
transforms, the same output reconciliation and the same signals
into the alarm engine. Only the wire is fake.
Drive its inputs with
Camera::set_simulated_pif_digital_input and
Camera::set_simulated_pif_analog_input. Read its outputs
back the ordinary way, off the ProcessInterface: an output
is what the SDK drove, and there is deliberately no call that
writes one from outside.
layout is the shape it should present: None for a standard
one, two channels of each sort with a fail-safe line. Every
kind is accepted, so declaring an identity can be exercised.
Calling it again replaces the interface, as swapping the box on the connector would.
Errors
Returns Status::NotSupported if this is a real camera or a
recording.
pub fn detach_simulated_pif(&mut self) -> Result<()>
Unplug it again. Camera::process_interface then answers
Status::NotSupported as it did before.
Succeeds when nothing is attached: "this camera has no process interface" is the state it is asked to reach.
Errors
Returns Status::NotSupported if this is a real camera or a
recording.
pub fn has_simulated_pif(&self) -> Result<bool>
Whether a simulated process interface is plugged in right now.
false for a real camera or a recording rather than an error:
it is the question asked before deciding whether the interface
in hand is a fake.
Errors
Returns an error only if the handle is not usable.
pub fn set_simulated_pif_digital_input(&mut self, index: u8, high: bool) -> Result<()>
Drive one digital input pin of the simulated interface.
The outside world talking: this is the level the next
ProcessInterface::poll reads off pin index.
Errors
Status::NotSupported if this is not a simulated camera or
nothing is attached; Status::Configuration if index is
past the attached layout.
pub fn set_simulated_pif_analog_input(&mut self, index: u8, volts: f32) -> Result<()>
Drive one analog input pin of the simulated interface, in volts.
Volts, not raw counts: the reading a multimeter on that pin would show, before any channel decode.
Errors
As Camera::set_simulated_pif_digital_input.
pub fn step_simulated_pif_watchdog(&mut self) -> Result<()>
Advance the simulated fail-safe watchdog by one check, as a passing health check on a real camera would.
The fail-safe line is deliberately not driven by
ProcessInterface::poll: on a real camera it moves only when
the frame watchdog says the pipeline is alive, so a line that
kept alternating because an application kept polling would tell
a PLC "the camera is healthy" when it means "this process is
still running". This is the explicit step instead.
Errors
Status::NotSupported if this is not a simulated camera or
nothing is attached.
pub fn set_simulated_pif_external_probe(&mut self, celsius: f32) -> Result<()>
Put an external temperature probe reading on the simulated
interface, in the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit), as a frame
carrying one would.
A probe reading does not arrive on a channel (it is decoded
out of the frame's process-interface telemetry), so there is no
pin to drive and this is the only way to produce one without
hardware. It reads back from
crate::pif::ProcessInterface::external_probe_temperature and
is published as
crate::enums::SignalField::ProbeTemperature, only on an
interface attached as a temperature probe, as on a real camera;
on any other kind the reading is ignored.
Errors
As Camera::set_simulated_pif_digital_input.
pub fn clear_thermal_callback(&mut self) -> Result<()>
Stop delivering thermal frames.
Errors
pub fn is_still(&self) -> Result<bool>
Whether this is a saved still rather than a camera or a recording.
Answered by all three kinds, so it is the one to branch on.
Errors
pub fn refresh_still(&self) -> Result<()>
Measure and deliver the still once, now.
Runs the region and alarm pass over the frame and fires the registered callbacks, on the calling thread, whether or not the source is running. This is the call for a program that wants an answer rather than a stream.
A still delivers only while it is running or once per call
to this, so Camera::acquire_frame on a still that has been
opened and neither started nor refreshed reports
Status::InvalidState -- exactly as it does on a camera that
has not been started.
Errors
Returns Status::NotSupported on a camera or a recording.
pub fn still_redelivery_rate(&self) -> Result<f32>
How often a running still re-delivers its one frame, in Hz.
Defaults to 10. No effect on Camera::refresh_still.
Errors
Returns Status::NotSupported on a camera or a recording.
pub fn set_still_redelivery_rate(&self, hz: f32) -> Result<()>
Set how often a running still re-delivers its one frame.
Errors
Returns Status::NotSupported on a camera or a recording, and
Status::Configuration for a rate outside 0.1 to 120 -- a
zero would be a thread that never delivers, which from outside
is indistinguishable from a wedged source. The rate in force is
left unchanged in that case.
pub fn honours_region_emissivity(&self) -> Result<bool>
Whether a region's own emissivity reaches the numbers here.
A property of the file, asked of the file that was opened. Honouring a region's own emissivity means undoing the radiometric correction already made and redoing it at a different emissivity, and both directions go through the camera's own characteristic curve. The SDK writes that curve into every still it saves from a camera that has one.
true when this still carried its curve: the region is then
resolved by the same object a live camera resolves it with, so
it reports what the camera that took the picture would have
reported. The picture itself is never corrected -- there is no
pipeline here -- so such a region's state is
RegionEmissivityState::ReadingOnly, which is the badge to
draw.
false for a still written before the curve was carried, one
saved by a source with no curve, and one whose curve cannot be
inverted. The region then reads at the camera's own emissivity
and RegionEmissivityState::Cameras says so -- reported rather
than absorbed, because the alternative is a region that reads
exactly as if it had no emissivity of its own while claiming to
have one.
Errors
Returns Status::NotSupported on a camera or a recording.
pub fn still_path(&self) -> Result<String>
The file this still was opened from.
Errors
Returns Status::NotSupported on a camera or a recording.
pub fn still_metadata_json(&self) -> Result<String>
The whole metadata document the file carries, as JSON.
The pixel scale, the scene statistics, the capture telemetry,
the regions the writer recorded and anything it merged in. It is
the way to reach the parts of the metadata this binding does not
model as methods, including the recorded region list and the
render block that says what the colours meant.
Errors
Returns Status::NotSupported on a camera or a recording.
pub fn sensor_width(&self) -> Result<u32>
The detector's own width, before any orientation.
Camera::width reports what is delivered, which a quarter
turn swaps. This reports what the hardware -- or, on a file, the
stored frame -- actually is.
Errors
pub fn sensor_height(&self) -> Result<u32>
The detector's own height, before any orientation.
Errors
pub fn set_orientation(&self, rotation_deg: f32, mirror: Mirror) -> Result<()>
Turn and/or mirror the frames this source delivers.
rotation_deg must be a multiple of 90. The orientation is part
of the radiometric pipeline rather than a display transform, so
there is only ever one coordinate system: regions are authored
in the oriented frame and need no mapping. Quarter turns are an
exact index remap, so a turned frame measures identically to an
unturned one, and one swaps what Camera::width and
Camera::height report while the sensor pair keeps reporting
the detector.
Errors
Returns Status::Configuration for anything that is not a
quarter turn: any other angle leaves output pixels with no
source pixel behind them, and this release has no concept of an
unmeasurable pixel, so it is refused rather than resampled.
pub fn orientation(&self) -> Result<(f32, Mirror)>
The orientation in force, as (rotation_deg, mirror).
Errors
pub fn color_range(&self) -> Result<(Option<f32>, Option<f32>)>
The colour range as it was set, each edge present or absent.
(min, max) in the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit), where None
means that edge is scaled automatically. The counterpart of
Camera::set_color_range, which takes the same two
Options.
Not what is being drawn: for that, ask
Camera::effective_color_range. The two differ for every
automatically scaled edge, which is the normal case, and the
ABI keeps them apart as two entry points for exactly that
reason.
One edge cannot be released on its own
Measured, and it contradicts the C header, which documents
has_min and has_max as independent. A single None
passed to Camera::set_color_range leaves that edge exactly
as it was; only (None, None) releases anything:
| state before | asked for | reads back as |
|---|---|---|
(-12.5, 87.5) |
(None, Some(87.5)) |
(-12.5, 87.5), unchanged |
(-12.5, 87.5) |
(Some(-12.5), None) |
(-12.5, 87.5), unchanged |
(None, None) |
(None, Some(87.5)) |
(Some(0.0), 87.5) (32.0 in Fahrenheit) |
| anything | (None, None) |
(None, None) |
So "fix the top and let the bottom follow the scene" cannot
be asked for at all. And the third row is the dangerous one:
from the released state the edge passed as None comes back
fixed at 0 °C (32.0 in Fahrenheit), which is the placeholder
Camera::set_color_range sends for an absent edge leaking
through a flag the SDK is not honouring. A caller who believed
the header gets a picture clamped at 0 °C with nothing saying
so.
Release both, then fix the one you want, and read this getter
back to confirm. It is an SDK behaviour rather than a binding
one, and tests/camera_color.rs pins all four rows so a fix
upstream shows up as a failing test rather than as a silently
stale comment.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn effective_color_range(&self) -> Result<(f32, f32)>
The range actually being drawn, both edges resolved, in the
SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit).
Every automatically scaled edge has a number here. This is what a colour-bar widget is labelled from.
Errors
Returns Status::InvalidState before the first frame, where
an automatic edge has nothing to have been derived from.
pub fn color_scaling(&self) -> Result<ColorScaling>
How an automatically scaled edge is derived.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_color_scaling(&mut self, scaling: ColorScaling) -> Result<()>
Choose how an automatically scaled edge is derived.
Errors
Returns Status::InvalidArgument for a mode this build of
the library does not know.
pub fn color_scale_dynamics(&self) -> Result<ColorScaleDynamics>
How quickly the range follows the scene.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_color_scale_dynamics(&mut self, dynamics: ColorScaleDynamics) -> Result<()>
Set them.
Errors
Returns Status::InvalidArgument for values outside their
documented domains: a negative time, a fraction above one.
pub fn are_color_windows_supported(&self) -> Result<bool>
Whether this camera's pipeline draws colour windows at all.
Worth asking before offering the feature: on a pipeline that
does not support them Camera::set_color_window is refused,
and an editor that discovers this by being refused has already
shown the operator a control that does nothing.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn color_windows(&self) -> Result<Vec<ColorWindowEntry>>
Every colour window on this camera, with its id.
Errors
Returns Status::NotSupported on a pipeline that does not
draw them, see Camera::are_color_windows_supported.
Why this is not written with the array helper
The entry point takes a per-element size as well as a
capacity, which the three-argument array helper cannot express.
The size handed over is size_of the struct this crate was
compiled against, which is how the ABI stays
forwards-compatible.
pub fn color_window_colors(&self, id: u32) -> Result<Vec<Rgb24>>
One colour window's own colour table.
Empty for a band coloured from its palette. This is the only
way to get the table: Camera::color_windows reports the
count and not the colours, because the SDK will not hand out a
pointer into its own memory.
Errors
Returns Status::NotFound for an id that has no window.
pub fn is_dde_supported(&self) -> Result<bool>
Whether this camera's pipeline implements digital detail enhancement.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn dde_gain(&self) -> Result<(bool, f32, f32)>
The DDE gains: whether it is on, and the base and detail weights.
The counterpart of Camera::set_dde_gain, which has no
"enabled" argument.
The flag is not derived from the gains
Measured: a fresh camera reads (false, 1.0, 1.0), and
set_dde_gain(1.0, 1.0) then reads (true, 1.0, 1.0),
so setting the identity enables DDE rather than leaving it
off, and there is no gain that switches it back off. The flag
means "a gain has been written", not "the gains do something".
An earlier version of this comment claimed the opposite; it was
wrong, and tests/camera_color.rs pins the measurement.
Errors
Returns Status::NotSupported on a pipeline without DDE.
pub fn connection_status(&self) -> Result<ConnectionStatus>
Where this camera stands on its way to being connected.
Six states rather than a boolean, and the distinctions are
load-bearing: ConnectionStatus::Stalled is a camera still
on its transport that may resume on its own, where
ConnectionStatus::Lost has gone; and a cancelled
reconnect rests at ConnectionStatus::Disconnected where a
failed one rests at ConnectionStatus::Failed.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn connection_timeout(&self) -> Result<Duration>
How long without a frame counts as a stalled stream.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_connection_timeout(&mut self, timeout: Duration) -> Result<()>
Set it.
Duration::ZERO is refused, not a reset. Measured: the
SDK answers "connection_timeout of 0 ms is not a wait: the
stream would be Stalled from the moment it started. Ask for at
least 1 ms." That is the opposite of
crate::CameraOptions::connection_timeout, where zero
means "use the camera's saved configuration"; the two are
different fields with opposite treatments of zero, which is
why this says so rather than leaving it to be inferred from
the neighbour.
Errors
Returns Status::InvalidArgument for Duration::ZERO, and
if the duration does not fit the ABI's uint32_t of
milliseconds.
pub fn clear_connection_status_callback(&mut self) -> Result<()>
Stop delivering status changes.
Errors
As Camera::on_connection_status.
pub fn reconnect(&mut self) -> Result<()>
Re-open this camera, in place, now.
Synchronous, and one attempt. It returns once the camera is open and a frame has arrived, not merely once the open returned, because an open can succeed against a stream session the operating system has not finished tearing down, accept every read and complete none. If no frame arrives the camera is closed again and this reports an error, so the next attempt starts from nothing.
Every setting survives: palette, colour range, temperature range and operation mode, radiation parameters, regions, alarm rules, colour windows, orientation, the process interface and every registered callback. A recording in progress is stopped and finalized before the teardown: the file on disk is complete and playable, and nothing is written into it afterwards.
Errors
Returns Status::Device if the camera could not be re-opened
or delivered no frame, and Status::InvalidState when called
from inside one of this camera's own callbacks; it would wait
on the thread that is asking, so it is refused rather than hung.
pub fn enable_auto_reconnect(&mut self, config: &ReconnectConfig) -> Result<()>
Have the SDK re-open this camera by itself whenever it drops.
Two things it deliberately does not recover
A Failed raised by the very first open is not recovered:
the application asked for that open and is holding the error,
and retrying it behind the application's back is not recovery.
And a camera that is being asked for frames and has never
delivered one is not recovered either.
Connected is published at the end of the open, before any
frame, so an open on its own cannot tell a session that worked
from one that merely opened. The case is a network camera whose
first frame a firewall prompt is holding back: it would
otherwise stall, be recovered, stall again, and spend the whole
attempt budget on a re-open that cannot help it. One frame is
enough, for the whole life of the camera.
Errors
Returns Status::InvalidArgument for a schedule the SDK will
not take.
pub fn disable_auto_reconnect(&mut self) -> Result<()>
Stop reconnecting automatically.
Harmless when nothing is enabled, so tidy-up code need not check. Returns after the watcher has stopped.
An attempt already in flight is abandoned, not waited
out, and the camera is left closed. So a cancelled
attempt comes to rest at ConnectionStatus::Disconnected and
a failed one at ConnectionStatus::Failed, deliberately,
because nothing failed, and switching recovery off must not
read in a log like a recovery that did not work. No
ReconnectPhase::AttemptFailed and no
ReconnectPhase::GaveUp is published.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn is_auto_reconnect_enabled(&self) -> Result<bool>
Whether automatic reconnection is in force.
The state, not the request. It reads false once the SDK
has given up: after ReconnectPhase::GaveUp nothing is
watching, and Camera::enable_auto_reconnect is what starts
it again.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn reconnect_config(&self) -> Result<ReconnectConfig>
The schedule in force.
Errors
Returns Status::InvalidState when nothing has been enabled.
pub fn clear_reconnect_callback(&mut self) -> Result<()>
Stop delivering reconnect events.
Errors
pub fn clear_reconnect_attempt_callback(&mut self) -> Result<()>
Stop being asked; every attempt proceeds again.
Not a fence. Unlike clearing
Camera::on_reconnect's handler, the veto is copied out from
under its lock and called with the lock released, which is
what stops installing one from inside a handler being a hang,
so a call already in flight when this returns runs to
completion afterwards. This crate retains every closure until
the camera is dropped, so that is sound here; it is why it is
stated rather than left to be discovered.
Errors
As Camera::on_reconnect_attempt.
pub fn network_config(&self) -> Result<NetworkConfig>
Read this camera's Ethernet configuration.
Errors
Returns Status::NotSupported if this camera has no Ethernet
interface, and on a recording.
pub fn apply_network_config(&mut self, config: &NetworkConfig) -> Result<NetworkApplyResult>
Write a new one.
Read the current one first and change what you mean to
change: every field is written, so a default-constructed
struct moves the camera to 0.0.0.0 as surely as a typed one
moves it anywhere else.
NetworkApplyResult::AppliedConnectionLost is an ordinary
outcome rather than a failure: the handle need not survive
its own success. Which one you get depends on what changed: a
new stream destination or subnet mask ends the connection; a
new address or port does not, because the SDK follows the
camera to its new address, leaving any address you cached
stale.
Warning
This changes where the camera is for every program on the network, not just yours, and it persists across a power cycle. A camera given an address on a subnet nobody can reach has to be fetched and put on a USB cable.
Errors
Returns Status::NotSupported if this camera has no Ethernet
interface, and Status::Device if the configuration was
refused, in which case nothing was written, and the
message says why. The commonest reason is a stream destination
equal to the address, which the SDK rejects itself before
writing, so that failure is not the device refusing anything.
pub fn request_network_config(&mut self, config: &NetworkConfig) -> Result<NetworkConfigReply>
Ask the camera to take a new network configuration, and return its answer -- including a refusal -- as a value.
The same write as Camera::apply_network_config, with the same
checks before anything is sent and the same outcomes when it is
taken. A camera that states why it refuses (the Xi 640 ETH over
USB, firmware reporting 4200..4399) has its reason and the
configuration it kept returned in the reply instead of as an
error.
Errors
Returns Status::NotSupported if this camera has no Ethernet
interface or its control path cannot configure it, and
Status::Device for everything
Camera::apply_network_config fails for except the camera's
own refusal.
pub fn interrupt_fail_safe(&mut self, active: bool, reason: Option<&str>) -> Result<()>
Stop, or restart, the fail-safe heartbeat from the application.
The fail-safe watchdog already watches the camera and the SDK's own processing. It cannot watch your application. This is how an application reports its own trouble to the same output: a stuck worker thread, a queue that stopped draining, a control loop that missed its deadline.
With active true the heartbeat stops, so any PIF fail-safe
output stops changing and whatever reads it sees a fault. With
active false the interrupt is lifted, which does not by
itself restart the heartbeat: the watchdog's own conditions
still have to pass.
reason is free text for the log, so the reason a line stopped
is recoverable afterwards.
Errors
Returns Status::Device if the camera is not connected.
pub fn start_continuous(&mut self, config: &ContinuousConfig) -> Result<()>
Start a continuous recording: a rolling history on disk.
A retention bound is required
At least one of ContinuousConfig::max_duration,
ContinuousConfig::max_bytes and
ContinuousConfig::min_free_bytes must be set. Each
field's own documentation says zero means "not bounded by
this", and all three zero is refused rather than unbounded: a
history allowed to fill the volume takes the application's logs
and the operating system's ability to write a file down with
it. Measured, not inferred -- the refusal names all three.
Errors
Returns Status::InvalidArgument for a configuration with no
directory, no segment duration or no retention bound,
Status::Io if the directory cannot be created or written,
and Status::InvalidState if a history is already running.
pub fn stop_continuous(&mut self) -> Result<()>
Stop it. The open segment is closed and catalogued.
Errors
Returns Status::Io if the open segment's trailer could not
be written.
pub fn is_continuous(&self) -> Result<bool>
Whether a continuous recording is running.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn continuous_stats(&self) -> Result<ContinuousStats>
What the history has done.
Errors
Returns Status::InvalidState when no history has run on this
camera.
pub fn continuous_timeline(&self) -> Result<Vec<TimelineSpan>>
Every segment of the timeline, oldest first.
This is what a transport bar is drawn from.
The open segment is in it
Measured across eight readings of a running history:
timeline().len() == continuous_stats().segments_written + 1,
exactly, every time. So the last span is the segment currently
being written -- which is why its byte count keeps growing and
why it cannot be cut from yet. An earlier draft of this comment
claimed the opposite; the arithmetic above is the correction,
and tests/camera_continuous.rs pins it.
Empty after Camera::stop_continuous, which resets the
catalogue along with the counters. See ContinuousStats.
Errors
Returns Status::InvalidState when no history has run on this
camera.
Why this is not written with read_array
The entry point takes a per-element size as well as a
capacity, so the array helper's three-argument shape does not
fit it. The size handed over is size_of the struct this crate
was compiled against, which is how the ABI stays
forwards-compatible: a newer library writes only the prefix
that fits.
pub fn save_clip(&mut self, from_us: u64, to_us: u64, path: &str) -> Result<ClipResult>
Cut a clip out of the history and write it to path.
from_us and to_us are capture times, as
TimelineSpan::from_us reports them. Both are clamped to what
the history still holds, and
ClipResult::incomplete says when that clamping happened.
Errors
Returns Status::InvalidArgument if path carries an interior
NUL byte or the window is inverted, Status::NotFound if the
window lies entirely outside the history, and
Status::AlreadyExists if a file is already at path; the
SDK will not destroy it.
pub fn start_interval_capture(
Write a still every interval into directory.
name_pattern is required and must not be empty --
measured, not assumed: an empty one is refused. Each file gets
a unique path, so an interval capture never overwrites its own
earlier output.
Errors
Refused for a zero interval, an empty name_pattern, or a
string with an interior NUL byte; Status::Io if the
directory cannot be written.
pub fn start_interval_capture_with(
Camera::start_interval_capture with the unit and spelling of
each CSV image.
csv is to every image of a SnapshotFormat::Csv time-lapse
what it is to Camera::save_csv_snapshot: degrees Fahrenheit,
a semicolon and a decimal comma, or both. Ignored by the other
formats. A capture started afterwards with
Camera::start_interval_capture writes the default CSV again
rather than keeping these options.
Examples
# fn main() -> optris_sdk::Result<()> {
use std::time::Duration;
use optris_sdk::{Camera, CsvOptions, SnapshotFormat, TemperatureUnit};
let mut camera = Camera::open()?;
camera.start()?;
let csv = CsvOptions::default().with_temperature_unit(TemperatureUnit::Fahrenheit);
camera.start_interval_capture_with(
Duration::from_secs(60),
"timelapse",
SnapshotFormat::Csv,
"night_{sequence}",
&csv,
)?;
# Ok(())
# }
Errors
Everything Camera::start_interval_capture refuses, and
Status::InvalidArgument for options
Camera::save_csv_snapshot refuses, whatever the format.
Nothing starts then.
pub fn stop_interval_capture(&mut self) -> Result<()>
Stop it.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn is_interval_capturing(&self) -> Result<bool>
Whether an interval capture is running.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn interval_capture_count(&self) -> Result<u64>
How many stills it has written.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn interval_capture_interval(&self) -> Result<Duration>
The interval it is capturing at.
Duration::ZERO when nothing is capturing.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn enable_pre_roll(&mut self, duration: Duration) -> Result<()>
Hold this much of the recent past, so a recording started now begins slightly before now.
This is the whole point of pre-roll: the interesting event is usually what makes you start recording, and without it the recording begins just after the thing you wanted to see.
Costs memory: a second of 640x480 frames at 32 Hz is about 39
MB. Camera::set_pre_roll_memory_budget caps it, and
Camera::pre_roll_state reports what survived the cap.
A Duration, not whole seconds. Until API version 30
this was enable_pre_roll_for and the plain name took a u32
of seconds, wrapping the deprecated whole-seconds entry
point: the obvious call in the obvious unit for 900 ms was
enable_pre_roll(duration.as_secs() as u32), which is
enable_pre_roll(0). Rust was the only binding that way round
-- .NET's EnablePreRoll has always taken a TimeSpan and
Python's enable_pre_roll a float of seconds, both through the
millisecond entry point.
To switch pre-roll off, call Camera::disable_pre_roll; a
zero duration is Status::InvalidArgument, not a disable.
Errors
Returns Status::InvalidArgument if the duration is zero or
does not fit the ABI's uint32_t of milliseconds, and
Status::OutOfMemory if the ring would exceed
Camera::set_pre_roll_memory_budget.
pub fn pre_roll_state(&self) -> Result<PreRollState>
Everything about the pre-roll, including the time the held frames actually span.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_pre_roll_memory_budget(&mut self, bytes: u64) -> Result<()>
Cap what the pre-roll ring may occupy, in bytes.
Every held frame is a full copy of the pixels, so a pre-roll asked for in seconds on a 640x480 sensor at 32 Hz is tens of megabytes. Zero means the SDK's own default.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn pre_roll_memory_budget(&self) -> Result<u64>
What that cap is.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn start_recording_with(
Record to path with options.
The _ex entry point, which is where crate::RecordingOptions
is spent: segmentation, a duration, a free-space floor, the
lossy settings.
Errors
Returns Status::AlreadyExists if a regular file is already
at path: nothing is opened and nothing is truncated;
Status::InsufficientSpace if the destination is below
min_free_bytes; Status::InvalidArgument for a path with an
interior NUL byte.
pub fn start_recording_for(&mut self, path: &str, duration: Duration) -> Result<()>
Record to path and stop by yourself after duration.
The clock starts once the recording is live, after any pre-roll has been written out, so a file with pre-roll enabled covers rather more than this.
Errors
As Camera::start_recording_with, plus
Status::InvalidArgument if the duration does not fit the
ABI's uint32_t of milliseconds.
pub fn is_recording_bounded(&self) -> Result<bool>
Whether the running recording will stop by itself.
true for one started with Camera::start_recording_for or
with a duration in its options. The question an application
asks before offering a stop button: a bounded take has an end
and an unbounded one does not.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn remaining_recording_time(&self) -> Result<Option<Duration>>
How much of a bounded recording is left.
None when nothing is recording or the recording is unbounded,
which is why Camera::is_recording_bounded exists beside it:
"no time left" and "no limit" are different answers and the
ABI's single uint32_t cannot tell them apart.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn clear_recording_callback(&mut self) -> Result<()>
Stop delivering recording events.
Errors
As Camera::on_recording_event.
pub fn clear_recording_event_detail_callback(&mut self) -> Result<()>
Stop delivering RecordingEventDetails.
Errors
As Camera::on_recording_event_detail.
pub fn set_canvas(&mut self, canvas: &crate::Canvas) -> Result<()>
Place this camera's frames in a canvas.
The camera copies the canvas, so dropping yours afterwards
does not disturb it, and later edits to yours do not reach the
camera; use Camera::set_placement for a live drag.
Two things change once a canvas is placed, and nothing changes before it, because the default canvas is a pass-through: the BGRA callback starts delivering the canvas composite at the canvas's extent rather than the sensor-native frame, and regions are read as canvas coordinates. The thermal, raw and energy callbacks are untouched and stay sensor-native; the composite resamples, and resampled thermal data is exactly what this design avoids.
Errors
Status::NotSupported on a player or a snapshot source.
pub fn canvas(&self) -> Result<crate::Canvas>
A copy of the canvas in force. You own it.
Errors
Status::NotSupported on a player or a snapshot source.
pub fn set_placement(&mut self, index: usize, placement: &crate::Placement) -> Result<()>
Edit one placement in place, without a copy round trip.
This is the call a drag handler wants: the swap happens under the frame thread's own lock, so it does not have to copy the canvas out, edit it and set it back while frames are arriving.
Errors
Status::NotFound when no canvas has been set, which includes
the ordinary case of not having set one yet, or when index is
past the end.
pub fn radiation(&self) -> Result<RadiationConfig>
The radiation parameters currently in force.
Errors
Returns Status::InvalidHandle if the camera is unusable.
pub fn set_radiation(&mut self, config: RadiationConfig) -> Result<()>
Apply radiation parameters.
Every field is applied, so read the current ones first and change what you mean to change rather than building a struct from scratch. They take effect on the next frame.
Examples
# use optris_sdk::Camera;
# fn main() -> optris_sdk::Result<()> {
let mut camera = Camera::open()?;
let mut radiation = camera.radiation()?;
radiation.emissivity = 0.95; // oxidised steel
camera.set_radiation(radiation)?;
# Ok(())
# }
Errors
Returns Status::Configuration if a value is out of range.
pub fn radiation_sources(&self) -> Result<RadiationSources>
Which radiation parameters this application owns, and which a process-interface input is driving.
Camera::radiation reads back from the engine, so a value a
PIF input supplied comes back looking exactly like one that was
set through this API. This is what tells them apart: an
application that lets an operator edit the emissivity or the
ambient temperature can show the field read-only, and say which
input owns it, instead of accepting an edit the next PIF sample
discards.
When the answer changes
With the channel table, not with each sample. An input
configured as crate::PifChannelKind::Emissivity owns the
emissivity from the moment it is configured: before the first
frame carries a reading for it, and whether or not any sample
ever arrives. So reading this once after configuring the
process interface is enough; it does not have to be polled per
frame. It changes only when the channel table does, which is
when this application changed it, or when a camera refused a
channel it was asked for, which is why guessing from the
application's own table is not the same answer.
Examples
# use optris_sdk::{Camera, RadiationParameterSource};
# fn main() -> optris_sdk::Result<()> {
let camera = Camera::open()?;
let sources = camera.radiation_sources()?;
let editable = sources.emissivity == RadiationParameterSource::Sdk;
println!("emissivity editable: {editable}");
# Ok(())
# }
Errors
Returns Status::NotSupported on a recording and on a still:
neither has a process interface, and
RadiationParameterSource::Sdk would be a value standing in
for "the question does not apply".
pub fn temperature_range(&self) -> Result<(i32, i32)>
The temperature range the camera is measuring in, as
(min_c, max_c) in whole degrees of the SDK's temperature unit
(Celsius unless crate::set_temperature_unit chose
Fahrenheit): -20..100 reads (-4, 212) in Fahrenheit.
Errors
pub fn set_temperature_range(&mut self, min_c: i32, max_c: i32) -> Result<()>
Switch to a different temperature range.
min_c and max_c are in the SDK's temperature unit, as
Camera::available_temperature_ranges reports them. In
Fahrenheit they are converted and rounded to the nearest whole
Celsius degree before they are matched against the camera's
ranges.
This restarts the camera's calibration, so frames stop for a moment and the first ones afterwards may be marked with the shutter closed.
Errors
Returns Status::Configuration if the camera does not support
that range; ask Camera::available_temperature_ranges first.
pub fn available_temperature_ranges(&self) -> Result<Vec<(i32, i32)>>
Every temperature range this camera offers, as (min, max) in
whole degrees of the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit).
Errors
pub fn operation_modes(&self) -> Result<Vec<OperationMode>>
Every mode this camera supports.
Errors
pub fn active_operation_mode(&self) -> Result<OperationMode>
The mode the camera is in.
Errors
pub fn set_operation_mode(&mut self, mode: &OperationMode) -> Result<()>
Put the camera into a mode.
mode must be one Camera::operation_modes reported. A mode
assembled by hand is rejected rather than approximated: a mode
the calibration does not support is not a mode.
Set the mode before starting when you can
Doing so costs no wait, and is correct and repeatable. Changing it on a running camera costs about thirty seconds of measurements, and the frames say so: a switch restarts the dark image and the auto-skim, and every frame reports its thermal data as not reliable until the readings are right again (556 of the 557 frames after a switch on an Xi 410, over 29.9 s). Wait for the first frame that reports it reliable. The readings then land where opening the camera in that mode lands them, so there is no reopen to do; earlier versions of this documentation said otherwise, and the defect behind that has been fixed.
No frame of the old mode is handed out after this returns, and a
snapshot is refused with Status::Io until a frame of the new
mode that reports its thermal data reliable has arrived.
Errors
Returns Status::Configuration if this camera has no such
mode.
pub fn processing_outputs(&self) -> Result<ProcessingOutputs>
Which frame types this camera's pipeline is producing.
Reports what is in force, including the two flags a callback
registration manages on the caller's behalf, so registering a
raw callback and reading this back shows
ProcessingOutputs::raw_frames set.
Errors
pub fn set_processing_outputs(&mut self, outputs: ProcessingOutputs) -> Result<()>
Choose which frame types the pipeline produces.
Writes all five flags. Read
Camera::processing_outputs first, change what you mean to
change, and write that back; a value assembled from scratch
switches off whatever its false fields name.
The rest of the processing configuration (the noise filter, the detail-enhancement gains, distortion correction) is untouched.
Clearing ProcessingOutputs::thermal_frames stops measurement
as well as frame delivery. See that field.
Errors
As Camera::radiation. A flag out of range cannot be
expressed here, because these are bools.
pub fn clipped_window(&self) -> Result<ClippedWindow>
Where a clipped video format's window sits on the detector.
Answers on every camera, open or not, and on every mode:
ClippedWindow::clipped is false when the active mode
reads the whole detector. Ask this before offering a control;
it is Camera::set_clipped_window that refuses.
Errors
pub fn set_clipped_window(&mut self, x: i32, y: i32) -> Result<()>
Move the clipped window's top-left corner, in detector pixels.
Positions outside the travel clamp to it rather than being
refused, so a slider dragged to its end does the obvious thing.
The travel is ClippedWindow::max_x and
ClippedWindow::max_y.
This costs what an operation-mode switch costs. The window is not only a command to the camera: the calibration is cropped to it, the lens-distortion correction's optical centre is measured from it, and the dead-pixel list is in detector coordinates. Moving it rebuilds the processing chain so that all four agree. Do not drive it from a slider's every intermediate value.
If the rebuild fails the previous position is restored, so the camera is never left reading one strip while the pipeline is calibrated for another.
Errors
Status::NotSupported when the active operation mode is not a
clipped format, or no camera is open;
Camera::clipped_window answers both without failing.
pub fn set_dde_gain(&mut self, base: f32, detail: f32) -> Result<()>
Detail enhancement: base and detail gain.
Setting either switches enhancement on. Display only: these change the picture and nothing else. Reported temperatures, measuring regions, recordings, snapshots and any registered buffer are unaffected.
Errors
pub fn effective_ambient_temperature(&self) -> Result<Option<f32>>
The ambient temperature actually in force, in the SDK's
temperature unit (Celsius unless crate::set_temperature_unit
chose Fahrenheit).
The camera's own estimate while
RadiationConfig::estimate_ambient is set, the configured
value otherwise, so this always says what the measurement is
based on, which Camera::radiation does not.
None when no ambient is in force yet: before the first frame,
or with estimation off and no ambient ever configured. Show
nothing rather than a default no measurement used, which is
why this is an Option rather than the C's pair of a float and
a validity flag.
Equal to the SignalField::AmbientTemp device signal
by construction; read that instead to put an alarm rule on it.
With estimation on the value steps rather than drifts: the pipeline refolds its energy table only when the estimate moves by 0.1 K or more, and this reports the value in force rather than a fresh calculation.
Errors
Returns Status::NotSupported for a recording, which has no
measurement in force. Otherwise as Camera::radiation.
SignalField::AmbientTemp: crate::SignalField::AmbientTemp
pub fn set_filter_mode(&mut self, mode: FilterMode) -> Result<()>
Spatial noise filter mode.
Unlike the detail-enhancement gains, these run inside the radiometric path and do change reported temperatures. That is what denoising a measurement means.
Errors
Returns Status::NotSupported if this camera's pipeline does
not implement mode; it never substitutes another filter.
Camera::is_filter_mode_supported asks in advance.
Otherwise as Camera::radiation.
pub fn filter(&self) -> Result<(FilterMode, f32)>
The spatial noise filter in force, and its strength.
Authoritative: it reports what was last accepted, and a rejected selection is never accepted, so this can never name a filter the pipeline is not running.
Errors
pub fn is_filter_mode_supported(&self, mode: FilterMode) -> Result<bool>
Whether this camera's pipeline implements mode.
Which pipeline runs depends on the camera's resolution rather than on anything the application chose, so this is the way to decide what to offer. Before a camera is attached the answer is the conservative one: true only for the filters every pipeline implements.
An unknown mode is reported as unsupported rather than as an error.
Errors
pub fn set_filter_strength(&mut self, strength: f32) -> Result<()>
How strongly the spatial filter is applied.
Errors
pub fn set_temporal_alpha(&mut self, alpha: f32) -> Result<()>
Temporal smoothing, 0 to 1.
Lower is smoother and slower to respond; 1 disables it.
Errors
pub fn temporal_alpha(&self) -> Result<f32>
The temporal smoothing in force.
Authoritative, and it answers before anything has been
written: smoothing is a stage of the SDK's own pipeline rather
than a setting held in the camera, so the value reported on a
camera nobody has configured is the one both pipelines start
from. It survives a change of filter (every mode other than
FilterMode::Temporal ignores the alpha rather than
clearing it), so this reports what temporal smoothing would
resume at.
Earlier releases had no reader for this value at all.
Errors
pub fn set_rdc_mode(&mut self, mode: RdcMode) -> Result<()>
Radial distortion correction.
Errors
pub fn set_sos_correction_enabled(&mut self, enabled: bool) -> Result<()>
Sensor-over-saturation correction.
Errors
pub fn trigger_shutter(&mut self) -> Result<()>
Close and reopen the shutter now.
The frames during a shutter cycle are not measurements: the
camera is looking at its own flag. Frames report it through
crate::FrameInfo::flag_open.
Errors
pub fn set_auto_flag_enabled(&mut self, enabled: bool) -> Result<()>
Whether the camera closes its shutter on its own schedule.
Switching this off is how a process that must not be interrupted avoids a shutter cycle mid-measurement, at the cost of drift, which is what the cycle exists to remove.
Errors
pub fn auto_flag_enabled(&self) -> Result<bool>
Whether the automatic shutter is enabled.
Errors
pub fn set_flag_while_recording(
Choose what a running recording does to the shutter schedule.
override_drift_c is the drift past which
FlagWhileRecording::AvoidUnlessDrift lets a correction
through: a difference in degrees of the SDK's temperature unit
(kelvin-sized in Celsius, Fahrenheit-sized in Fahrenheit). It
must be above zero for that policy and is ignored by the other
two.
Suppressing the shutter buys an unbroken stream and pays in
drift, and a recording stores finished temperatures, so that
drift is in the file permanently. Watch
Camera::shutter_deferral to see what it is costing.
Errors
As Camera::radiation, plus
Status::InvalidArgument for
FlagWhileRecording::AvoidUnlessDrift with
override_drift_c at or below zero. That pair is refused rather
than accepted because every drift is more than zero: the
override would fire every time and the policy would silently
behave as FlagWhileRecording::Use. There is deliberately no
default, because how much drift a measurement can bear is a
property of what is being measured.
pub fn flag_while_recording(&self) -> Result<(FlagWhileRecording, f32)>
The while-recording shutter policy and its drift override, the override a difference in degrees of the SDK's temperature unit (kelvin-sized in Celsius, Fahrenheit-sized in Fahrenheit).
Read back from what was applied, so a policy this build does not
know reads as FlagWhileRecording::Other.
Errors
pub fn shutter_deferral(&self) -> Result<ShutterDeferral>
What the while-recording shutter policy is doing, and what it has cost so far.
The honest half of FlagWhileRecording: setting a policy says
what you want, this says whether it is in force and how far the
detector has drifted while it was. A suppressed cycle changes
nothing else an application can see (the stream has no gap and
the temperatures still look like temperatures), so without this
a degraded recording is indistinguishable from a good one.
Read ShutterDeferral::policy_in_force first. It is false
while a process interface owns the flag, because the SDK then
runs no cycle to hold and the setting is moot rather than
working; Camera::shutter_externally_controlled tells that
case from the others.
Errors
pub fn shutter_externally_controlled(&self) -> Result<bool>
Whether the shutter flag belongs to a process-interface input rather than to the SDK.
true while any PIF input is configured as
PifChannelKind::FlagControl. The camera firmware then drives
the flag from that pin, and for as long as it does the SDK runs
no shutter cycle of its own: no automatic cycle, whatever
Camera::set_auto_flag_enabled says, and no startup
calibration, and Camera::trigger_shutter is refused. Every
closure the interface makes is still reported and still produces
a correction.
So this is not "the shutter is disabled". It is "somebody else
decides when", which is the point of the feature: a closure
interrupts the measurement, and only the process knows when that
is safe. It is also why
ShutterDeferral::policy_in_force is false here;
FlagWhileRecording has no cycle to hold, so the setting is
moot rather than working.
Ask this rather than inferring it from the channel table you sent: it answers from what was applied to the camera, so it cannot disagree with the behaviour, and it survives a reconnect.
false for a simulated camera and for a recording; neither has
an interface to hand the flag to.
Errors
pub fn recorded_flag_policy(&self) -> Result<Option<RecordedFlagPolicy>>
What a recording says its shutter was told to do while it was written.
The call to make before trusting a recording's numbers. Holding the shutter back buys an unbroken stream and pays in drift, and a recording stores finished temperatures, so the drift is in these pixels permanently and nothing on replay removes it. A suppressed recording otherwise looks exactly like a good one.
Merges the file header's half (the policy and its override, for
the whole recording) with the current frame's half (held and
drift_c, present only on the frames where a correction was
actually refused), so one call answers both questions.
Ok(None) when the recording declares no policy, which for this
metadata means the shutter was not held back: the block is
omitted entirely at the default policy. Every recording written
before the setting existed is in that position, and for those
files it is also the truth.
Errors
As Camera::radiation. A live camera answers
Status::NotSupported; it has
Camera::shutter_deferral instead, which reports what is
happening now rather than what a file remembers.
pub fn recorded_gap(&self) -> Result<Option<RecordedGap>>
Whether the frame most recently delivered is on the far side of a hole in this recording.
That you get a value at all is the fact: the frames either side of that frame are not contiguous, because the camera stopped delivering in between. Per frame, like the render block, so a replay has to be at the frame to see it; there is no file-level half to fall back to, because a recording's metadata document is written before its first frame and cannot describe anything that happens afterwards.
Ok(None) when this frame carries no marker, which is the
complete answer rather than an absence: the join here is sound.
Every frame of a recording that ran without an outage is in
that position, as is every frame of every recording written
before this metadata existed.
Errors
As Camera::radiation. A live camera answers
Status::NotSupported -- it has no file, and what it
offers instead is a reconnect notification.
pub fn set_flag_interval(&mut self, min_seconds: f32, max_seconds: f32) -> Result<()>
The shortest and longest the camera waits between shutter cycles.
Errors
pub fn set_flag_forecast_enabled(&mut self, enabled: bool) -> Result<()>
Compensate for the dark offsets drifting between shutter cycles. On by default.
A dark reference describes the detector at the instant it was taken; between corrections the detector keeps moving and the reference goes stale, by 2.4 to 2.6 K on a PI 400 measured between two cycles. With this on, the SDK measures how fast each pixel's offset is moving and walks the applied offset towards where the next reference is predicted to be.
This is not a warning that a cycle is about to happen. It was documented as letting "an application pause rather than record unusable frames", which described a feature the SDK does not have. For that, use the shutter callback.
Errors
pub fn flag_forecast_enabled(&self) -> Result<bool>
Whether the drift compensation between shutter cycles is on.
See Camera::set_flag_forecast_enabled. This getter did not
exist because the C one refused on every camera: the setter was
an empty stub, so there was no state to report.
Errors
pub fn flag_open(&self) -> Result<bool>
Whether the shutter is open right now.
Errors
pub fn nuc_in_progress(&self) -> Result<bool>
Whether a non-uniformity correction is running right now.
Errors
pub fn skip_startup_calibration(&mut self) -> Result<()>
Skip the calibration a camera runs when it starts.
The frames during it are unreliable and the SDK says so. Skipping gets a picture sooner and gets worse numbers until the camera has settled.
Errors
Returns Status::NotSupported if the camera will not.
pub fn focus_capability(&self) -> Result<FocusCapability>
Whether this camera's lens can be driven at all.
Ask this before offering a focus control. It is the only
call in this group that answers on every camera; the others
refuse with Status::NotSupported on a camera with no focus
motor and on one that is not open. This one never fails for
that reason; an unopened camera reports
FocusCapability::Unknown.
Branch with FocusCapability::is_focusable rather than on
"is not Fixed": Unknown means the question has no answer
yet, not that the answer is no.
This differs from
crate::DeviceCapabilities::has_motorized_focus, which is a
flag copied out of an enumeration entry and therefore cannot
distinguish "no motor" from "not asked". Prefer this on an open
camera.
Errors
Returns Status::InvalidHandle if the camera has been closed.
pub fn focus_diagnosis(&self) -> Result<String>
Why, in words: for the tooltip on a disabled focus control, and for a support report. Never empty.
Errors
pub fn focus_target(&self) -> Result<u16>
The position last asked for: where the lens is heading.
A focus command does not wait for the lens.
Camera::set_focus and Camera::set_focus_position return
as soon as the command is on the wire, and the motor takes
seconds to cross its travel: 1.9 s for a two-thirds traverse on
an Xi 400. Camera::focus_position read straight afterwards
reports where the lens was, which looks exactly like the
command having been ignored.
Bind a control to this and poll Camera::focus_position
beside it. The lens has arrived when the position stops changing
near this value, within about three steps on the camera
measured, so compare with a tolerance rather than for equality.
Zero when nothing has been commanded since the camera opened.
Errors
pub fn set_focus(&mut self, position: f32) -> Result<()>
Focus as a fraction of the lens's travel, 0.0 to 1.0.
The portable way to ask for a focus: it needs no knowledge of
the motor's own units. The fraction is mapped onto the range
Camera::focus_range reports and rounded to the nearest step.
Errors
Returns Status::OutOfRange if position is outside 0.0 to
1.0, and Status::NotSupported on a camera with no motorized
lens or one that is not open; ask
Camera::focus_capability first.
pub fn focus(&self) -> Result<f32>
Where the lens is now, as a fraction of its travel: 0.0 at the
near end of Camera::focus_range, 1.0 at the far end.
The counterpart of Camera::set_focus, for showing a person
where the focus is without the motor's own units. Read from the
motor, so while the lens is still travelling it reports where it
is, not where it is going.
Errors
Returns Status::NotSupported on a camera with no motorized
lens or one that is not open.
pub fn set_focus_position(&mut self, position: u16) -> Result<()>
Focus in the lens's own step units, for repeating an exact setting.
Errors
pub fn focus_position(&self) -> Result<u16>
Where the lens is now, in its own step units.
Errors
pub fn focus_range(&self) -> Result<(u16, u16)>
The lens's travel, as (near, far) in its own step units.
Errors
pub fn set_reference_temperature(
Correct the whole scale against a known temperature.
For a camera measuring against a reference body: tell it what the reference really is and what the camera read, and the difference is applied to everything it measures afterwards.
All three are in the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit). ambient_c
may be None to leave the air temperature to the camera.
Errors
pub fn reset_reference_temperature(&mut self) -> Result<()>
Discard the reference-temperature correction.
Errors
pub fn set_temperature_range_extension_enabled(&mut self, enabled: bool) -> Result<()>
Show a scene past the active temperature range.
Not a measuring range. The extended part lies outside the calibration and reads with poor precision. It exists so the field of view can be aimed, and so a visual check is possible, on a camera whose range has a high lower limit: a 150..900 °C range typically extends down to 20 °C.
Camera-wide, not per mode: the request is recorded whether or
not the active mode can act on it, so switching it on and then
selecting an extendable mode works. Whether it is in force is
OperationMode::extendable together with the limits the mode
reports, which become the extended ones once this is on. A mode
that cannot be extended keeps its limits and its 25 K
accommodation band.
Implemented here; in earlier releases true was refused.
Errors
pub fn temperature_range_extension_enabled(&self) -> Result<bool>
Whether the range extension is on.
The camera-wide request, false by default as in SDK 11.
Whether it is in force on the mode you are in is a separate
question, see
Camera::set_temperature_range_extension_enabled.
Errors
pub fn set_temperature_high_precision_enabled(&mut self, enabled: bool) -> Result<()>
Select the high-precision temperature table, where the active mode offers one. On by default, as in SDK 11.
It trades the span of temperatures the 16-bit internal value can
represent, and not the frame rate, which is identical either
way. The ordinary table encodes (T + 100) * 10 and spans
-100..+6453 °C in 0.1 °C steps; the high-precision one encodes
(T + 100) * 100: 0.01 °C steps, but clamped at +300 °C. That
is why OperationMode::high_precision_available is a per-range
property of the calibration.
What it does not change today: the step size of the
temperatures this SDK reports. The pipeline carries thermal
pixels as T*10 + 1000 in an i16, so the finer table is built
and then rounded to 0.1 °C. SDK 11's 0.01 °C reporting needs
that representation changed, which is tracked separately.
This call cannot tell you any of that, which is why
Camera::high_precision_state exists: writing true
succeeds and reads back true on every camera, including one
whose calibration offers no finer table, so "not supported" and
"supported and rounded away" are the same observation here.
And 0.01 °C is the step of the encoding, not of the
measurement. The SDK's per-pixel temperature is a lookup on
an integer corrected detector count, so the finest difference
it can distinguish between two pixels is the gap between two
adjacent entries of that table. Measured over the 76 real
characteristic curves on the cameras Optris tests with, each
restricted to the range it belongs to and joined to the
Decimal flag that decides whether a range gets the finer
table at all:
- Only 4 of the 76 can use it, all −20..100 °C, on 4 of 28 cameras. A figure averaged over all 76 answers a different question, because the other 72 never receive it.
- On the best of the four, one adjacent count is 0.0093 K at 100 °C and 0.0274 K at −20 °C, so 0.01 °C exists at the top of that range and nowhere else, and a step guaranteed across the range is 0.0274 K, or 0.0772 K on the worst of the four.
- The single figure 0.0140 K is that range's mean, neither its best nor a guarantee.
So quote a statistic, never a bare number: about 0.0093 K at best, 0.0125 K typically and 0.027 K guaranteed on the best range of the best camera.
SDK 11 genuinely resolved this rather than merely printing it. Its delivered pixel carried centidegrees and its table builder stretched the energy axis to ~200 index steps per kelvin where this one uses 20, so it is a capability SDK 12 lost rather than a number SDK 11 displayed over coarser data.
Implemented here; in earlier releases true was refused.
Errors
pub fn temperature_high_precision_enabled(&self) -> Result<bool>
Whether high precision is on.
The camera-wide request, true by default. Read
Camera::set_temperature_high_precision_enabled before
concluding anything about the step size of the temperatures you
are getting.
Errors
pub fn high_precision_state(&self) -> Result<HighPrecisionState>
Whether the finer step is actually reaching the temperatures you read, and when it is not, why not.
Read this rather than inferring an answer from
Camera::temperature_high_precision_enabled, which reports
the request and answers true on every camera, including
those whose calibration offers no finer table and those where
the pipeline rounds it away. Pairing it with a mode's
high_precision_available gets closer and still cannot see the
rounding, which is the part a caller has no other way to learn.
Answers HighPrecisionState::Unknown on a camera that is not
open rather than failing.
Errors
pub fn set_subsampled_framerate(&mut self, framerate: f32) -> Result<()>
Run the sensor below its native rate, which lowers noise.
Errors
pub fn set_chip_heating(&mut self, mode: ChipHeatingMode, temperature_c: f32) -> Result<()>
How the sensor chip's own temperature is held.
temperature_c is the target for ChipHeatingMode::Fixed and
ignored otherwise, in the SDK's temperature unit (Celsius unless
crate::set_temperature_unit chose Fahrenheit).
Errors
Returns Status::NotSupported on a camera without chip
heating.
pub fn chip_heating(&self) -> Result<(ChipHeatingMode, f32)>
The chip-heating mode and its target, the target in the SDK's temperature unit.
Errors
pub fn set_auto_nuc(
When the camera decides on its own to run a correction.
temp_drift_c is how far the detector may drift before a cycle
is brought forward: a difference in degrees of the SDK's
temperature unit (kelvin-sized in Celsius, Fahrenheit-sized in
Fahrenheit).
Errors
pub fn calibration_status(&self) -> Result<CalibrationStatus>
Whether this camera's calibration was found, and where.
Worth asking. A camera whose calibration is missing still
opens and still streams, and nothing about its frames says they
are not measurements, so CalibrationStatus::Missing is the
only thing that distinguishes a measuring camera from one
producing plausible nonsense.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn calibration_diagnosis(&self) -> Result<String>
Why the calibration is in the state it is, in words.
What a support engineer needs beside
Camera::calibration_status: which files were looked for,
where, and what was found.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn picture_correction(&self) -> Result<PictureCorrection>
What the picture corrections are actually doing.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn rdc_mode(&self) -> Result<RdcMode>
The radial-distortion mode that was asked for.
The counterpart of Camera::set_rdc_mode. For what it is
doing, read PictureCorrection::rdc: a camera whose
calibration carries no coefficients accepts any mode and
corrects nothing.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn sos_correction_enabled(&self) -> Result<bool>
Whether slant-optics correction was asked for.
As Camera::rdc_mode, this is the request. Read
PictureCorrection::sos for what it is doing; there are
three ways for it to be inert and this reports none of them.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn sos_strength(&self) -> Result<f32>
How strongly slant-optics correction is applied.
Zero is a third way for the correction to be inert, beside
"off" and "no table", and SosStatus::ZeroStrength is the
only thing that tells it from the other two.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_sos_strength(&mut self, strength: f32) -> Result<()>
Set it.
Errors
Returns Status::InvalidArgument for a strength outside the
SDK's domain, and Status::NotSupported on a calibration
with no table.
pub fn reference_correction_support(&self) -> Result<ReferenceCorrectionSupport>
Whether this camera can correct against a reference temperature, and why not when it cannot.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn reference_correction_diagnosis(&self) -> Result<String>
Why that is the answer, in words.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn reference_temperature(&self) -> Result<ReferenceCorrection>
The reference-temperature correction in force.
The counterpart of Camera::set_reference_temperature.
It answers on a camera that cannot do the correction
Measured: on a camera whose
Camera::reference_correction_support is not
ReferenceCorrectionSupport::Supported this still returns
Ok, with active false and both temperatures at the SDK's
-100.0 sentinel. So it does not refuse, and -100.0 is not a
reading; ask
Camera::reference_correction_support before showing either
number to anyone.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn has_radiation(&self) -> Result<bool>
Whether this camera has stated its radiation parameters.
Not whether a reader has numbers; Camera::radiation always
hands some back. This asks whether the camera said anything, and
the distinction is load-bearing: a field nobody wrote
reads as its zero initialiser, and a criterion satisfied by the
absence of a reading is how a camera came to report itself
settled on a field that had never been written.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn has_temperature_range(&self) -> Result<bool>
Whether this camera has stated a temperature range.
As Camera::has_radiation, and for the same reason.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn emissivity_conversion_support(&self) -> Result<EmissivityConversionSupport>
Whether this camera can convert a measurement to another emissivity, and why not when it cannot.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn temperature_at_emissivity(
What a measurement would have read at a different emissivity.
measured_c and the answer are both in the SDK's temperature
unit (Celsius unless crate::set_temperature_unit chose
Fahrenheit).
Ok(None) where the conversion cannot be made: a curve that
is not invertible at that point, or a camera with no energy
curve. Ask Camera::emissivity_conversion_support first to
learn which; this one deliberately does not distinguish
"cannot in general" from "cannot here".
Errors
Returns Status::InvalidArgument for an emissivity outside
its domain.
pub fn frame_rate_info(&self) -> Result<FrameRateInfo>
Why the delivered frame rate is what it is.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn measured_frame_rate(&self) -> Result<MeasuredFrameRate>
What the camera is measured to be delivering.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn live_frame_rate(&self) -> Result<LiveFrameRate>
Real frames per second over the time the scene was being
measured: the frame rate to show a user. See LiveFrameRate.
Answers for a camera, the simulated camera and a recording.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn subsampled_framerate(&self) -> Result<f32>
The rate the user frame-rate reducer is delivering at.
The counterpart of Camera::set_subsampled_framerate.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn pipeline_info(&self) -> Result<PipelineInfo>
Which pipeline is processing this camera's frames, and why.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn frame_queue_policy(&self) -> Result<FrameQueuePolicy>
Which frame a full acquisition queue throws away.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn set_frame_queue_policy(&mut self, policy: FrameQueuePolicy) -> Result<()>
Choose it.
FrameQueuePolicy::DropOldest is right for a live display
and FrameQueuePolicy::DropNewest for a recording; the
latter keeps the sequence contiguous, so a gap in the stream is
always a gap in time.
Errors
Returns Status::InvalidArgument for a policy this build of
the library does not know.
pub fn auto_nuc(&self) -> Result<AutoNuc>
The automatic shutter schedule in force.
The counterpart of Camera::set_auto_nuc, which takes the
same four values.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn flag_interval(&self) -> Result<(Duration, Duration)>
The flag interval's bounds, as
Camera::set_flag_interval took them.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn last_nuc_cycle(&self) -> Result<Option<NucCycleReport>>
What the last non-uniformity correction cycle did, or None
before the first one.
Where the None comes from
Not from a status. Measured: on a camera that has run no
cycle the entry point answers OPTRIS_SDK_OK and writes a
report with every field zero, which is indistinguishable, to a
reader, from a real cycle that kept no frames. So the None
here is derived from NucCycleReport::sequence, which the
header documents as monotonically increasing and which is
therefore zero only before the first cycle.
Without that derivation a caller would draw a cycle that never happened: a cycle report of all zeroes renders as a 0 ms capture that kept 0 of 0 frames, and nothing on it says it is not a measurement.
Errors
Returns Status::InvalidHandle if the camera has been
dropped. Status::NotFound is handled as None as well, in
case a future SDK starts reporting it.
pub fn last_shutter_correction(&self) -> Result<Option<ShutterCorrectionEvent>>
What the last shutter correction did, or None before the
first one.
The None is derived from
ShutterCorrectionEvent::sequence, for the reason
Camera::last_nuc_cycle documents.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn clear_shutter_callback(&mut self) -> Result<()>
Stop delivering shutter events.
Errors
pub fn clear_shutter_correction_callback(&mut self) -> Result<()>
Stop delivering them.
Errors
pub fn clear_pipeline_change_callback(&mut self) -> Result<()>
Stop delivering them.
Errors
pub fn clear_nuc_cycle_callback(&mut self) -> Result<()>
Stop delivering them.
Errors
pub fn playback_at_end(&self) -> Result<bool>
Whether a non-looping replay has handed over its last frame.
Ask this rather than comparing the position with the duration, which never becomes equal on a correct file.
Errors
Returns Status::NotSupported on a live camera.
pub fn playback_part(&self) -> Result<(u32, u32)>
Which part of a multipart recording is playing, counting from 0
-- the number in the file's _partNNN suffix -- and how many
parts the replay holds. Added in 12.0.10.
(0, 1) for a replay opened with Camera::from_file, which
holds a single file.
Errors
Returns Status::NotSupported on a live camera.
pub fn recorded_lossy(&self) -> Result<Option<RecordedLossy>>
What the recording's lossy settings were, or None for an
exact recording.
Measured: the ABI answers Status::NotFound here, and its
own message says why: "this recording declares nothing lossy,
which means its samples are exactly what the camera measured:
the block is omitted entirely for an exact recording". That is
a state and not a failure, so it is None rather than an
error. The alternative, handing back a RecordedLossy with
quantize_counts == 0, would be the same answer spelled as
data a caller has to know to re-interpret.
Errors
Returns Status::NotSupported on a live camera.
pub fn recorded_render(&self) -> Result<RecordedRender>
How the recording was being rendered when it was made.
Errors
Returns Status::NotSupported on a live camera.
pub fn region_emissivity_in_frames(&self) -> Result<bool>
Whether a region's own emissivity is applied to the frames it measures, rather than only to its own statistics.
Errors
Returns Status::InvalidHandle if the camera has been
dropped.
pub fn region_signal_slot(&self, id: u64) -> Result<u32>
Which signal slot a region's readings are published in.
What a PIF output or an alarm rule addresses the region by.
Errors
Returns Status::NotFound for an id that has no region.
pub fn is_simulated(&self) -> Result<bool>
Whether this is a simulated camera.
It refuses on a recording rather than answering false
Measured: a handle opened with Camera::from_file answers
Status::NotSupported: "this handle is a recording, not a
camera; only the playback calls apply to it". So this is not
a three-way question answered with a boolean; Ok(false) is a
live camera and an error is a replay or a still. Treating the
error as false would be wrong in the one direction that
matters, because a replay is not a simulated camera and is
not a real one either.
Errors
Returns Status::NotSupported on a recording or a still, and
Status::InvalidHandle if the camera has been dropped.
pub fn simulated_config(&self) -> Result<SimulatedConfig>
The configuration a simulated camera is running.
Errors
Returns Status::NotSupported on anything that is not a
simulated camera.
pub fn update_simulated_scene(&mut self, config: &SimulatedConfig) -> Result<()>
Change what a simulated camera is generating, while it runs.
Only the scene is changed. The geometry and the frame rate are fixed when the camera is opened, because changing them would be a mode switch rather than a scene change; a configuration that moves them is refused.
Errors
Returns Status::NotSupported on anything that is not a
simulated camera, and Status::InvalidArgument for a
configuration the SDK will not take.
pub fn set_simulated_pif_detected_kind(
Make a simulated camera report a process interface of this kind.
For exercising the PIF surface with no hardware. layout is
the channel layout to report, or None for the kind's own
default.
Errors
Returns Status::NotSupported on anything that is not a
simulated camera.
pub fn clear_simulated_pif_external_probe(&mut self) -> Result<()>
Stop a simulated camera reporting an external probe temperature.
The counterpart of Camera::set_simulated_pif_external_probe.
Clearing is a different state from setting zero: a cleared probe
reports nothing, and a probe set to 0 °C reports a
measurement.
Errors
Returns Status::NotSupported on anything that is not a
simulated camera.
pub fn save_config(&mut self, path: &str) -> Result<()>
Write the camera's whole configuration to a file.
This covers the scalar settings, the measuring regions and their alarm rules, the free rules, the canvas placement and the output directory.
Errors
Returns Status::Io if the file cannot be written. The
directory must already exist.
pub fn load_config(&mut self, path: &str) -> Result<()>
Restore a configuration written by Camera::save_config.
This replaces the measuring regions, the alarm rules and the canvas placement. Anything added since the file was written is discarded, and every region gets a new id; ids are assigned on add and are not preserved across a save and load, so look regions up by name afterwards rather than by a stored id.
Errors
Returns Status::Io if the file cannot be read.
pub fn load_config_checked(
Import a configuration file, and say what it did.
The import an application can put a dialog in front of: it
reports which sections the file carried, which are now in effect
and which are not, and require_matching_serial refuses a file
from a different camera outright rather than applying it until
some setting the other model has and this one has not.
Everything that can be checked before the camera is touched is
checked before the camera is touched, so a file that cannot work
here reports ConfigLoadOutcome::Refused with the camera
untouched.
The report arrives on failure too
This is why the report is not in the Ok arm alone. A refusal
and a part-way application are both Err, and both are exactly
the cases where a caller most needs to know what happened,so
the report comes back either way, and
ConfigLoadReport::outcome is what to read first.
The one case with nothing to report is a file that did not parse
at all: there the outcome is ConfigLoadOutcome::Refused with
empty section sets, and the error carries the I/O failure.
Errors
The Err arm carries the report alongside the error. Returns
Status::Configuration for a refusal or a part-way
application, and Status::Io if the file cannot be read or is
not JSON, in which case nothing was changed.
Warning
A successful load replaces the measuring regions, the alarm rules, the motion zones, the colour windows and the canvas placement, and every region gets a new id.
pub fn get_config(&self) -> Result<CameraConfig>
Read the camera's whole configuration back as one record.
Everything Camera::save_config writes: the measurement
parameters, the temperature range, the palette and any custom
colour table, the output directory, the motion zones, the
colour windows, the canvas placement, the measuring regions and
the alarm rules, without a file anywhere in it.
The record is a snapshot and does not track the camera
afterwards. Hand it back to Camera::apply_config to restore
what it holds. See CameraConfig for why it is opaque.
Errors
Returns Status::NotSupported for a recording, which has no
live configuration to read, and Status::OutOfMemory if the
record cannot be allocated.
pub fn apply_config(
Apply a whole configuration record, and say what it did.
The in-memory counterpart of Camera::load_config_checked,
through the same staged applier and reporting in the same
ConfigLoadReport: what cannot work on this camera is decided
while nothing has moved, and only then is anything applied. A
record carrying a temperature range this model has not got comes
back ConfigLoadOutcome::AppliedWithOmissions with the range
named in ConfigLoadReport::omitted, rather than leaving the
camera holding another model's emissivity.
require_matching_serial refuses a record from a different
camera outright, exactly as it does for a file.
CameraConfig::serial is what it is compared against, and can
be read first to put the question to an operator.
ConfigLoadReport::present is always
ConfigSections::ALL. A record always carries every section:
no regions means "no regions", not "absent", which is the one
way it differs from a file, where a section can genuinely be
missing.
The report arrives on failure too
Shaped like Camera::load_config_checked and for the same
reason: a refusal and a part-way application are both Err, and
both are exactly the cases where a caller most needs to know
what happened. So the report comes back either way, and
ConfigLoadReport::outcome is what to read first.
Errors
The Err arm carries the report alongside the error. Returns
Status::Configuration for a refusal or a part-way
application, and Status::NotSupported for a recording.
Warning
This replaces the measuring regions, the alarm rules, the motion zones, the colour windows and the canvas placement, exactly as an import does, and every region gets a new id. Look regions up by name afterwards rather than by an id held across the call.
ConfigLoadOutcome::AppliedWithOmissions: crate::ConfigLoadOutcome::AppliedWithOmissions
pub fn apply_still_config(&mut self, config: &CameraConfig) -> Result<()>
Put a configuration record back onto a still.
A still's own spelling of Camera::apply_config, and it has
to be separate rather than folded into that method because
what it returns is different: a still either re-derives every
pixel or refuses naming what the file cannot do, so there is
no partial apply for a ConfigLoadReport to describe. There
is nothing to report, so nothing is returned.
The serial-matching option has nothing to check against either: the record came out of this same file.
To change the emissivity, use
Camera::set_radiation instead. This cannot do it, and
that is a property of the record rather than of this call: an
optris_sdk_config is opaque and the ABI has no setters on
one, so a record from Camera::get_config carries the
values it was copied with and applying it back changes
nothing. The radiation setter branches onto the still's own
entry point for exactly that reason.
What it is for is restoring a record captured earlier -- palette, colour range, regions, rules -- onto the still it came from.
Errors
Returns Status::NotSupported on a live camera or a
recording, where Camera::apply_config is the spelling, and
when the still carries no radiometry bundle: one saved before
12.0, or from a camera with no characteristic curve. The
temperature range cannot be reached through it at all,
deliberately -- a different range is a different calibration,
and the file holds only the one it was saved in.
pub fn save_device_config_archive(&mut self) -> Result<()>
Write the SDK's own per-camera archive for this camera.
Nothing to do with Camera::save_config: this is the
host-side file the SDK keeps per serial number and reloads the
next time that camera is opened. Calling it is how a program
says "remember these settings for this camera".
It is not a write to the camera's memory. Move the camera to another machine and none of this goes with it.
Does nothing on a simulated camera and on playback, neither of which has an archive.
Errors
Returns Status::Io if the archive cannot be written.
pub fn disable_pre_roll(&mut self) -> Result<()>
Stop keeping a pre-roll buffer and release its memory.
Errors
Returns Status::InvalidHandle if the camera is unusable.
pub fn start_recording(&mut self, path: &str) -> Result<()>
Start recording to an .mkv file.
Success here does not mean the recording will survive
The path is checked: this call opens the output file, so a
directory that does not exist, a permission that forbids writing
or a stick that is not mounted fails here, with a caller to
return the error to, and Camera::is_recording stays false.
What it cannot tell you about is a failure after a successful start: a disk that fills, a drive removed mid-recording, a write refused part way through. Those happen on the recording thread, where there is no caller to report to.
If the recording matters, check the file exists and has grown
after Camera::stop_recording returns. This is a limitation of
the SDK's recording layer, not of this binding, which reports
what it is told.
Errors
Returns Status::InvalidArgument if path contains an
interior NUL byte.
pub fn set_segment_limit_action(&mut self, action: SegmentLimitAction) -> Result<()>
What a recording does when it reaches its segment limit. Added in 12.0.10.
SegmentLimitAction::ContinueSeries, the default, carries on
in the next part of the same recording, which
Camera::from_series replays as one.
SegmentLimitAction::StartNewRecording ends the recording and
starts a new one, named with its own start time.
SegmentLimitAction::StopRecording (12.0.28) ends the recording
at the limit, with crate::RecordingStopReason::SegmentLimit.
Applies to every recording started afterwards, by the application
or by an alarm rule, and has no effect on one with no segment
limit.
Errors
Returns Status::NotSupported on a replay or a still, and
Status::InvalidArgument for a value this library does not
know.
pub fn segment_limit_action(&self) -> Result<SegmentLimitAction>
What Camera::set_segment_limit_action last set.
Errors
Returns Status::NotSupported on a replay or a still.
pub fn stop_recording(&mut self) -> Result<()>
Stop the current recording and close the file.
Stopping when nothing is recording succeeds and does nothing.
A recording in parts has reported every part it finished by the
time this returns: Stopped is
delivered only after each
SegmentCompleted of
those parts has been delivered and its callback has returned, so
those parts and the one the stop ends are every file of the
recording. A recording callback still running for such a part
holds this call up until it returns, for at most 5 seconds, so it
must never wait for the thread that calls this one.
Errors
pub fn is_recording(&self) -> Result<bool>
Whether a recording is running.
Read the warning on Camera::start_recording before trusting
this to mean bytes are reaching a disk.
Errors
pub fn recording_stats(&self) -> Result<RecordingStats>
What the current, or last, recording did with its frames.
The only honest answer to "did the recording work".
Camera::start_recording opens the container, so an
unwritable path fails there, but a disk that fills, a drive
pulled mid-recording or a write refused part way through happens
on the recording thread, long after the call returned, where
there is no caller to report to. Camera::is_recording still
reports true through all of it.
So read this after a recording and assert on
RecordingStats::frames_lost. The figures are reset when a
recording starts and kept after it stops, so they are still
readable once the file is closed.
Errors
pub fn set_output_directory(&mut self, directory: &str) -> Result<()>
Where snapshots and recordings go when whatever started them did not name a directory: an alarm rule, typically.
Errors
Returns Status::InvalidArgument if directory contains an
interior NUL byte.
pub fn output_directory(&self) -> Result<String>
Read the output directory.
Errors
pub fn save_snapshot(&mut self, path: &str, format: SnapshotFormat) -> Result<()>
Write the frame this source is showing to a still image.
The format matters, because only one of them keeps the
temperatures, see SnapshotFormat.
Works on all three kinds of source, not only on a live
camera. On a recording from Camera::from_file it writes
the frame the replay is showing, the moment found while
scrubbing; on a still from Camera::open_still it writes what
that still is measuring. Both used to return
Status::NotSupported. See Camera::save_snapshot_with for
which metadata fields such a file can lack.
Errors
Returns Status::Io if the file cannot be written, or if
nothing has been delivered yet.
pub fn save_snapshot_with(
Write the most recent frame to a still image, with metadata and encoder settings.
Everything Camera::save_snapshot does, plus the two things
it could not express. The camera's identity, radiometry and
measurement range are still filled in for you; anything set
explicitly in info wins.
extra_json is a JSON object merged into the metadata
document at the top level; keys the schema already uses are not
overwritten. It is separate from info because it has no
length bound, and so that the one type can serve reading as
well as writing.
Any registered attachment provider is pulled as the file is
opened, see Camera::set_attachment_provider.
Examples
# fn main() -> optris_sdk::Result<()> {
use optris_sdk::{Camera, SnapshotFormat, SnapshotInfo, SnapshotOptions};
let mut camera = Camera::open()?;
camera.start()?;
let info = SnapshotInfo {
emissivity: Some(0.93),
description: "north bearing, shift 2".to_string(),
..SnapshotInfo::default()
};
camera.save_snapshot_with(
"shift2.png",
SnapshotFormat::Png,
Some(&info),
Some(&SnapshotOptions::default()),
Some(r#"{"layout":"line 4 overview"}"#),
)?;
# Ok(())
# }
Errors
Returns Status::Io if the file cannot be written or if
nothing has been delivered yet, and Status::InvalidArgument
for a scale that cannot represent the frame or for a field longer
than the ABI's fixed capacity for it.
On a replay or a still
Accepted on all three kinds of source. Both spellings used to
return Status::NotSupported for the other two.
A field the source file does not carry is left out rather than
written as a default. A file stating an emissivity nobody set
cannot be told apart from one stating the emissivity an operator
chose, so the radiometry, the measurement range, the device
record and the field of view can each be absent; read each as
"not recorded" rather than as zero. The characteristic curve and
the radiometry bundle are carried forward byte for byte when the
source had them, so the new file can be reopened with
Camera::open_still and measured at another emissivity exactly
as the source can.
Three further differences from a live snapshot, all deliberate:
the recorded render reports no overlays, because only the GPU
pipeline composites them and neither source has one; attachment
providers are not pulled, because they are a camera's registry,
so pass your own files on info; and a replay that nothing is
displaying has no colour scale, so its snapshot is the 16-bit
greyscale form, the same rule a camera follows with no live view.
pub fn save_csv_snapshot(
Write the frame this source is showing as a CSV snapshot,
spelled the way csv asks.
Camera::save_snapshot_with with SnapshotFormat::Csv, plus
the choice of delimiter, decimal separator, how an unmeasured
pixel is written and whether the # header lines appear, so a
spreadsheet set to a German or French locale opens the file as
numbers. CsvOptions::default writes exactly the CSV
Camera::save_snapshot writes. Metadata in info is handled
exactly as there, on a camera, a replay or a still. An alarm's
snapshot action writes its CSV in the default spelling.
Examples
# fn main() -> optris_sdk::Result<()> {
use optris_sdk::{Camera, CsvOptions};
let mut camera = Camera::open()?;
camera.start()?;
let csv = CsvOptions::default().with_delimiter(';').with_decimal_separator(',');
camera.save_csv_snapshot("capture.csv", &csv, None)?;
# Ok(())
# }
Errors
Returns Status::InvalidArgument for a delimiter other than
',', ';' or '\t', a decimal separator other than '.' or
',', or the two being the same character, and nothing is
written then; Status::Io on the same terms as
Camera::save_snapshot_with.
pub fn clear_attachment_provider(&mut self) -> Result<()>
Stop supplying attachments.
Files written afterwards carry none. The closure itself is still retained until the camera is dropped, because the ABI has no handshake that says a provider already in flight has finished.
Errors
pub fn is_playback(&self) -> Result<bool>
Whether this camera is a recording being replayed rather than hardware.
Errors
pub fn attachment_count(&self) -> Result<usize>
How many files the recording being replayed carries.
Errors
Returns Status::NotSupported on a live camera, which
carries nothing.
pub fn attachment_info(&self, index: usize) -> Result<AttachmentInfo>
Describe one carried file by index, from 0, in container order.
Errors
Returns Status::NotSupported on a live camera and
Status::InvalidArgument for an index past the end.
pub fn attachments(&self) -> Result<Vec<AttachmentInfo>>
Describe every file the recording being replayed carries.
The same enumeration, at the same positions, as
crate::RecordingFile::attachments on the same file;
two ways in, because there are two questions: this one when
the recording is already open for playback, and
crate::RecordingFile when it is a path in a folder listing
and no decoder is wanted.
Errors
pub fn read_attachment(&self, index: usize) -> Result<Vec<u8>>
Copy one carried file's bytes out of the recording being replayed.
Errors
pub fn seek_to_frame(&mut self, frame_index: u64) -> Result<()>
Jump to a frame, counted from the start of the recording.
Not a no-op on a live camera
The header says the playback calls are "accepted and do nothing"
on a live camera, so that one piece of code can drive both
without branching. They are not: every call in this group returns
Status::NotSupported on a camera that is not a recording.
Branch on Camera::is_playback first.
Errors
Returns Status::NotSupported on a live camera.
pub fn seek_to_timestamp_us(&mut self, timestamp_us: u64) -> Result<()>
Jump to a point in the recording, in microseconds from its start.
Errors
pub fn pause_playback(&mut self) -> Result<()>
Stop advancing, holding the current frame and position.
Not Camera::stop, which ends the run: a paused replay is
still open, still at the frame it was on, and still seekable, so
Camera::resume_playback carries on from there. Do not reach
for a Camera::set_playback_speed of zero instead -- the
pacing divides the frame interval by the speed, so zero plays
the file as fast as the disk allows. It is refused.
A paused replay produces nothing. Every frame a consumer
sees is one the decode thread pushed, so a setting changed while
paused does not reach the picture until the replay resumes. Call
Camera::refresh_playback to see it now.
A no-op on a replay that is not running or is already paused.
Errors
Returns Status::NotSupported on a live camera, which has no
transport to pause.
pub fn resume_playback(&mut self) -> Result<()>
Carry on from where Camera::pause_playback stopped.
A no-op on a replay that is not running or is not paused.
Errors
Returns Status::NotSupported on a live camera.
pub fn is_playback_paused(&self) -> Result<bool>
Whether the replay is paused.
Distinct from "not running": a stopped replay is not paused, and
both answer false here. Pair it with Camera::is_running.
Errors
Returns Status::NotSupported on a live camera.
pub fn refresh_playback(&mut self) -> Result<PlaybackRefresh>
Re-process the frame now held and deliver it again.
The call for a paused replay whose settings have changed. Pausing halts the decode thread and a paused replay therefore produces nothing, so changing the emissivity, the orientation or the palette while paused left the picture on screen exactly as it was until the replay was resumed. Seeking to the frame already showing was not a way around it either.
Re-runs the whole delivery path from the frame as the decoder
handed it over, so the frame callback and
Camera::acquire_frame see it exactly as they see a decoded
one.
It deliberately leaves three things alone: the position, because the same frame was delivered again; the alarm rules, because a refresh is the same instant measured again rather than a new observation, and evaluating would let a caller walk a delayed alarm to firing by refreshing a standing picture; and the colour scale, which is temporally damped, so re-filtering would draw a slightly different picture on every call.
What a recording can be told after the fact
- The global emissivity, transmissivity and ambient reach the
pixels, when
Camera::playback_can_change_radiation. - A region's own emissivity reaches that region's numbers
only, never the picture, when
Camera::playback_honours_region_emissivity. The region then reportsOPTRIS_SDK_REGION_EMISSIVITY_READING_ONLY. - Orientation, palette, colour range, auto-scale and isotherms reach the picture on any radiometric recording.
- The temperature range reaches nothing and is refused: a different range is a different calibration.
- Size-of-source correction, the noise filters and detail enhancement reach nothing and cannot be set on a replay at all -- they need a pipeline backend and a replay has none. That is why a refresh cannot quietly honour part of what it was asked for.
Returns one of PlaybackRefresh::Delivered,
PlaybackRefresh::NoHeldFrame, PlaybackRefresh::Running
or PlaybackRefresh::PictureRecording. Only the first put a
frame out; the other three are the three ways nothing happens,
kept apart because a program showing a picture acts differently
on each.
The frame callback runs on the calling thread here, unlike a decoded frame which arrives on the decode thread. Do not call this from inside a frame callback: the delivery path is serialised, so it would wait on the pass it is inside.
Errors
Returns Status::NotSupported on a live camera, which
delivers frames of its own and needs nothing re-delivered.
pub fn playback_can_change_radiation(&self) -> Result<bool>
Whether this recording's global radiation can be changed and have it reach the delivered pixels.
Ask this rather than writing the emissivity to find out: a user interface wants to grey the slider out, and an error return is a poor way to discover that. Fixed when the file is opened.
true when the recording carries a radiometry bundle that
reproduces the characteristic curve the file also carries. The
energy each stored temperature came from is then recovered
through that curve and read back out of a table rebuilt at the
new value -- the table the camera itself would have built. It
costs the stored tenth of a kelvin and nothing else: measured,
0.20 K at emissivity 0.90 and 0.30 K at 0.50.
false for a recording written before the bundle was carried,
for one from a camera with no characteristic curve, and for one
whose bundle does not reproduce its own curve. Writing the
radiation then returns Status::NotSupported.
Says nothing about a region's own emissivity, which goes through
the curve alone and needs no bundle --
Camera::playback_honours_region_emissivity is that question.
Errors
Returns Status::NotSupported on a live camera.
pub fn playback_honours_region_emissivity(&self) -> Result<bool>
Whether a per-region emissivity reaches that region's numbers on this recording.
Honouring a region's own emissivity means undoing the correction at the camera's value and redoing it at the region's, and both directions go through the camera's characteristic curve. A recording holds finished temperatures, so that curve is the one thing needed to invert them.
The picture is never corrected either way. A replay runs no
pipeline backend, so there is nothing to apply a per-region
emissivity map in; such a region reports
OPTRIS_SDK_REGION_EMISSIVITY_READING_ONLY to say exactly that,
and a refresh after changing it moves the region's statistics
and not one pixel. Read the state rather than assuming the image
agrees with the number beside it.
false for a recording written before the curve was carried and
for one from a camera that has none. The region then reads at
the camera's own emissivity and
OPTRIS_SDK_REGION_EMISSIVITY_CAMERAS says so.
Errors
Returns Status::NotSupported on a live camera.
pub fn set_playback_speed(&mut self, speed: f32) -> Result<()>
Set the replay speed. 1.0 is real time.
Errors
pub fn playback_speed(&self) -> Result<f32>
The replay speed.
Errors
pub fn set_loop(&mut self, looping: bool) -> Result<()>
Start again from the beginning when the recording ends.
Errors
pub fn is_looping(&self) -> Result<bool>
Whether looping is on.
Errors
pub fn playback_duration_us(&self) -> Result<u64>
How long the recording is, in microseconds. Zero on a live camera.
Errors
pub fn playback_start_time_us(&self) -> Result<u64>
When the recording started, in microseconds since the Unix epoch (UTC): the file's creation time.
For a recording made from a camera, when the recording began, to
the second. For one converted from a PIX Connect .ravi by
crate::ravi::import, when the original was recorded rather
than when it was converted. Add
Camera::playback_position_us for the wall-clock time of the
frame on screen.
Zero when the file does not say: one written by something other than this SDK, or with the tag stripped.
Errors
crate::Status::NotSupported on a live
camera or a still, as the other playback calls.
pub fn playback_time_zone(&self) -> Result<Option<RecordingTimeZone>>
The time zone the recording was made in, beside the UTC start
Camera::playback_start_time_us gives.
The recording computer's zone for a recording of a camera; the
one given (or, marked RecordingTimeZone::assumed, the one
taken) at conversion for one converted from a PIX Connect .ravi.
None for a recording that does not say: one made by an SDK
release before this existed, or by another program.
Errors
crate::Status::NotSupported on a live camera or a still, as
the other playback calls.
pub fn playback_position_us(&self) -> Result<u64>
How far into the recording we are, in microseconds from its first frame.
An offset into the file, the same thing
Camera::seek_to_timestamp_us takes, so it never exceeds
Camera::playback_duration_us. It is not the replayed
frame's capture stamp, which counts from an epoch belonging to
the transport the recording was made on.
Errors
pub fn last_seek_walked_frames(&self) -> Result<u64>
How many frames the last seek decoded without delivering them.
A recording this SDK writes is not all-intra, so a seek can only start the decoder at the anchor at or before its target; the frames between are decoded and discarded, which is what makes a seek frame-accurate. This is what that cost. Zero after a seek that landed on an anchor, and zero before the first seek.
Counted, not estimated. For what a seek will cost, before
paying for it, build a crate::FrameIndex over the file;
crate::FrameIndex::anchor_for answers it without decoding
anything.
The walk is unpaced: a seek costs decode time rather than the playback time of the frames it steps over.
Errors
Returns Status::NotSupported on a live camera and on a
still. There is no seek on either, so zero would be a number
standing in for "the question does not apply".
pub fn last_seek_replayed_records(&self) -> Result<u64>
How many region records the last seek replayed without decoding anything.
A seek's second cost, bounded by a different distance from
Camera::last_seek_walked_frames, which is why there are two
numbers rather than one. The picture reaches back to the video
anchor; the region state reaches back to wherever it was last
known, which can be much further, because a region's definition
is written on the frame it first appeared on.
A seek forward replays only the records between where the state was last known and the target, so a scrub forward costs the same per frame crossed however long the file is. A seek backward starts from the beginning of the file (a record is a delta and nothing un-applies one), so its cost is proportional to where it lands. That is the figure to plan a scrub against on a long recording.
Errors
As Camera::last_seek_walked_frames.
pub fn set_palette(&mut self, palette: Palette) -> Result<()>
The colour map for the RGBA and RGB output.
Display only: no palette has ever moved a measured temperature.
Errors
pub fn palette(&self) -> Result<Palette>
Which palette is active.
Errors
pub fn set_palette_by_name(&mut self, name: &str) -> Result<()>
Colorize with a palette from the machine's palette library.
name comes from crate::palette::library::names. This is a
convenience over reading the colours and setting them as a
custom palette, and it behaves as exactly that:
Camera::custom_palette_name afterwards reports name, and
Camera::clear_custom_palette undoes it.
For one of the SDK's own palettes, Camera::set_palette is
cheaper and survives a configuration round trip as a number
rather than a string.
Errors
crate::Status::NotFound when the machine has no palette by
that name; otherwise as Camera::disable_pre_roll.
pub fn set_custom_palette(&mut self, name: &str, colors: &[Rgb24]) -> Result<()>
Colorize with colours your own code supplies.
colors is coldest first and must be exactly
crate::palette::PALETTE_COLOR_COUNT long; the length is
fixed for every palette. A table whose every entry is the same
colour is refused by the SDK, because it would produce a flat
picture with no information in it.
This overrides Camera::palette without replacing it: that
still reports the built-in the camera returns to when this is
cleared.
Errors
crate::Status::InvalidArgument when colors is the wrong
length, which is checked here so the message names both the
required count and the one given; otherwise as
Camera::disable_pre_roll.
pub fn clear_custom_palette(&mut self) -> Result<()>
Stop using a custom palette, and go back to Camera::palette.
Errors
pub fn custom_palette_name(&self) -> Result<Option<String>>
The custom palette in force, or None when there is none.
The ABI reports "no custom palette" as
crate::Status::NotFound. That is right for C, where the two
cases have to be distinguishable without an out-of-band value,
but in Rust the absence is what Option is for and making every
caller match on an error kind would be worse. So the absence is
translated and only the absence: any other failure still errors.
Errors
pub fn custom_palette_colors(&self) -> Result<Option<Vec<Rgb24>>>
The colours of the custom palette in force, coldest first.
None when there is no custom palette; see
Camera::custom_palette_name for why that is not an error.
Errors
pub fn set_color_range(&mut self, min_c: Option<f32>, max_c: Option<f32>) -> Result<()>
Fix the temperatures the palette spans, in the SDK's temperature
unit (Celsius unless crate::set_temperature_unit chose
Fahrenheit).
None on either end lets the SDK track the scene's own extreme.
Auto-scaling makes a room-temperature scene legible, and makes two moments incomparable: an object leaving the frame re-colours everything that stayed. Fix the range whenever the picture is meant to be read rather than merely watched.
Errors
pub fn set_color_window(&mut self, id: u32, window: ColorWindow) -> Result<()>
Draw one temperature band in colour over a grayscale base.
Setting the same id again replaces it.
Errors
Returns Status::InvalidArgument if the band is not usable.
pub fn remove_color_window(&mut self, id: u32) -> Result<()>
Remove one colour window.
Errors
Returns Status::NotFound if the id is unknown.
pub fn clear_color_windows(&mut self) -> Result<()>
Remove every colour window.
Errors
pub fn set_overlay_compositing(&mut self, enabled: bool) -> Result<()>
Whether the SDK draws the region outlines into the RGBA frame it delivers.
Where the picture is made decides the default. A camera whose
picture is made on the graphics card (a GPU backend) draws them
unless this is set to false, and leaves them out while an
orientation is set. A camera on the CPU pipeline, the simulated
camera and a recording draw them only once this has been set to
true.
To draw them yourself at display resolution, set false and
call Camera::composite_overlays, which does not scale up
from the thermal frame's size.
Errors
pub fn overlay_compositing(&self) -> Result<bool>
The overlay compositing setting, as
Camera::set_overlay_compositing last left it: true on a
fresh camera or recording, on every backend.
It reports the setting, not the picture. On the CPU pipeline,
the simulated camera and a recording it reads true while no
outlines are drawn, until the setter has been called. Whether a
saved picture has outlines in it is
SnapshotRender::overlays.
There was no reader before v12, so an application had to cache
what it wrote.
Errors
pub fn set_display_temperature_unit(&mut self, unit: TemperatureUnit) -> Result<()>
Show temperatures in unit wherever the SDK itself turns one
into text for a person to read.
That is the reading in a region's label drawn into the picture
(the show_label style flag), on the colour image, on the GPU
surface and in a snapshot's picture, and the "The scene measured
... to ..." line a JPEG snapshot opens with. Each is converted
and rounded by crate::temperatures::format, so a label and
your own text for the same reading agree to the last digit. In
Fahrenheit a label reads INLET 70.3F where it read
INLET 21.3C.
Display only. It chooses the unit of this camera's own text
and nothing else. The unit of every number this API takes and
returns is crate::set_temperature_unit's, for the whole SDK.
Everything written for a program to read stays in Celsius: the
radiometric PNG and TIFF, the metadata in every snapshot, and
log lines. A CSV snapshot keeps its own
crate::CsvOptions::with_temperature_unit.
Until it is called, this camera draws in the SDK's unit (Celsius by default), so a program that sets only that gets Fahrenheit labels too. Once called, it is this camera's choice whatever the SDK's unit. With both left at Celsius every picture and file is byte for byte what it was before this call existed. Works on a camera, a recording and a still (a still draws no region labels, so there it is the JPEG line alone).
Errors
Status::InvalidArgument for TemperatureUnit::Other,
which changes nothing.
pub fn display_temperature_unit(&self) -> Result<TemperatureUnit>
The unit Camera::set_display_temperature_unit last set; the
SDK's unit (crate::temperature_unit) until it is called.
Errors
pub fn composite_overlays(&self, bgra: &mut [u8], width: u32, height: u32) -> Result<()>
Draw the region overlays onto a caller-supplied BGRA buffer at any size.
bgra must hold at least width * height * 4 bytes.
Works on a camera and on a recording. Without a GPU backend, which a recording never has, the overlays are drawn on the CPU instead, so a missing GPU is not an error.
Errors
Returns Status::InvalidArgument if the buffer is the wrong
size, or Status::NotSupported if there is nothing to draw or
the camera is a still opened with Camera::open_still.
pub fn set_motion_zone(&mut self, id: u32, zone: MotionZone) -> Result<()>
Watch an area for movement.
Setting the same id again replaces it.
Errors
Returns Status::InvalidArgument if the zone is not usable.
pub fn remove_motion_zone(&mut self, id: u32) -> Result<()>
Stop watching one zone.
Errors
Returns Status::NotFound if the id is unknown.
pub fn clear_motion_zones(&mut self) -> Result<()>
Stop watching every zone.
Errors
pub fn remove_external_buffer(&mut self, data: *mut u8) -> Result<()>
Stop writing into a buffer, by the address it was registered with.
Returns once the SDK will no longer write there, so the buffer can be freed afterwards.
Errors
Returns Status::NotFound if no buffer was registered at that
address.
pub fn clear_external_buffers(&mut self) -> Result<()>
Stop writing into every registered buffer.
Errors
pub fn gpu_instance(&self) -> Result<Option<*mut c_void>>
The SDK's WebGPU instance, as a raw WGPUInstance.
None when there is no GPU backend. Owned by the SDK: do not
release it.
This crate does not wrap wgpu, so the handle is handed over as
a raw pointer for a caller who does.
Errors
pub unsafe fn configure_surface(
Render every frame straight to a surface, at display resolution.
Safety
surface must be a live WGPUSurface created against the
instance from Camera::gpu_instance, and must not be destroyed
while it is configured.
The C header is explicit that this pointer is not validated and
cannot be; it belongs to another library. Passing anything
else is undefined behaviour, and in practice a segfault inside
the graphics driver on the first frame rather than a returned
error. On a camera with no GPU backend the call returns
Status::NotSupported before looking at it, which means a bad
handle can appear harmless on one camera and be fatal on the
next. That asymmetry is why this is unsafe.
Errors
Returns Status::NotSupported if there is no GPU backend.
pub fn has_surface(&self) -> Result<bool>
Whether a surface is configured.
Errors
pub fn open_with(options: &CameraOptions) -> Result<Self>
Open the first camera found, with options.
Errors
As Camera::open, plus crate::Status::Configuration if
CameraOptions::operation_mode names a mode this camera does
not have.
pub fn open_device_with(device: &DeviceInfo, options: &CameraOptions) -> Result<Self>
Open a specific camera, with options.
Errors
As Camera::open_with, plus crate::Status::NotConnected
if the device has gone away since it was enumerated.
pub fn open_network_with(target: &NetworkTarget, options: &CameraOptions) -> Result<Self>
Open a camera over Ethernet, with options.
Never falls back to USB, see Camera::open_network.
The timeouts come from the target, not from the options
CameraOptions::connect_timeout and
CameraOptions::discovery_timeout have no effect on this
call. Both bounds also live on NetworkTarget, the SDK
fills that record with the defaults so it never looks unset,
and it is applied last, so a bound asked for through the
options is silently discarded here. Measured against a
documentation-range address: 200 ms on the options costs
3040 ms, the SDK's own default, while 200 ms on the target
costs 608 ms.
So use NetworkTarget::connect_timeout_ms and
NetworkTarget::discovery_timeout_ms for the bounds, and the
options for the calibration settings and the operation mode,
which a target cannot express. The options' pair is the bound
for Camera::open_with and Camera::open_device_with,
which take no target.
Errors
As Camera::open_network and Camera::open_with.
pub fn add_region(&mut self, region: &Region) -> Result<u64>
Add a region to the camera.
The region is copied; the builder stays yours. Children (hot and cold spots, blob groups) receive ids of their own.
Examples
use optris_sdk::{Camera, Region};
# fn main() -> optris_sdk::Result<()> {
let mut camera = Camera::open()?;
let mut region = Region::circle((0.5, 0.375), 0.1)?;
region.set_name("bearing")?;
let id = camera.add_region(®ion)?;
# Ok(())
# }
Errors
Returns Status::InvalidArgument if the geometry is degenerate
or exceeds the depth and node caps.
pub fn add_child_region(&mut self, parent_id: u64, region: &Region) -> Result<u64>
Add a region as a child of an existing one, so it measures through its parent.
A child is measured through its parent's geometry: a region of
kind crate::enums::RegionKind::HotSpot added this way follows
the warmest pixel inside the parent rather than across the whole
frame, and a spot's aperture is clipped to it. Without this a
hot-spot region could only track the whole scene.
The child is a region in every other respect (its own id, its own statistics, its own alarm rules, its own name), and every per-id call takes it.
A child is not a blob. Blobs are per-frame detection results whose ids churn on every frame, which is why they are deliberately not children. A child region is declared once and keeps its id until it is removed, so a rule naming one is never orphaned.
Children do not appear in Camera::read_region_states: a child's
alarm already rolls up into its parent's state, so listing it
separately would count it twice. Enumerate them with
Camera::region_children.
Errors
Returns Status::NotFound if parent_id is unknown, and
Status::InvalidArgument if the child's geometry is
degenerate.
pub fn region_children(&self, parent_id: u64) -> Result<Vec<u64>>
The ids of one region's direct children, in the order they were added.
Empty for a region with none, and for an unknown id.
Errors
Returns an error only if the handle is not usable.
pub fn remove_region(&mut self, id: u64) -> Result<()>
Remove a region and every rule attached to it.
Errors
Returns Status::NotFound if the id is unknown.
pub fn clear_regions(&mut self) -> Result<()>
Remove every region.
Errors
Returns Status::InvalidHandle if the camera is unusable.
pub fn region_count(&self) -> Result<usize>
How many regions the camera holds.
Errors
pub fn region_ids(&self) -> Result<Vec<u64>>
The id of every region the camera holds, top level only.
Children (hot and cold spots, nested areas) are not listed; they are reached through their parent.
Errors
pub fn region_id_by_name(&self, name: &str) -> Result<Option<u64>>
Find a region by name.
Returns Ok(None) if no region has that name, because looking
for something that is not there is a question, not a failure.
Errors
Returns Status::InvalidArgument if name contains an
interior NUL byte.
pub fn region_stats(&self, id: u64) -> Result<RegionStats>
Read one region's most recent measurement.
Check RegionStats::valid before using the numbers: a region
that has not been measured yet reports invalid rather than zero
temperatures that look real.
Errors
Returns Status::NotFound if the id is unknown.
pub fn read_region_states(&self) -> Result<Vec<RegionState>>
Read every region's state in one pass.
One lock and one copy of a dense array: this is what a live display should call per frame, rather than a getter per region.
Errors
pub fn region_percentiles(&self, id: u64) -> Result<Option<RegionPercentiles>>
One region's temperature distribution for the most recent frame.
None unless the region was built with
crate::Region::want_percentiles (it costs extra work per frame
and is off by default) or if it has not been measured yet.
That is a None rather than a struct of zeroes, which would
read as a very cold region.
Errors
Returns Status::NotFound if there is no region id.
pub fn region_threshold_share(&self, id: u64) -> Result<Option<RegionThresholdShare>>
How much of one region was past its threshold on the most recent frame.
None unless the region was built with a
crate::ThresholdConfig (it is off by default) or if it
has not been measured yet. That is a None rather than a share
of zero, which would read as "none of it was hot".
Errors
Returns Status::NotFound if there is no region id.
pub fn region_emissivity_state(&self, id: u64) -> Result<RegionEmissivityState>
Whether a region is being measured at an emissivity of its own, and what that does to the picture.
See RegionEmissivityState. Recomputed on every measured
frame against the emissivity that frame was corrected at, not
the one currently configured; the two differ on a replayed
recording and for a frame or two after a settings change. This
is what a label draws to say an area is not on the same
emissivity as everything around it.
Errors
Returns Status::NotFound if there is no region id.
pub fn region_is_from_recording(&self, id: u64) -> Result<bool>
Whether a region belongs to the recording being replayed, as against having been added on the playback handle afterwards.
The question an application reviewing footage has to answer
about every region it shows: a recorded region is the file's
statement about what was measured, and one the operator drew
during the review is the operator's. The two are
indistinguishable through Camera::region.
Ask this rather than comparing the id against 2<sup>32</sup>. Regions added on a replay are numbered from that floor, so "a low id is the recording's" happens to hold today, as a numbering convention, which nothing promises to keep. It is also not the whole answer even now: a region born mid-replay from a per-frame record is the recording's, carries a recorded id, and did not exist when the file was opened; and one the take deleted stops being the recording's on the frame it goes. A comparison sees neither.
false on a live camera, on a still and for an unknown id, in
every case because nothing there is a recording's rather than
as a refusal, so this is callable on a handle whose kind is not
known, and an id whose region was removed a frame ago answers
false instead of failing.
It says nothing about whether the region can be edited. A
replay accepts an edit to a recorded region. The next per-frame
record naming it sets again what the recording states (where it
is, its shape, name, style and emissivity, and its minimum,
maximum, mean, coverage and alarm state), so an edit to any of
those lasts one frame. Which optional statistics it computes
(crate::Region::want_percentiles for the median and
percentiles, the threshold, the samples) is yours once you
change it: the replay computes them from the recorded
temperatures, and no record changes the choice after that,
including when a seek removes the region and a later record
brings it back. A computed statistic is withheld (NaN, None)
on a frame the record says the region was not measured, and for
a region with an emissivity of its own whose recorded pixels do
not carry it.
Errors
Returns an error only if the handle itself is unusable; an
unknown id is Ok(false).
pub fn region_samples(&self, id: u64) -> Result<Vec<RegionSample>>
The individual pixel readings one region took on the most recent frame: the temperature profile along a line region.
Empty unless the region was built with
crate::Region::want_samples. An empty profile is not an
error: a region that keeps no samples reports a count of zero,
so forgetting to ask gives a blank rather than a failure.
A profile is per-frame and its length varies with the region's
geometry and the frame size, so this allocates a Vec sized to
the count the SDK reports. The SDK itself allocates nothing per
frame to produce it.
Errors
Returns Status::NotFound if there is no region id.
pub fn region_blobs(&self, id: u64) -> Result<Vec<RegionBlob>>
The blobs one crate::RegionKind::BlobGroup region found on
the most recent frame.
Empty for any other kind, and empty for a blob group that found
nothing or has not yet seen a frame, which is a different
answer from Status::NotFound, meaning there is no such
region. Configure detection with
crate::Region::set_blob_config before adding the region.
Each blob's outline is fetched with it when the region asked for
crate::BlobRenderMode::Contour, so a caller never has to
make the second call by hand.
Errors
Returns Status::NotFound if there is no region id.
pub fn worst_alarm_state(&self) -> Result<AlarmState>
The worst alarm state across every rule on the camera.
Errors
pub fn update_region(&mut self, id: u64, source: &Region) -> Result<()>
Replace an installed region's geometry and settings, keeping its identity.
This is how a user interface drags a measuring box. The change is applied under the same lock the frame thread takes to measure, so editing while frames arrive is safe, and (unlike removing and re-adding) the region keeps its id and its signal slot, so every rule already attached to it stays valid.
Errors
Returns Status::NotFound if the id is unknown.
pub fn region(&self, id: u64) -> Result<Region>
A copy of an installed region, as a builder.
Pair with Camera::update_region to read, change and write
back.
Errors
Returns Status::NotFound if the id is unknown.
pub fn add_rule(&mut self, region_id: u64, rule: &Rule) -> Result<u64>
Install a rule, which the camera copies.
region_id is the region the rule belongs to, or 0 for a rule
attached to none: a process-interface alarm, a device alarm, or
one on an application value. When the rule's input names a region
signal, its index is filled in from this, so the common case
never has to look a slot up.
Errors
Returns Status::InvalidArgument if the region is unknown or
the rule does not describe something evaluable.
pub fn remove_rule(&mut self, rule_id: u64) -> Result<()>
Remove a rule.
Errors
Returns Status::NotFound if the id is unknown.
pub fn update_rule(&mut self, rule_id: u64, rule: &Rule) -> Result<()>
Replace an installed rule, keeping its id.
Validated before it is applied: a rejected change leaves the rule exactly as it was rather than half-applied.
Errors
Returns Status::NotFound if the id is unknown, if the rule's
region has since been removed, or if the new state is not
evaluable. A refused edit is Status::NotFound, not the
Status::InvalidArgument that Camera::add_rule returns; the
error's message says which it was.
pub fn rule_region(&self, rule_id: u64) -> Result<u64>
The region a rule was attached to, or 0 for a free rule and for an unknown id.
A region rule's own input names a generational slot, not a
region id, and the slot is filled in by
Camera::add_rule; nothing on the Rule itself names the
region. Without this a rule read back with Camera::rule is
a condition on "some region".
Errors
As Camera::rule_ids.
pub fn rule(&self, rule_id: u64) -> Result<Rule>
A copy of an installed rule, as a builder.
Errors
Returns Status::NotFound if the id is unknown.
pub fn rule_ids(&self) -> Result<Vec<u64>>
The ids of every installed rule.
Errors
pub fn alarm_state(&self, rule_id: u64) -> Result<AlarmState>
The state of one rule.
Errors
Returns Status::NotFound if the id is unknown.
pub fn alarm_runtime(&self, rule_id: u64) -> Result<(AlarmState, bool)>
The state of one rule, and whether its latch is the only thing holding it active.
The second element is true only when the state is
AlarmState::Active and the condition itself has released,
so Camera::acknowledge_alarm will clear it. When it is
false, acknowledging an active alarm re-arms the latch and
changes nothing. Always false for a non-latching rule.
Errors
Returns Status::NotFound if the id is unknown.
pub fn region_alarm_state(&self, region_id: u64) -> Result<AlarmState>
The worst state across every rule attached to one region.
Errors
Returns Status::NotFound if the region id is unknown.
pub fn acknowledge_alarm(&mut self, rule_id: u64) -> Result<()>
Release a latch.
If the condition still holds the alarm stays active and the latch re-arms: acknowledging a ringing alarm never silences it.
Errors
Returns Status::NotFound if the id is unknown.
pub fn acknowledge_all_alarms(&mut self) -> Result<()>
Release every latch, with the same rule as above.
Errors
pub fn read_alarm_log(&self) -> Result<Vec<AlarmEvent>>
The most recent state transitions, oldest first.
For a display that repaints faster than it wants to subscribe.
Errors
pub fn action_drop_counts(&self) -> Result<ActionDropCounts>
How many actions, and how many action reports, this camera has lost.
Exact totals over the life of the camera, recording or still,
across reconnects. The two action callbacks are best effort; this
is how an application learns that some of their reports never
arrived. See ActionDropCounts.
Errors
pub fn register_signal(&mut self, name: &str) -> Result<u32>
Register a value your application publishes, so rules can watch it.
A line pressure, a batch number, a reading from another instrument; once registered it behaves exactly like a temperature, with the same bands, hysteresis, delays and actions.
Registering the same name twice returns the same slot.
Errors
Returns Status::InvalidArgument if name contains an
interior NUL byte.
pub fn publish_signal(&mut self, slot: u32, value: f64) -> Result<()>
Publish a new value. Rules watching it are evaluated immediately.
The value is in your application's own unit and is never
converted, whatever crate::set_temperature_unit chose: a
rule on it compares it, and reports it, as published.
Errors
Returns Status::NotFound if the slot is unknown.
pub fn read_signal(&self, signal: SignalId) -> Result<Option<SignalReading>>
Read any signal, in any domain.
Returns Ok(None) when the producer supplied no value this
cycle. A rule on such a signal reports AlarmState::Orphaned
rather than holding its last state, and this mirrors that: there
is no value to report, rather than a stale one.
Errors
Returns Status::NotFound if the signal does not exist.