Skip to main content

EventStream

Struct EventStream 

Source
pub struct EventStream { /* private fields */ }
Expand description

A stream of events stored column-wise (struct-of-arrays). Columns compress and transform far better than interleaved rows, and timestamps use i64 (µs) so real multi-second recordings fit. See TASKS.md §3.

Implementations§

Source§

impl EventStream

Source

pub fn efast(&self) -> EventStream

eFAST event corner detector (Mueggler et al., Fast Event-based Corner Detection, BMVC 2017). For each event it updates its polarity’s SAE, then tests two Bresenham rings (radius 3 and 4) around the pixel: an event is a corner when, on both rings, the most recent timestamps form a contiguous arc within the INNER_ARC/OUTER_ARC bounds — the signature of a moving corner rather than a straight edge. Events too close to the border to evaluate the outer ring are dropped. Returns the corner events as a new stream.

Source

pub fn harris_corners(&self, threshold: f64) -> EventStream

Harris corner score on the Surface of Active Events. For each event it updates a merged SAE of raw latest timestamps, then computes the Harris response det(M) - k·trace(M)² of the structure tensor M = Σ ∇T ∇Tᵀ of the SAE’s spatial gradient over a 9×9 window. Because the SAE is a local time ramp, a straight moving edge has a constant gradient direction (rank-1 M, R < 0) while a corner mixes gradient directions (rank-2 M, R > 0) — so the default threshold = 0 keeps corners and rejects edges. Raise threshold to be stricter. Returns the corner events as a new stream; a score-based complement to Self::efast.

Source§

impl EventStream

Source

pub fn background_activity_filter(&self, dt: i64) -> EventStream

Background-activity (nearest-neighbour) noise filter. Keeps an event only if some pixel in its 3×3 neighbourhood fired within dt (raw timestamp units, as Self::time_window): uncorrelated noise, which has no recent neighbours, is dropped. Assumes ascending time.

Source

pub fn refractory_filter(&self, dt: i64) -> EventStream

Refractory-period filter: after a pixel fires, suppress its events for dt (raw timestamp units). Keeps an event only when at least dt has elapsed since that pixel’s last kept event; dropped events do not refresh the dead time. Assumes ascending time.

Source

pub fn hot_pixel_filter(&self, n_std: f64) -> EventStream

Hot-pixel removal: drops every event from stuck pixels whose total event count exceeds mean + n_std·std, with the mean and standard deviation taken over the active pixels (those with at least one event). A uniform or empty stream removes nothing.

Source§

impl EventStream

Source

pub fn optical_flow(&self, window: usize) -> Result<EventFrame, FlowError>

Estimates dense optical flow by Lucas-Kanade on the time surface. window is the half-width of the least-squares neighbourhood (a (2·window+1)² patch); it must be at least 1. Returns a two-channel f32 frame — channel 0 flow_x, channel 1 flow_y, in pixels/ms — zero wherever flow is undefined.

Source§

impl EventStream

Source

pub fn filter_polarity(&self, polarity: bool) -> EventStream

Keeps only events of the given polarity.

Source

pub fn invert_polarity(&self) -> EventStream

Flips every event’s polarity. Sensor and timestamps unchanged.

Source

pub fn sort_by_time(&self) -> EventStream

Returns a copy reordered by ascending timestamp (stable for equal timestamps).

Source

pub fn concat(&self, others: &[&EventStream]) -> EventStream

Concatenates several streams into one (in argument order, not time-sorted). The sensor size is the element-wise maximum of the inputs; the timestamp scale comes from self.

Source§

impl EventStream

Source

pub fn crop(&self, x0: i64, y0: i64, w: usize, h: usize) -> EventStream

Keeps events inside the w×h window at (x0, y0) and shifts them to a new origin. The result is a w×h stream.

Source

pub fn flip_x(&self) -> EventStream

Mirrors horizontally (x → width-1-x). Sensor size unchanged.

Source

pub fn flip_y(&self) -> EventStream

Mirrors vertically (y → height-1-y). Sensor size unchanged.

Source

pub fn rotate90(&self, k: i32) -> EventStream

Rotates by k * 90° clockwise. k is taken mod 4; quarter turns swap the sensor dims.

Source

pub fn transpose(&self) -> EventStream

Reflects across the main diagonal ((x, y) → (y, x)); swaps the sensor dims.

Source

pub fn translate(&self, dx: i64, dy: i64) -> EventStream

Translates by (dx, dy); events shifted off the sensor are dropped. Sensor unchanged.

Source

pub fn resize(&self, w: usize, h: usize) -> EventStream

Resizes the sensor grid to w×h, rebinning each coordinate proportionally (floored — the destination bin, no interpolation). Every event maps into [0, w)×[0, h), so the count is conserved; on downscale several events may share a pixel (lossless).

Source

pub fn scale(&self, sx: f64, sy: f64) -> EventStream

Scales the sensor by (sx, sy), rounding the new dimensions. See Self::resize.

Source

pub fn warp_affine(&self, m: [[f64; 3]; 2]) -> EventStream

Applies a 2×3 affine matrix [[a,b,c],[d,e,f]] (x' = a·x+b·y+c, rounded). Sensor size unchanged; events warped off the sensor are dropped.

Source

pub fn warp_perspective(&self, m: [[f64; 3]; 3]) -> EventStream

Applies a 3×3 perspective (homography) matrix, dividing by the homogeneous coordinate. Events whose denominator is zero, or that warp off the sensor, are dropped.

Source

pub fn undistort(&self, camera: &Camera) -> EventStream

Rectifies events with a Camera’s intrinsics + distortion, mapping each event from its distorted pixel to the undistorted location on the same grid. Builds a per-pixel lookup once (the sensor grid is small), then remaps every event through it; events landing off the sensor after rectification are dropped. Sensor size unchanged.

Source

pub fn mask(&self, mask: &[bool], mask_w: usize, mask_h: usize) -> EventStream

Keeps only events where the mask_w×mask_h row-major boolean grid is true. Events outside the mask are dropped. Sensor size unchanged.

Source§

impl EventStream

Source

pub fn time_window(&self, t0: i64, t1: i64) -> EventStream

Keeps events whose timestamp lies in the half-open window [t0, t1).

Source

pub fn time_shift(&self, dt: i64) -> EventStream

Shifts every timestamp by dt (same units as the stored timestamps).

Source

pub fn time_scale(&self, factor: f64) -> EventStream

Scales every timestamp by factor (rounded), e.g. to change playback speed.

Source

pub fn normalize_time(&self) -> EventStream

Shifts timestamps so the earliest event starts at zero. A no-op on an empty stream.

Source

pub fn decimate(&self, k: usize) -> EventStream

Keeps every k-th event by index (k = 1 is the identity); k = 0 is treated as 1.

Source§

impl EventStream

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn sensor_size(&self) -> (usize, usize)

Source

pub fn timestamp_scale_ms(&self) -> f64

Source

pub fn xs(&self) -> &[u16]

Source

pub fn ys(&self) -> &[u16]

Source

pub fn ts(&self) -> &[i64]

Source

pub fn ps(&self) -> &[bool]

Source

pub fn iter(&self) -> impl Iterator<Item = Event> + '_

Source

pub fn to_array2(&self) -> Array2<u64>

Materialises an owned (N, 4) array of [x, y, t, p] rows for numpy interop.

Trait Implementations§

Source§

impl Clone for EventStream

Source§

fn clone(&self) -> EventStream

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 EventStream

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
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.

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.