An event camera processing library with Rust backend and Python bindings, designed for scalable data processing with real-world event camera datasets.
Core Features
- Universal Format Support: Load data from H5, AEDAT, EVT2/3, AER, and text formats
- Automatic Format Detection: No need to specify format types manually
- Polars DataFrame Integration: High-performance DataFrame operations with up to 360M events/s filtering
- Event Filtering: Comprehensive filtering with temporal, spatial, and polarity options
- Event Representations: Stacked histograms, voxel grids, and mixed density stacks
- Neural Network Models: E2VID model loading and inference
- Real-time Data Processing: Handle large datasets (550MB+ files) efficiently
- Polarity Encoding: Automatic conversion between 0/1 and -1/1 polarities
- Rust Performance: Memory-safe, high-performance backend with Python bindings
In Development: Advanced neural network processing (hopefully with Rust
backend, maybe Candle) Real-time visualization (Only simulated working at the
moment — see wasm-evlib
)
Note: The Rust backend currently focuses on data loading and processing, with Python modules providing advanced features like filtering and representations.
- Quick Start
- Installation
- Polars DataFrame Integration
- Available Python Modules
- Examples
- Development
- Community & Support
- License
Quick Start
Basic Usage
# Load events from any supported format (automatic detection)
=
# Or load as LazyFrame for memory-efficient processing
=
# Basic event information
# Convert to NumPy arrays for compatibility
=
=
=
=
Advanced Filtering
# High-level preprocessing pipeline
=
# Individual filters (work with LazyFrames)
=
=
=
=
=
Event Representations
# Create stacked histogram (replaces RVT preprocessing)
=
# Create mixed density stack representation
=
# High-level preprocessing for neural networks
=
# Performance benchmarking against RVT
=
Installation
Basic Installation
# For Polars DataFrame support (recommended)
Development Installation
# Clone the repository
# Create virtual environment
# Install in development mode with all features
# Build the Rust extensions
System Dependencies
# Ubuntu/Debian
# macOS
Performance-Optimized Installation
For optimal performance, ensure you have the recommended system configuration:
System Requirements:
- RAM: 8GB+ recommended for files >100M events
- Python: 3.10+ (3.12 recommended for best performance)
- Polars: Latest version for advanced DataFrame operations
Installation for Performance:
# Install with Polars support (recommended)
# For development with all performance features
# Verify installation with benchmark
Optional Performance Dependencies:
# For advanced memory monitoring
# For parallel processing (already included in dev)
Polars DataFrame Integration
evlib provides comprehensive Polars DataFrame support for high-performance event data processing:
Key Benefits
- Performance: 1.9M+ events/s loading speed, 360M+ events/s filtering speed
- Memory Efficiency: ~23 bytes/event (5x better than typical 110 bytes/event)
- Expressive Queries: SQL-like operations for complex data analysis
- Lazy Evaluation: Query optimization for better performance
- Ecosystem Integration: Seamless integration with data science tools
API Overview
Loading Data
# Load as LazyFrame (recommended)
=
= # Collect to DataFrame when needed
# Automatic format detection and optimization
= # EVT2 format automatically detected
Advanced Features
# Chain operations with LazyFrames for optimal performance
=
=
# Memory-efficient temporal analysis
=
# Combine with filtering module for complex operations
=
=
Utility Functions
# Built-in format detection
=
# Spatial filtering using dedicated filtering functions (preferred)
=
=
# Or using direct Polars operations
=
# Temporal analysis with Polars operations
=
# Save processed data
=
=
, , , = .
# Convert microseconds to seconds for save function
= / 1_000_000
Performance Benchmarks
Benchmark Results:
- Loading Speed: 1.9M+ events/second average across formats
- Filter Speed: 360M+ events/second for complex filtering operations
- Memory Efficiency: ~23 bytes/event
- Format Performance: RAW binary (2.6M events/s) > HDF5 (2.5M events/s) > Text (0.6M events/s)
Benchmarking and Monitoring
Run performance benchmarks to verify optimizations:
# Verify README performance claims and generate plots
# Memory efficiency benchmark
# Test with your own data
Performance Examples
Optimal Loading for Different File Sizes
# Small files (<5M events) - Direct loading
=
=
# Large files (>5M events) - Automatic streaming
=
# Same API, automatically uses streaming for memory efficiency
# Memory-efficient filtering on large datasets using filtering module
=
=
# Or using direct Polars operations
=
Memory Monitoring
=
return . / 1024 / 1024 # MB
# Monitor memory usage during loading
=
=
=
=
Troubleshooting Large Files
Memory Constraints
- Automatic Streaming: Files >5M events use streaming by default
- LazyFrame Operations: Memory-efficient processing without full materialization
- Memory Monitoring: Use
benchmark_memory.py
to track usage - System Requirements: Recommend 8GB+ RAM for files >100M events
Performance Tuning
- Optimal Chunk Size: System automatically calculates based on available memory
- LazyFrame Operations: Use
.lazy()
for complex filtering chains - Memory-Efficient Formats: RAW binary formats provide best performance, followed by HDF5
- Progress Reporting: Large files show progress during loading
Common Issues and Solutions
Issue: Out of memory errors
# Solution: Use filtering before collecting (streaming activates automatically)
=
# Streaming activates automatically for files >5M events
# Apply filtering before collecting to reduce memory usage
=
= # Only collect when needed
# Or stream to disk using Polars
Issue: Slow loading performance
# Solution: Use LazyFrame for complex operations and filtering module
=
# Use filtering module for optimized operations
=
=
# Or chain Polars operations
=
Issue: Memory usage higher than expected
# Solution: Monitor and verify optimization
=
=
# Check format detection
=
Available Python Modules
evlib provides several Python modules for different aspects of event processing:
Core Modules
evlib.formats
: Direct Rust access for format loading and detectionevlib.filtering
: High-performance event filtering with Polarsevlib.representations
: Event representations (stacked histograms, voxel grids)evlib.models
: Neural network model loading and inference (🚧 Under construction)
Module Overview
# Core event loading (returns Polars LazyFrame)
=
# Format detection and description
=
=
# Advanced filtering
=
=
# Event representations
=
# voxel = evr.create_voxel_grid("data/slider_depth/events.txt", height=480, width=640, nbins=5) # API compatibility issue
# Neural network models (limited functionality)
# If available
# Data saving (need to get arrays first)
=
, , , = .
# Convert microseconds to seconds for save functions
= / 1_000_000
Examples
Run examples:
# Test all notebooks
# Run specific examples
Development
Testing
Core Testing
# Run all tests (Python and Rust)
# Test specific modules
# Test notebooks (including examples)
# Test with coverage
Documentation Testing
All code examples in the documentation are automatically tested to ensure they work correctly:
# Test all documentation examples
# Test specific documentation file
# Use the convenient test script
# Test specific documentation section
Code Quality
# Format code
# Run linting
# Check types
Building
Requirements
- Rust: Stable toolchain (see
rust-toolchain.toml
) - Python: ≥3.10 (3.12 recommended)
- Maturin: For building Python extensions
# Development build
# Build with features
# Release build
Community & Support
{ width=100% }
- GitHub: tallamjr/evlib
- Issues: Report bugs and request features
- Discussions: Community Q&A and ideas
License
MIT License - see LICENSE.md for details.