Skip to main content

read event stream files

Project description

Event Stream

Event Stream is a fast and buffered Event Stream python reader, with a C++ underlying implementation.

Run pip install event_stream to install it.

Documentation

The event_stream library provides a single class: Decoder. A decoder object is created by passing a file name to Decoder. The file name must be a path-like object.

Here's a short example:

import event_stream

decoder = event_stream.Decoder('/path/to/file.es')
"""
decoder is a packet iterator with 3 additional properties: type, width and height
type is one of 'generic', 'dvs', 'atis' and 'color'
if type is 'generic', both width and height are None
otherwise, width and height represent the sensor size in pixels
"""
if decoder.type == 'generic':
    print('generic events')
else:
    print(f'{decoder.type} events, {decoder.width} x {decoder.height} sensor')

for packet in decoder:
    """
    packet is a numpy array whose dtype depends on the decoder type:
        generic: [('t', '<u8'), ('bytes', 'object')]
        dvs: [('t', '<u8'), ('x', '<u2'), ('y', '<u2'), ('on', '?')]
        atis: [('t', '<u8'), ('x', '<u2'), ('y', '<u2'), ('exposure', '?'), ('polarity', '?')]
        color: [('t', '<u8'), ('x', '<u2'), ('y', '<u2'), ('r', '?'), ('g', '?'), ('b', '?')]
    """
    print('{} events, ts = [{} µs, {} µs]'.format(len(packet), packet['t'][0], packet['t'][-1]))

Contribute

To format the code, run:

clang-format -i source/sepia.h source/event_stream.cpp

Publish

The version number can be changed in setup.py.

rm -rf dist
python3 setup.py sdist
twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

event_stream-1.1.0.tar.gz (11.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page