Skip to main content

Frame

Struct Frame 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§payload: Bytes

The 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: u32

Width of the image in pixels.

§height: u32

Height of the image in pixels.

§pixel_format: PixelFormat

Pixel 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: u64

Block id from the transport: 16 bits widened, or the 64-bit extended id.

§payload_type: u16

Payload type from the leader, all 16 bits: 0x0001 is an image and 0x4001 an image with extended chunk data (TC-05).

§status: FrameStatus

How the block ended.

§padding_x: u16

Bytes the camera sends after every line of the image: the GVSP image leader’s padding_x, 0 for none. See row_stride.

§raw_payload: Bytes

The 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

Source

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.

Source

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.

Source

pub fn is_complete(&self) -> bool

Whether every packet of the frame arrived.

Source

pub fn host_time(&self) -> Option<SystemTime>

Host-reconstructed timestamp if the camera reports a device timestamp.

Source

pub fn as_rgb8(&self) -> Option<&[u8]>

Return a borrowed slice of RGB pixels when the payload is already RGB8.

Source

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.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Frame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

§

impl UnwindSafe for Frame

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more