aedat 2.2.0__cp313-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aedat/__init__.py +5 -0
- aedat/aedat.cp313-win_amd64.pyd +0 -0
- aedat-2.2.0.dist-info/METADATA +241 -0
- aedat-2.2.0.dist-info/RECORD +6 -0
- aedat-2.2.0.dist-info/WHEEL +4 -0
- aedat-2.2.0.dist-info/licenses/LICENSE +21 -0
aedat/__init__.py
ADDED
|
Binary file
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: aedat
|
|
3
|
+
Version: 2.2.0
|
|
4
|
+
Requires-Dist: numpy >=1.26
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Summary: A fast AEDAT4 decoder with an underlying Rust implementation
|
|
7
|
+
Author: International Centre for Neuromorphic Systems, Alexandre Marcireau
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
10
|
+
Project-URL: homepage, https://github.com/neuromorphicsystems/aedat/
|
|
11
|
+
Project-URL: repository, https://github.com/neuromorphicsystems/aedat/
|
|
12
|
+
Project-URL: documentation, https://github.com/neuromorphicsystems/aedat/
|
|
13
|
+
|
|
14
|
+
AEDAT is a fast AEDAT 4 python reader, with a Rust underlying implementation.
|
|
15
|
+
|
|
16
|
+
Run `pip install aedat` to install it.
|
|
17
|
+
|
|
18
|
+
- [Example](#example)
|
|
19
|
+
- [Process frames](#process-frames)
|
|
20
|
+
- [Pillow (PIL)](#pillow-pil)
|
|
21
|
+
- [OpenCV](#opencv)
|
|
22
|
+
- [Detailed example](#detailed-example)
|
|
23
|
+
- [Install from source](#install-from-source)
|
|
24
|
+
- [Linux](#linux)
|
|
25
|
+
- [macOS](#macos)
|
|
26
|
+
- [Windows](#windows)
|
|
27
|
+
- [Contribute](#contribute)
|
|
28
|
+
- [Publish](#publish)
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
The `aedat` library provides a single class: `Decoder`. A decoder object is created by passing a file name to `Decoder`. The file name must be a [path-like object](https://docs.python.org/3/glossary.html#term-path-like-object).
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
import aedat
|
|
36
|
+
|
|
37
|
+
decoder = aedat.Decoder("/path/to/file.aedat")
|
|
38
|
+
print(decoder.id_to_stream())
|
|
39
|
+
|
|
40
|
+
for packet in decoder:
|
|
41
|
+
print(packet["stream_id"], end=": ")
|
|
42
|
+
if "events" in packet:
|
|
43
|
+
print("{} polarity events".format(len(packet["events"])))
|
|
44
|
+
elif "frame" in packet:
|
|
45
|
+
print("{} x {} frame".format(packet["frame"]["width"], packet["frame"]["height"]))
|
|
46
|
+
elif "imus" in packet:
|
|
47
|
+
print("{} IMU samples".format(len(packet["imus"])))
|
|
48
|
+
elif "triggers" in packet:
|
|
49
|
+
print("{} trigger events".format(len(packet["triggers"])))
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Process frames
|
|
53
|
+
|
|
54
|
+
### Pillow (PIL)
|
|
55
|
+
|
|
56
|
+
```py
|
|
57
|
+
import aedat
|
|
58
|
+
import PIL.Image # https://pypi.org/project/Pillow/
|
|
59
|
+
|
|
60
|
+
index = 0
|
|
61
|
+
for packet in decoder:
|
|
62
|
+
if "frame" in packet:
|
|
63
|
+
image = PIL.Image.fromarray(
|
|
64
|
+
packet["frame"]["pixels"],
|
|
65
|
+
mode=packet["frame"]["format"],
|
|
66
|
+
)
|
|
67
|
+
image.save(f"{index}.png")
|
|
68
|
+
index += 1
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### OpenCV
|
|
72
|
+
|
|
73
|
+
```py
|
|
74
|
+
import aedat
|
|
75
|
+
import cv2 # https://pypi.org/project/opencv-python/
|
|
76
|
+
|
|
77
|
+
index = 0
|
|
78
|
+
for packet in decoder:
|
|
79
|
+
if "frame" in packet:
|
|
80
|
+
image = packet["frame"]["pixels"]
|
|
81
|
+
if packet["frame"]["format"] == "RGB":
|
|
82
|
+
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
|
83
|
+
elif packet["frame"]["format"] == "RGBA":
|
|
84
|
+
image = cv2.cvtColor(image, cv2.COLOR_RGBA2BGRA)
|
|
85
|
+
cv2.imwrite(f"{index}.png", image)
|
|
86
|
+
index += 1
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Detailed example
|
|
90
|
+
|
|
91
|
+
This is the same as the first example, with detailed comments:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import aedat
|
|
95
|
+
|
|
96
|
+
decoder = aedat.Decoder("/path/to/file.aedat")
|
|
97
|
+
"""
|
|
98
|
+
decoder is a packet iterator with an additional method id_to_stream
|
|
99
|
+
id_to_stream returns a dictionary with the following structure:
|
|
100
|
+
{
|
|
101
|
+
<int>: {
|
|
102
|
+
"type": <str>,
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
type is one of "events", "frame", "imus", "triggers"
|
|
106
|
+
if type is "events" or "frame", its parent dictionary has the following structure:
|
|
107
|
+
{
|
|
108
|
+
"type": <str>,
|
|
109
|
+
"width": <int>,
|
|
110
|
+
"height": <int>,
|
|
111
|
+
}
|
|
112
|
+
"""
|
|
113
|
+
print(decoder.id_to_stream())
|
|
114
|
+
|
|
115
|
+
for packet in decoder:
|
|
116
|
+
"""
|
|
117
|
+
packet is a dictionary with the following structure:
|
|
118
|
+
{
|
|
119
|
+
"stream_id": <int>,
|
|
120
|
+
}
|
|
121
|
+
packet also has exactly one of the following fields:
|
|
122
|
+
"events", "frame", "imus", "triggers"
|
|
123
|
+
"""
|
|
124
|
+
print(packet["stream_id"], end=": ")
|
|
125
|
+
if "events" in packet:
|
|
126
|
+
"""
|
|
127
|
+
packet["events"] is a structured numpy array with the following dtype:
|
|
128
|
+
[
|
|
129
|
+
("t", "<u8"),
|
|
130
|
+
("x", "<u2"),
|
|
131
|
+
("y", "<u2"),
|
|
132
|
+
("on", "?"),
|
|
133
|
+
]
|
|
134
|
+
"""
|
|
135
|
+
print("{} polarity events".format(len(packet["events"])))
|
|
136
|
+
elif "frame" in packet:
|
|
137
|
+
"""
|
|
138
|
+
packet["frame"] is a dictionary with the following structure:
|
|
139
|
+
{
|
|
140
|
+
"t": <int>,
|
|
141
|
+
"begin_t": <int>,
|
|
142
|
+
"end_t": <int>,
|
|
143
|
+
"exposure_begin_t": <int>,
|
|
144
|
+
"exposure_end_t": <int>,
|
|
145
|
+
"format": <str>,
|
|
146
|
+
"width": <int>,
|
|
147
|
+
"height": <int>,
|
|
148
|
+
"offset_x": <int>,
|
|
149
|
+
"offset_y": <int>,
|
|
150
|
+
"pixels": <numpy.array(shape=(height, width), dtype=uint8)>,
|
|
151
|
+
}
|
|
152
|
+
format is one of "L", "RGB", "RGBA"
|
|
153
|
+
"""
|
|
154
|
+
print("{} x {} frame".format(packet["frame"]["width"], packet["frame"]["height"]))
|
|
155
|
+
elif "imus" in packet:
|
|
156
|
+
"""
|
|
157
|
+
packet["imus"] is a structured numpy array with the following dtype:
|
|
158
|
+
[
|
|
159
|
+
("t", "<u8"),
|
|
160
|
+
("temperature", "<f4"),
|
|
161
|
+
("accelerometer_x", "<f4"),
|
|
162
|
+
("accelerometer_y", "<f4"),
|
|
163
|
+
("accelerometer_z", "<f4"),
|
|
164
|
+
("gyroscope_x", "<f4"),
|
|
165
|
+
("gyroscope_y", "<f4"),
|
|
166
|
+
("gyroscope_z", "<f4"),
|
|
167
|
+
("magnetometer_x", "<f4"),
|
|
168
|
+
("magnetometer_y", "<f4"),
|
|
169
|
+
("magnetometer_z", "<f4"),
|
|
170
|
+
]
|
|
171
|
+
"""
|
|
172
|
+
print("{} IMU samples".format(len(packet["imus"])))
|
|
173
|
+
elif "triggers" in packet:
|
|
174
|
+
"""
|
|
175
|
+
packet["triggers"] is a structured numpy array with the following dtype:
|
|
176
|
+
[
|
|
177
|
+
("t", "<u8"),
|
|
178
|
+
("source", "u1"),
|
|
179
|
+
]
|
|
180
|
+
the source value has the following meaning:
|
|
181
|
+
0: timestamp reset
|
|
182
|
+
1: external signal rising edge
|
|
183
|
+
2: external signal falling edge
|
|
184
|
+
3: external signal pulse
|
|
185
|
+
4: external generator rising edge
|
|
186
|
+
5: external generator falling edge
|
|
187
|
+
6: frame begin
|
|
188
|
+
7: frame end
|
|
189
|
+
8: exposure begin
|
|
190
|
+
9: exposure end
|
|
191
|
+
"""
|
|
192
|
+
print("{} trigger events".format(len(packet["triggers"])))
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Because the lifetime of the file handle is managed by Rust, decoder objects are not compatible with the [with](https://docs.python.org/3/reference/compound_stmts.html#with) statement. To ensure garbage collection, point the decoder variable to something else, for example `None`, when you are done using it:
|
|
196
|
+
|
|
197
|
+
```py
|
|
198
|
+
import aedat
|
|
199
|
+
|
|
200
|
+
decoder = aedat.Decoder("/path/to/file.aedat")
|
|
201
|
+
# do something with decoder
|
|
202
|
+
decoder = None
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Install from source
|
|
206
|
+
|
|
207
|
+
Local build (first run).
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
python3 -m venv .venv
|
|
211
|
+
source .venv/bin/activate
|
|
212
|
+
pip install --upgrade pip
|
|
213
|
+
pip install maturin numpy
|
|
214
|
+
maturin develop # or maturin develop --release to build with optimizations
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Local build (subsequent runs).
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
source .venv/bin/activate
|
|
221
|
+
maturin develop # or maturin develop --release to build with optimizations
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
After changing any of the files in _framebuffers_, one must run:
|
|
225
|
+
|
|
226
|
+
```sh
|
|
227
|
+
flatc --rust -o src/ flatbuffers/*.fbs
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
To format the code, run:
|
|
231
|
+
|
|
232
|
+
```sh
|
|
233
|
+
cargo fmt
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
# Publish
|
|
237
|
+
|
|
238
|
+
1. Bump the version number in _Cargo.toml_ and _pyproject.toml_.
|
|
239
|
+
|
|
240
|
+
2. Create a new release on GitHub.
|
|
241
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
aedat-2.2.0.dist-info/METADATA,sha256=wXY2pUg_yDCv17Bmkqb4O3NF7YktiAMqumLwVai6AMI,7218
|
|
2
|
+
aedat-2.2.0.dist-info/WHEEL,sha256=1ZpRl7NI5FUTGBGfAoLBw2DqQx_-H3hwfjZ2VbdjU5g,95
|
|
3
|
+
aedat-2.2.0.dist-info/licenses/LICENSE,sha256=fNneVkKWFh9p0XoRrDTFAXrj-VMTtlf10iqLsGGverY,1123
|
|
4
|
+
aedat/__init__.py,sha256=MLUJ9eDi5oJ_gJuqmMTyw8Xb2sHGU7PqJh6_QpDMn8Y,103
|
|
5
|
+
aedat/aedat.cp313-win_amd64.pyd,sha256=x10p2G2GabLr6xSRdt-omcwtd8vyvnMsdfiT6_foLl4,605184
|
|
6
|
+
aedat-2.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 International Centre for Neuromorphic Systems
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|