-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaedat4toesColourD.py
42 lines (37 loc) · 1.13 KB
/
aedat4toesColourD.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''
Description: Convert .aedat4 format to .es using loris and pyDV
using the colourDAVIS346
'''
import loris
import numpy as np
import matplotlib.pyplot as plt
import os
import fnmatch
from tqdm import tqdm
from npy_to_matlab import npy_to_matlab
import scipy.io as sio
import glob, os
from dv import AedatFile
import matplotlib.pyplot as plt
import os
FILENAME = "bluebackgroundRedcircleLowlighttest"
parentFile = "/media/sami/Samsung_T5/MPhil/Dataset/aedat4/" + FILENAME + ".aedat4"
destinationFile = "/media/sami/Samsung_T5/MPhil/Dataset/es/"
events = []
with AedatFile(parentFile) as f:
# list all the names of streams in the file
print(FILENAME)
print(f.names)
for e in tqdm(f['events']):
event = np.zeros(4,dtype=np.uint32)
event[0] = e.timestamp
event[1] = e.x
event[2] = e.y
if e.polarity:
event[3] = 1
events.append(event)
finalArray = np.asarray(events)
finalArray[:,0] -= finalArray[0,0]
ordering = "txyp"
loris.write_events_to_file(finalArray, destinationFile + FILENAME + ".es",ordering)
print("File: " + FILENAME + "converted to .es")