OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Rust API referencev12.0

session — functions and constants

Sessions: several cameras on one clock.

A session records N cameras into one Matroska file, every frame of every camera stamped from one clock, and plays it back as one session. SessionRecorder writes one; SessionPlayer reads one.

Why a session rather than one recording per camera

Each recording's presentation times are measured from its own first frame. Two cameras are never started in the same microsecond, and a camera that reports no capture stamp of its own (which a PI over USB does, on every frame) has its times synthesised from its nominal rate, so one running at 9.8 Hz and calling itself 10 Hz drifts without bound. A session takes the timing decision away from the cameras, so "what did camera 1 see at the moment camera 0 saw this" is answered by the file.

Frames in, not cameras in

You hand each camera's frames to the session as they arrive, one call per frame. The session never takes a camera's frames away from you, which it would have to if it registered its own callback, and on a live dashboard that is the one thing it must not do.

Example

use optris_sdk::{Camera, SessionOptions, SessionRecorder, SessionSource};

# fn main() -> optris_sdk::Result<()> {
let mut session = SessionRecorder::create(
    "plant.mkv",
    &SessionOptions::new(),
)?;
let north = session.add_source(&SessionSource::new(160, 120, 32.0).name("Furnace north"))?;
session.open()?;

let mut camera = Camera::open()?;
camera.start()?;
while let Some(frame) = camera.acquire_frame(1000)? {
    session.write_frame(north, frame.as_frame(), None)?;
}
session.stop()?;
# Ok(())
# }

pub const OUTAGE_OPEN: u64 = u64::MAX;

SessionOutage::until_us for an outage the file never closed; the session stopped while the camera was still gone.

Spelled u64::MAX rather than taken from optris_sdk_sys::OPTRIS_SDK_SESSION_OUTAGE_OPEN: the header writes that macro as 18446744073709551615ULL, and bindgen types it i32 = -1, which is the same bit pattern only after a cast nobody reading the code would expect. Using the sys constant here would compile and would read as a negative number.