Skip to content

Commit

Permalink
important bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rfma23 committed Jul 20, 2020
1 parent 2ec60d9 commit 36ece9f
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 19 deletions.
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import os

from aertb.core import FileLoader
from aertb import make_gif
from aertb.core import make_gif

# =============================================================================
# SHELL
Expand Down
50 changes: 50 additions & 0 deletions aer_toolbox.log
Original file line number Diff line number Diff line change
Expand Up @@ -693,3 +693,53 @@ TypeError: get_frame() takes 1 positional argument but 3 were given
ValueError: No closing quotation

2020-07-18 23:23:44,121 [INFO] Calling tohdf5 with params ['example_data/bin/one/03263.bin', None, 'mytest2.h5', [0, 1]]
2020-07-20 11:17:42,557 [INFO] Calling tohdf5 with params ['example_data/dat/cars/obj_004415_td.dat', None, 'cameraEvents.h5', [0, 1]]
2020-07-20 11:17:42,571 [INFO] Processing 4977.0 events
2020-07-20 11:19:04,801 [INFO] Calling makegif with params ['example_data/dat/cars/obj_004415_td.dat', None, 'testProphesee.gif', 'both', 'decay']
2020-07-20 11:19:04,803 [INFO] Processing 4977.0 events
2020-07-20 11:19:04,837 [INFO] Duration 0.099904, Delta 0.012488000094890594 Tau 0.012488000094890594
2020-07-20 11:23:12,086 [INFO] Calling makegif with params ['example_data/mixed/recording.dat', None, 'testProphesee.gif', 'both', 'decay']
2020-07-20 11:23:12,088 [INFO] Processing 30854479.0 events
2020-07-20 11:24:21,984 [INFO] Calling tohdf5 with params ['example_data/mixed/recording.dat', None, 'cameraEvents.h5', [0, 1]]
2020-07-20 11:24:21,986 [INFO] Processing 30854479.0 events
2020-07-20 11:31:20,797 [INFO] Calling makegif with params ['example_data/dat/cars/obj_004415_td.dat', None, 'testProphesee.gif', 'both', 'decay']
2020-07-20 11:31:20,799 [INFO] Processing 4977.0 events
2020-07-20 11:31:20,833 [INFO] Duration 0.099904, Delta 0.012488000094890594 Tau 0.012488000094890594
2020-07-20 11:32:17,984 [INFO] Calling tohdf5 with params ['example_data/dat/cars/obj_004415_td.dat', None, 'myFile.h5', [0, 1]]
2020-07-20 11:32:17,986 [INFO] Processing 4977.0 events
2020-07-20 13:38:04,318 [INFO] Calling makegif with params ['example_data/aedat/cards_1.aedat', 'aedat', 'std.gif', 'both', 'std']
2020-07-20 13:38:04,319 [INFO] Processing 598882.0 events
2020-07-20 13:38:07,704 [INFO] Duration 2.207847, Delta 0.18398725986480713 Tau 0.18398725986480713
2020-07-20 13:39:09,178 [INFO] Calling makegif with params ['example_data/dat/cars/obj_004415_td.dat', None, 'testProphesee.gif', 'both', 'decay']
2020-07-20 13:39:09,180 [INFO] Processing 4977.0 events
2020-07-20 13:39:09,209 [INFO] Duration 0.099904, Delta 0.016650666793187458 Tau 0.016650666793187458
2020-07-20 13:39:23,510 [INFO] Calling makegif with params ['example_data/dat/cars/obj_004415_td.dat', None, 'testProphesee.gif', 'both', 'decay']
2020-07-20 13:39:23,511 [INFO] Processing 4977.0 events
2020-07-20 13:39:23,539 [INFO] Duration 0.099904, Delta 0.008325333396593729 Tau 0.008325333396593729
2020-07-20 13:40:13,544 [INFO] Calling tohdf5 with params ['example_data/mixed/recording.dat', None, 'cameraEvents.h5', [0, 1]]
2020-07-20 13:40:13,565 [INFO] Processing 30854479.0 events
2020-07-20 14:03:17,966 [INFO] Calling tohdf5 with params ['example_data/mixed/recording.dat', None, 'cameraEvents.h5', [0, 1]]
2020-07-20 14:03:17,990 [WARNING] Traceback (most recent call last):
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/click_shell/core.py", line 37, in invoke_
parent=self.ctx)
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "./__main__.py", line 76, in tohdf5
fl.create_hdf5_dataset(out, file, polarities)
File "./aertb/core/file_loader.py", line 76, in create_hdf5_dataset
with h5py.File(dataset_name, 'w') as fp:
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py", line 408, in __init__
swmr=swmr)
File "/Users/rafaelmosca/opt/anaconda3/lib/python3.7/site-packages/h5py/_hl/files.py", line 179, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 108, in h5py.h5f.create
OSError: Unable to create file (unable to lock file, errno = 35, error message = 'Resource temporarily unavailable')

