Giter VIP home page Giter VIP logo

taro-dvstoolkit's Introduction

DVS Toolkit

The simple toolkit for processing event-based data. Any suggestions and questions, please contact me with [email protected] or comment in the issue.

demonstrate

Preliminaries

Installation

We recommend to create a new conda environment and install our package as follows:

python setup.py install

Running

You can run test/demo.py to verify its validity

python test/demo.py

Getting started

This package aims to provide a series of wrapped modules to help users to do subsequent processing and analysis on event camera data. We follows standards in dv and dv-python documentation. Now the supported data types are:

  • Size
  • Event
  • Frame
  • IMU

I/O Operations

DvsFile can be used to read and write event data files.

  • load(path: str) reads file containing streams of data that are defined like dv style. It supports load all the information including .aedat4 and .txt file.

    from evtool.dvs import DvsFile
    
    # load event data
    data = DvsFile.load(<path/to/load>)
    
    # access dimensions of the event stream
    height, width = data['size']
    
    # loop through the "events"
    for event in data['events']:
        print(event.timestamp, event.x, event.y, event.polarity)
    
    # loop through the "frames" (.txt not supported)
    for frame in data['frames']:
        print(frame.timestamp, frame.image.shape)
  • save(data: Data, path: str) writes data to .txt file, whose type is determined by suffix.

    from evtool.dvs import DvsFile
    
    # load event data
    data = DvsFile.load(<path/to/load>)
    
    # save event data
    DvsFile.save(data, <path/to/save>)

Standard Type

Event stores basic information of event data, including timestamp, x, y and polarity.

  • slice(t: interval{'unit'}) divides events into subsets by time interval.

    # loop through sliced event packet by time interval ('s', 'ms', 'us')
    for timestamp, event in data['events'].slice('25ms'):
        print(timestamp, event.shape)
  • project(size: Size) accumulates events into a 2D plane

    import matplotlib.pyplot as plt
    
    # get projected events frame
    counts = data['events'].project(data['size'])
    
    # display projected frame
    plt.imshow(counts, vmin=-1, vmax=1, cmap=plt.set_cmap('bwr'))
    plt.show()
  • hotpixel(size: Size, thres: int) returns potential hot-pixel index. It will project events first and return a set of index whose pixels' median numbers are larger than defined thres.

    # return hot-pixel index
    idx = data['events'].hotpixel(data['size'], thres=1000)
    
    # filter all hot-pixels
    data['events'] = data['events'][idx]
  • shot_noise(size: Size, rate: int, down_sample: int) generates shot noise events. It simulates the process of generating shot noise with Poisson distribution at fixed rate and downsamples raw events at down_sample.

    # generate shot noise
    data['events'] = data['events'].shot_noise(data['size'], rate=5, down_sample=0.8)

Frame stores Active Pixel Sensor (APS) outputs, including timestamp and image.

  • find_closest(t: int) finds the frame which is closet to timestamp t, returns the frame's timestamp and corresponding image.
    from numpy.random import randint
    import matplotlib.pyplot as plt
    
    # find closet frame
    idx = data['frames'].find_closest(randint(0, 1E16, 1))
    timestamp, image = data['frames'][idx]
    
    # display frame closest to referred timestamp
    plt.imshow(image)
    plt.show()

Utilities

Player is a class to provide visualization. It has matplotlib and plotly implementation, the former is suggested to view a real-time animation while the latter is more suitable for static 2D and 3D rendering (which means may take a long time to generate animation).

  • view(t: interval{'unit'}, core: {'matplotlib'(default), 'plotly'}) gives a glance at events stream.
    from evtool.utils import Player
    
    # load file
    data = DvsFile.load(<path/to/load>)
    
    # load data into player and choose core
    player = Player(data, core='matplotlib')
    
    # view data
    player.view("25ms", use_aps=True)

Acknowledgement

Special thanks to Jinze Chen.

taro-dvstoolkit's People

Contributors

kugamaxx avatar

Stargazers

dlutzy avatar gghit avatar fisher avatar YangWang avatar  avatar  avatar  avatar

Watchers

dlutzy avatar  avatar

Forkers

tlwzzy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.