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')
if decoder.type == 'generic':
    print('generic events')
else:
    print(f'{decoder.type} events, {decoder.width} x {decoder.height} sensor')

for packet in decoder:
    print('{} events, ts = [{} µs, {} µs]'.format(len(packet), packet['t'][0], packet['t'][-1]))

And the same example with detailed comments:

import event_stream

decoder = event_stream.Decoder('/path/to/file.aedat')
"""
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.

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-0.2.0.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file event_stream-0.2.0.tar.gz.

File metadata

  • Download URL: event_stream-0.2.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for event_stream-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6db4d54cd7e05f25ab9f604c7a6ec0bb4f4313494e1d5778f7e7522e34a53639
MD5 02367161e490bb477a2478af334d9c21
BLAKE2b-256 576c8aea29f1a28dccb7a24a6d76d4b4279a618a61f8f0eec9dbce700b7e6a75

See more details on using hashes here.

Supported by

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