Giter Club home page Giter Club logo

events_contrast_maximization's Introduction

Event Contrast Maximization Library

A python library for contrast maximization and voxel creation using events.

Usage

To use this library, you need to first convert the events to hdf5 file format. This is necessary because reading the events from rosbag is painfully slow. So use the script in tools/rosbag_to_h5.py like so: python rosbag_to_h5.py /path/to/your/bag --output_dir /path/to/save/h5/file --event_topic /dvs/events Obviously for this to work, you will need to have ros installed.

If you just want to get going, you can also download a couple of h5 event sequences from here (slider_depth from Mueggler, The Event-Camera Dataset and Simulator, IJRR17 and a super simple sequence I recorded myself).

To run a quick demo (show the cost landscape and run through a bunch of objective functions) go to utils and run python events_cmax.py /path/to/my/events.h5 To implement your own objective functions, check out utils/objectives.py to implement your own warps (at the moment there is only linear velocity warp, I'll put more in soon) check out utils/warps.py.

Dependencies

You need to be running at least Python 3 and have PyTorch installed (GPU not necessary).

Overview

This library contains functions for generally useful event-based vision tasks. Here is q quick overview:

Tools

Event conversions

-rosbag_to_h5.py converts rosbag events to HDF5 files, together with lots of useful metadata (for example, images contain the index of the time-synchronized event). Works for color event cameras.

-txt_to_h5.py converts txt or zip file events to HDF5 files, together with lots of useful metadata. Input txt or zip event files match format used in rpg_e2vid:

width height
t1 x1 y1 p1
t2 x2 y2 p2
t3 x3 y3 p3
...

-h5_to_memmap.py converts HDF5 events to MemMap events, as sometimes used at RPG.

Implementing your own data format converter is easy, by implementing an event packager in event_packagers.py.

Utils

This contains the contrast maximization code as well as a load of other utility functions.

event_utils.py

  • Binary search over timestamps for HDF5 files (this means you don't need to load the entire event sequence into RAM to search) and binary search of events as tensors.
  • Loading HDF5 events (read_h5_events)
  • Turn a voxel grid into an image (each 'slice' placed side by side) (get_voxel_grid_as_image, plot_voxel_grid)
  • Get a mask for all events out of a certain spatial bounds (events_bounds_mask, clip_events_to_bounds)
  • Turn a set of events to an image (events_to_image, events_to_image_torch) turns a set of events into an image. If the event coordinates are floating point, due to camera calibration or other transforming, this can be done with ilinear interpolation. If some warp has been applied to the events and the jacobian of that warp is available, you may compute the derivative images using events_to_image_drv. You may also get an average timestamp image as described in Unsupervised Event-based Learning of Optical Flow, Depth, and Egomotion with events_to_timestamp_image, events_to_timestamp_image_torch (currently the only public implementation of this).
  • Generate voxel grids. This is frequently required for deep learning with events. You can generate voxel grids with fixed k events (voxel_grids_fixed_n_torch), fixed t-seconds (voxel_grids_fixed_t_torch) between two times (events_to_voxel_timesync_torch) or simply turn the entire collection of events into a single voxels (events_to_voxel, events_to_voxel_torch). You can also get the voxel grid positive and negative channels separately if you wish (events_to_neg_pos_voxel, events_to_neg_pos_voxel_torch). So you can see, there are many options.
  • Warp events over a flow field (warp_events_flow_torch). When functions are appended with _torch, it indicates that the method expects data inputs to be torch.tensor, otherwise np.array is expected.

events_cmax.py

Contains the code for running contrast maximization with various objectives/warp functions on the events. To implement your own warp function, see warps.py, for your own objective functions see objectives.py. For example code, see the main code in events_cmax.

Citation

If you use any of this code, please cite: T. Stoffregen and L. Kleeman, Event Cameras, Contrast Maximization and Reward Functions: An Analysis, The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2019.

@InProceedings{Stoffregen19cvpr,
author = {Stoffregen, Timo and Kleeman, Lindsay},
title = {Event Cameras, Contrast Maximization and Reward Functions: An Analysis},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2019}
} 

events_contrast_maximization's People

Contributors

timostoff avatar cedric-scheerlinck avatar tobias-fischer avatar huizerd avatar

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.