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
impl EventStream
Sourcepub fn efast(&self) -> EventStream
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.
Sourcepub fn harris_corners(&self, threshold: f64) -> EventStream
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
impl EventStream
Sourcepub fn background_activity_filter(&self, dt: i64) -> EventStream
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.
Sourcepub fn refractory_filter(&self, dt: i64) -> EventStream
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.
Sourcepub fn hot_pixel_filter(&self, n_std: f64) -> EventStream
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
impl EventStream
Sourcepub fn optical_flow(&self, window: usize) -> Result<EventFrame, FlowError>
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
impl EventStream
Sourcepub fn filter_polarity(&self, polarity: bool) -> EventStream
pub fn filter_polarity(&self, polarity: bool) -> EventStream
Keeps only events of the given polarity.
Sourcepub fn invert_polarity(&self) -> EventStream
pub fn invert_polarity(&self) -> EventStream
Flips every event’s polarity. Sensor and timestamps unchanged.
Sourcepub fn sort_by_time(&self) -> EventStream
pub fn sort_by_time(&self) -> EventStream
Returns a copy reordered by ascending timestamp (stable for equal timestamps).
Sourcepub fn concat(&self, others: &[&EventStream]) -> EventStream
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
impl EventStream
Sourcepub fn crop(&self, x0: i64, y0: i64, w: usize, h: usize) -> EventStream
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.
Sourcepub fn flip_x(&self) -> EventStream
pub fn flip_x(&self) -> EventStream
Mirrors horizontally (x → width-1-x). Sensor size unchanged.
Sourcepub fn flip_y(&self) -> EventStream
pub fn flip_y(&self) -> EventStream
Mirrors vertically (y → height-1-y). Sensor size unchanged.
Sourcepub fn rotate90(&self, k: i32) -> EventStream
pub fn rotate90(&self, k: i32) -> EventStream
Rotates by k * 90° clockwise. k is taken mod 4; quarter turns swap the sensor dims.
Sourcepub fn transpose(&self) -> EventStream
pub fn transpose(&self) -> EventStream
Reflects across the main diagonal ((x, y) → (y, x)); swaps the sensor dims.
Sourcepub fn translate(&self, dx: i64, dy: i64) -> EventStream
pub fn translate(&self, dx: i64, dy: i64) -> EventStream
Translates by (dx, dy); events shifted off the sensor are dropped. Sensor unchanged.
Sourcepub fn resize(&self, w: usize, h: usize) -> EventStream
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).
Sourcepub fn scale(&self, sx: f64, sy: f64) -> EventStream
pub fn scale(&self, sx: f64, sy: f64) -> EventStream
Scales the sensor by (sx, sy), rounding the new dimensions. See Self::resize.
Sourcepub fn warp_affine(&self, m: [[f64; 3]; 2]) -> EventStream
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.
Sourcepub fn warp_perspective(&self, m: [[f64; 3]; 3]) -> EventStream
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.
Sourcepub fn undistort(&self, camera: &Camera) -> EventStream
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§impl EventStream
impl EventStream
Sourcepub fn time_window(&self, t0: i64, t1: i64) -> EventStream
pub fn time_window(&self, t0: i64, t1: i64) -> EventStream
Keeps events whose timestamp lies in the half-open window [t0, t1).
Sourcepub fn time_shift(&self, dt: i64) -> EventStream
pub fn time_shift(&self, dt: i64) -> EventStream
Shifts every timestamp by dt (same units as the stored timestamps).
Sourcepub fn time_scale(&self, factor: f64) -> EventStream
pub fn time_scale(&self, factor: f64) -> EventStream
Scales every timestamp by factor (rounded), e.g. to change playback speed.
Sourcepub fn normalize_time(&self) -> EventStream
pub fn normalize_time(&self) -> EventStream
Shifts timestamps so the earliest event starts at zero. A no-op on an empty stream.
Sourcepub fn decimate(&self, k: usize) -> EventStream
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
impl EventStream
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn sensor_size(&self) -> (usize, usize)
pub fn timestamp_scale_ms(&self) -> f64
pub fn xs(&self) -> &[u16]
pub fn ys(&self) -> &[u16]
pub fn ts(&self) -> &[i64]
pub fn ps(&self) -> &[bool]
pub fn iter(&self) -> impl Iterator<Item = Event> + '_
Trait Implementations§
Source§impl Clone for EventStream
impl Clone for EventStream
Source§fn clone(&self) -> EventStream
fn clone(&self) -> EventStream
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more