Modern C++ Pipeline Design for Event–Frame Particle Tracking Velocimetry
Immutable event chunk ownership, zero-copy std::span slicing, Newton-refined continuous frequency estimation on raw microsecond timestamps, and uncertainty propagation.
High-Throughput Event Streams in Fluid Velocimetry
Event cameras asynchronously emit whenever pixel log-intensity crosses a contrast threshold:
In high-speed seeded flows, event rates routinely reach events/s. Copying event arrays across sliding time windows saturates memory bandwidth, while naive FFT binning quantizes velocity estimates in strong shear layers.
Append-Only Immutable Chunks and std::span Views
To decouple sensor ingestion from downstream tracking without lock contention or per-window copies, the capture thread writes into an exclusive buffer and seals it as an immutable std::shared_ptr<const std::vector<Event>> block upon completion. Sliding windows pass lightweight std::span slices:
#include <cstdint>
#include <memory>
#include <span>
#include <vector>
struct Event {
std::int64_t t_us;
std::uint16_t x, y;
std::int8_t polarity;
};
struct EventWindow {
std::shared_ptr<const std::vector<Event>> chunk;
std::size_t offset, length;
std::span<const Event> view() const noexcept {
return std::span<const Event>(*chunk).subspan(offset, length);
}
};
Timestamps remain int64_t microseconds and subtract window origin before floating-point conversion to avoid mantissa loss over long recordings. Half-open intervals locate bounds in via std::lower_bound, while spatial ROI lookups use a lightweight tile-to-index side table without moving event payloads.
Continuous Frequency Refinement Beyond FFT Bins
Under periodic illumination modulation, motion-compensated ROI events form the complex phase response:
Evaluating only on discrete FFT grid centers introduces picket-fence quantization bias. Seeding from a coarse FFT peak and running 2–3 damped Newton steps directly on raw timestamps recovers continuous sub-bin frequency using analytical derivatives accumulated in a single pass:
Frame–Event Association and Velocity Uncertainty
Synchronized grayscale frames anchor drift-free particle centroids while event streams resolve curved inter-frame trajectories. Gated association combines Mahalanobis innovation distance with wrapped modulation phase consistency:
Converting pixel displacement to metric speed exposes the fundamental window-length tradeoff:
Shrinking reduces streamline-curvature bias in high shear, but amplifies centroid noise by and timing jitter by —motivating local SNR-adaptive window sizing.