Library to connect to DV event based vision software
pip install dv==1.0.10
A library that to connect a python script to outputs from the dynamic vision system DV. This is used in conjunction with the Dynamic Vision Sensor (DVS).
DV (Dynamic Vision System) is a platform to develop high-performance, embedded, deployable C++ applications. However, for rapid prototyping and experimenting, many developers prefer to use python.
DV-Python DV python is a library that helps you:
Make sure you are using a recent python 3 version. The easiest way to install the library is via pip
pip3 install dv
DV communicates with the outside world by means of your computers network stack. To make DV export your required data to the network, follow these steps:
Start DV
Go to Structure tab
Add a Dv net output tcp server
by clicking on Add module
Name the module as you wish, for example "event_server"
Connect events
output of your camera with the input of the added module
The module assumes port 7777
by default. If you are happy with that, you can start the module by pressing the play button. If not, click on the plus button next to the modules name in the configuration list in the right sidebar.
To change the port, change the setting in the window that popped up
A sample program that loops over the events in the input:
from dv import NetworkEventInput
with NetworkEventInput(address='localhost', port=7777) as i:
for event in i:
print(event.timestamp)
An event has properties x
, y
, polarity
and timestamp. The timestamp is in microseconds.
Configure DV as in the event case, but connect the camera frame output to the network module input.
A sample program that loops over the events in the input:
from dv import NetworkFrameInput
import cv2
with NetworkFrameInput(address='localhost', port=7777) as i:
for frame in i:
print(frame)
cv2.imshow('out', frame.image)
cv2.waitKey(1)
frame.image
is a numpy matrix that can directly be used to perform openCV operations on it.
As with the event and frame case, one can also obtain IMU and Trigger data from the camera the same way.
Ever .aedat
file created with DV, contains all the streams of data that were connected to while recording. To get the names of all the streams in the file, call the .names
.
from dv import AedatFile
with AedatFile(<Path to aedat file>) as f:
# list all the names of streams in the file
print(f.names)
# loop through the "events" stream
for e in f['events']:
print(e.timestamp)
# loop through the "frames" stream
for frame in f['frames']:
print(frame)
cv2.imshow('out', frame.image)
cv2.waitKey(1)
dv-python supports loading some (sane) aedat 2 and aedat 3 files. However, it only supports reading the event data from these files. Other data, like frames etc. is not supported.
from dv import LegacyAedatFile
with LegacyAedatFile('myFile.aedat') as f:
for event in f:
print(event.timestamp)
Note Reading of the file is done completely in python and is therefore pretty slow. This is not recommended for more than quick tests.
The configuration of DV at runtime is stored in a tree structure accesible over the network. The config tree is what is altered making changes in the dv gui. dv-python offers experimental wrappers for the dv-control
command line utility to read and change config options at runtime from python.
from dv import Control
ctrl = Control(address='localhost', port=4040)
print(ctrl.get('/mainloop/output_file/', 'file', 'string'))
ctrl.put('/mainloop/accumulator/', 'running', 'bool', True)
put(path, attribute, type, value)
get(path, attribute, type)
add_module(name, library)
remove_module(name)
node_exists(path)
attribute_exists(path, attribute, type)
get_children(path)
This is very new software which can and will contain bugs. Please report any bugs you find, and we'll quickly address them.