ImageRef
pub struct ImageRef<'a>
A borrowed view of one image frame.
'a ends when the callback that was handed this returns; the SDK
reuses the buffer afterwards. ImageRef::data therefore yields a
slice that cannot escape the callback, and
ImageRef::to_vec is how you keep a copy.
ImageRef — methods
pub fn format(self) -> PixelFormat
What the bytes mean.
pub fn width(self) -> u32
Frame width in pixels.
pub fn height(self) -> u32
Frame height in pixels.
pub fn stride_bytes(self) -> u32
Bytes from the start of one row to the start of the next.
Equal to width * bytes_per_pixel for every frame this SDK
produces, but the header says to read it rather than assume so,
and ImageRef::rows does.
pub fn bytes_per_pixel(self) -> u32
Bytes one pixel occupies.
pub fn sequence(self) -> Option<u32>
The sequence number of the capture this image was drawn from,
the same value crate::FrameInfo::sequence carries on the
thermal frame of the same moment.
This is what makes a picture pairable with its measurement. The image callback and the thermal frame arrive by independent paths, so pairing on "the newest frame I hold" is one frame late while a stream runs, and stays wrong indefinitely after a paused replay's single seeked frame.
None when the SDK could not say, which is a replay of a
picture-only file. Option and not a bare u32 because
sequence 0 is a real frame, the first of the stream, so there
is no in-band value that could mean "nobody said".
pub fn timestamp_us(self) -> Option<u64>
When the capture was taken, in microseconds.
A stopwatch reading, not a date, see
crate::FrameInfo::timestamp_us for what the epoch is and
is not. None under the same condition as
ImageRef::sequence, and from the same flag, so the two
cannot disagree about whether this image has an identity.
pub fn data(self) -> &'a [u8]
Borrow the image's bytes.
Nothing is copied. The slice's lifetime is 'a, so it cannot
outlive the callback that received the image.
Returns an empty slice if the SDK reported no data, which should not happen but is preferable to constructing a dangling slice.
pub fn rows(self) -> impl Iterator<Item = &'a [u8]>
The image's rows, each width * bytes_per_pixel bytes.
Honours ImageRef::stride_bytes, so this is correct even if a
future frame is padded. Rows that fall outside the reported
buffer are skipped rather than read.
pub fn to_vec(self) -> Vec<u8>
Copy the image's bytes out.
This is how a callback keeps what it was given. It allocates and copies, which is the price of outliving the callback.