#[non_exhaustive]pub struct Frame {Show 14 fields
pub payload: Bytes,
pub width: u32,
pub height: u32,
pub pixel_format: PixelFormat,
pub chunks: Option<ChunkData>,
pub ts_dev: Option<u64>,
pub ts_host: Option<SystemTime>,
pub block_id: u64,
pub payload_type: u16,
pub status: FrameStatus,
pub padding_x: u16,
pub raw_payload: Bytes,
pub delivered_height: Option<u32>,
pub expected_size: Option<usize>,
}Expand description
Image frame produced by the GigE Vision stream reassembler.
Construct one with Frame::new; the struct is #[non_exhaustive] so the
stream can report more about a block without breaking callers.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.payload: BytesThe image: its lines one after another, each followed by
padding_x bytes.
For an image with chunks (0x4001) this is the image chunk alone,
without the chunks that follow it. A chunk-data block (0x0004) has
no image: payload is its chunk data, and width and height are 0.
width: u32Width of the image in pixels.
height: u32Height of the image in pixels.
pixel_format: PixelFormatPixel format describing how to interpret the payload bytes.
chunks: Option<ChunkData>The block’s chunks by chunk ID, when its payload type carries chunks
(0x0004, or the 0x4000 flag), the block is complete, and its chunk
layout parsed.
What each chunk holds is the camera’s XML’s to say: read the values
through GenApi with Camera::with_chunks
or Camera::chunk_features.
ts_dev: Option<u64>Device timestamp reported by the camera when available.
ts_host: Option<SystemTime>Host timestamp obtained by mapping the device ticks.
block_id: u64Block id from the transport: 16 bits widened, or the 64-bit extended id.
payload_type: u16Payload type from the leader, all 16 bits: 0x0001 is an image and
0x4001 an image with extended chunk data (TC-05).
status: FrameStatusHow the block ended.
padding_x: u16Bytes the camera sends after every line of the image: the GVSP image
leader’s padding_x, 0 for none. See row_stride.
raw_payload: BytesThe block’s whole payload as the camera sent it: for an image with
chunks (0x4001), the image chunk first, then every other chunk and
the tags between them; otherwise the same bytes as
payload. payload is a slice of
it, so keeping both costs no copy.
What a consumer that parses the chunk layout itself needs — a GenTL consumer, which locates chunks in the buffer the producer fills.
delivered_height: Option<u32>Lines the block delivered, from its trailer’s Size Y: fewer than
height when a variable-height frame (a line scan)
ended early. None when no trailer said — it was lost, or the
payload is not an image.
expected_size: Option<usize>Bytes the block was meant to carry, lost ones included: for a complete
block, the length of raw_payload; for an
incomplete one, what its trailer’s packet count, PayloadSize or the
leader’s geometry say. None when none of them does.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(
payload: Bytes,
width: u32,
height: u32,
pixel_format: PixelFormat,
) -> Self
pub fn new( payload: Bytes, width: u32, height: u32, pixel_format: PixelFormat, ) -> Self
A complete image frame with no chunks, timestamps or block id; its
raw_payload is payload.
Sourcepub fn row_stride(&self) -> Option<usize>
pub fn row_stride(&self) -> Option<usize>
Bytes from the start of one line to the start of the next, when the
camera pads its lines: the line’s own bytes, a packing group it ends
inside completed (PFNC 2.4 §6.7), plus padding_x.
None without padding: the lines then follow one another, and the
pixels run on from one line to the next.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether every packet of the frame arrived.
Sourcepub fn host_time(&self) -> Option<SystemTime>
pub fn host_time(&self) -> Option<SystemTime>
Host-reconstructed timestamp if the camera reports a device timestamp.
Sourcepub fn as_rgb8(&self) -> Option<&[u8]>
pub fn as_rgb8(&self) -> Option<&[u8]>
Return a borrowed slice of RGB pixels when the payload is already RGB8.
Sourcepub fn to_rgb8(&self) -> Result<Vec<u8>, GenicamError>
pub fn to_rgb8(&self) -> Result<Vec<u8>, GenicamError>
Convert the frame payload into an owned RGB8 buffer.
Every format viva_pfnc::convert handles: monochrome and Bayer at 8
to 16 bits, packed or not, RGB/BGR with or without alpha, and 8-bit
Y’CbCr. Samples deeper than 8 bits keep their top eight bits, and a
Bayer mosaic is demosaiced bilinearly — the same pixels Viva Studio’s
viewer shows. Bytes past the image are ignored.