Skip to main content

viva_genicam/
evs.rs

1//! Event-vision blocks: what an event camera streams instead of images (a
2//! LUCID TRT009S-E's EVT 3.0 or 2.1 words), kept apart from [`Frame`](crate::Frame).
3
4use std::time::SystemTime;
5
6use bytes::Bytes;
7use viva_pfnc::PixelFormat;
8
9use crate::chunks::ChunkData;
10use crate::frame::FrameStatus;
11
12/// Encoding used by a LUCID event-vision stream block.
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14#[non_exhaustive]
15pub enum EvsFormat {
16    /// Prophesee EVT 3.0, encoded as 16-bit words.
17    Evt30,
18    /// Prophesee EVT 2.1, encoded as 64-bit events.
19    Evt21,
20}
21
22impl EvsFormat {
23    pub(crate) const fn pixel_format(self) -> PixelFormat {
24        match self {
25            Self::Evt30 => PixelFormat::VendorLucidEvsEvt30,
26            Self::Evt21 => PixelFormat::VendorLucidEvsEvt21,
27        }
28    }
29}
30
31/// One raw event-vision block reassembled from GVSP packets.
32#[derive(Debug, Clone)]
33#[non_exhaustive]
34pub struct EvsBlock {
35    /// Encoded EVT bytes, preserved exactly as transmitted.
36    pub payload: Bytes,
37    /// EVT encoding identified by the GVSP leader's format code.
38    pub format: EvsFormat,
39    /// Device timestamp from the GVSP leader.
40    pub ts_dev: Option<u64>,
41    /// Raw Size X value from the GVSP leader.
42    pub leader_size_x: u32,
43    /// Raw Size Y value from the GVSP leader.
44    pub leader_size_y: u32,
45    /// Raw Size Y value from the GVSP trailer.
46    ///
47    /// On the captured TRT009S-E stream this equals the encoded payload length,
48    /// but it is retained as wire metadata rather than generalized from one
49    /// device observation.
50    pub trailer_size_y: u32,
51    /// The block's chunks by chunk ID, as on [`crate::Frame::chunks`].
52    pub chunks: Option<ChunkData>,
53    /// Host-correlated timestamp, when time synchronization is available.
54    pub ts_host: Option<SystemTime>,
55    /// GVSP block id.
56    pub block_id: u64,
57    /// How the block ended.
58    pub status: FrameStatus,
59}