2020-07-20 14:03:24,616 [INFO] Calling tohdf5 with params ['example_data/mixed/recording.dat', None, 'cameraEvents.h5', [0, 1]]
2020-07-20 14:03:24,620 [INFO] Processing 30854479.0 events
Binary file added aertb/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
24 changes: 19 additions & 5 deletions aertb/core/loaders/aedat_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,25 @@ def load_events(self, filename, polarities=[-1,1], to_secs=True):
f = open(filename, "rb")

# Read Header
f.readline() # Version
f.readline() # Description 1
f.readline() # Description 2
f.readline() # Description 3
f.readline() # Date

# Read Header
parsedHeader = False
header = []

while parsedHeader is False:

two_bytes = f.read(1)
# if they match a comment syntax
if two_bytes==b'#':
# reset file cursor
f.seek(-1, 1)
# read whole line
header.append(f.readline()) #
else:
# signal header is parsed
parsedHeader = True

f.seek(-1, 1)

# Compute number of events
start = f.tell()
Expand Down
29 changes: 19 additions & 10 deletions aertb/core/loaders/dat_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,35 @@ def load_events(self, filename, polarities=[-1,1], to_secs=True):
f = open(filename, "rb")

# Read Header
f.readline() # Title
f.readline() # Version
f.readline() # Date

# read two bytes ?? dunno why
# took a while to figure out how to make things work
# this made it work
f.read(2)
parsedHeader = False
header = []

while parsedHeader is False:

two_bytes = f.read(2)
# if they match a comment syntax
if (two_bytes==b'% '):
# reset file cursor
f.seek(-2, 1)
# read whole line
header.append(f.readline()) #
else:
# signal header is parsed
parsedHeader = True

# Compute number of events
start = f.tell()
end = f.seek(0, 2)
n_events = (end-start)/8

logging.info(f'Processing {n_events} events')

# Reposition file cursor
f.seek(-(end-start), 1)

prophesee_events = np.fromfile(f, dtype=prophesee_event_dtype, count=-1)

f.close()

x = np.bitwise_and(prophesee_events['xyp'], int('00003FFF', HEX))
y = np.right_shift(np.bitwise_and(prophesee_events['xyp'], int('0FFFC000', HEX)), 14)
p = np.right_shift(np.bitwise_and(prophesee_events['xyp'], int('10000000', HEX)), 28)
Expand All @@ -85,4 +93,5 @@ def load_events(self, filename, polarities=[-1,1], to_secs=True):

recarray = np.rec.fromarrays([x,y,ts,p], dtype=event_dtype)

return recarray
return recarray

2 changes: 1 addition & 1 deletion aertb/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
# =============================================================================

event_dtype = np.dtype([('x', np.uint8), ('y', np.uint8),
event_dtype = np.dtype([('x', np.uint16), ('y', np.uint16),
('ts', np.float32), ('p', np.int8)])

# =============================================================================
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

setup(
name='aertb',
version="0.1.2",
version="0.1.3",
author="Rafael Mosca",
author_email="rafael.mosca@mail.polimi.it",
url='https://github.com/rfma23',
packages=["aertb"],
packages=["aertb", "aertb.core", "aertb.core.loaders"],
keywords = ['aedat', 'aer', 'dat', 'event', 'camera'],
classifiers=list(filter(None, metadata.split('\n'))),
long_description=long_description,
Expand Down

0 comments on commit 36ece9f

Please sign in to comment.