evutils 0.3.0__tar.gz
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.
- evutils-0.3.0/.github/workflows/release.yaml +83 -0
- evutils-0.3.0/.github/workflows/test.yaml +35 -0
- evutils-0.3.0/.gitignore +25 -0
- evutils-0.3.0/.gitmodules +3 -0
- evutils-0.3.0/CMakeLists.txt +53 -0
- evutils-0.3.0/LICENSE +19 -0
- evutils-0.3.0/PKG-INFO +154 -0
- evutils-0.3.0/README.md +102 -0
- evutils-0.3.0/csrc/evutils.c +24 -0
- evutils-0.3.0/csrc/include/evutils/evt3.h +69 -0
- evutils-0.3.0/csrc/include/evutils/evutils.h +30 -0
- evutils-0.3.0/csrc/include/evutils/types.h +81 -0
- evutils-0.3.0/docker/Dockerfile +20 -0
- evutils-0.3.0/docs/Makefile +20 -0
- evutils-0.3.0/docs/make.bat +35 -0
- evutils-0.3.0/docs/source/_static/event_hexagon_broken.webp +0 -0
- evutils-0.3.0/docs/source/_templates/autoapi/python/module.rst +156 -0
- evutils-0.3.0/docs/source/conf.py +100 -0
- evutils-0.3.0/docs/source/index.rst +25 -0
- evutils-0.3.0/pyproject.toml +70 -0
- evutils-0.3.0/src/evutils/__init__.py +39 -0
- evutils-0.3.0/src/evutils/_native.py +291 -0
- evutils-0.3.0/src/evutils/augment/__init__.py +11 -0
- evutils-0.3.0/src/evutils/augment/_drop.py +32 -0
- evutils-0.3.0/src/evutils/chunking.py +117 -0
- evutils-0.3.0/src/evutils/dataset/__init__.py +5 -0
- evutils-0.3.0/src/evutils/io/__init__.py +14 -0
- evutils-0.3.0/src/evutils/io/_aedat.py +17 -0
- evutils-0.3.0/src/evutils/io/_bin.py +15 -0
- evutils-0.3.0/src/evutils/io/_common.py +216 -0
- evutils-0.3.0/src/evutils/io/_csv.py +197 -0
- evutils-0.3.0/src/evutils/io/_dat.py +14 -0
- evutils-0.3.0/src/evutils/io/_hdf5.py +187 -0
- evutils-0.3.0/src/evutils/io/_npz.py +14 -0
- evutils-0.3.0/src/evutils/io/_raw.py +588 -0
- evutils-0.3.0/src/evutils/io/_reader.py +428 -0
- evutils-0.3.0/src/evutils/io/_txt.py +16 -0
- evutils-0.3.0/src/evutils/io/_writer.py +162 -0
- evutils-0.3.0/src/evutils/io/buffer.py +76 -0
- evutils-0.3.0/src/evutils/io/reader.py +145 -0
- evutils-0.3.0/src/evutils/io/writer.py +129 -0
- evutils-0.3.0/src/evutils/processing/__init__.py +14 -0
- evutils-0.3.0/src/evutils/processing/_masking.py +30 -0
- evutils-0.3.0/src/evutils/processing/_utils.py +25 -0
- evutils-0.3.0/src/evutils/random.py +77 -0
- evutils-0.3.0/src/evutils/repr/__init__.py +25 -0
- evutils-0.3.0/src/evutils/repr/_frame.py +126 -0
- evutils-0.3.0/src/evutils/repr/_histogram.py +110 -0
- evutils-0.3.0/src/evutils/repr/_timesurface.py +59 -0
- evutils-0.3.0/src/evutils/repr/_tore.py +58 -0
- evutils-0.3.0/src/evutils/repr/_voxel.py +54 -0
- evutils-0.3.0/src/evutils/torch/__init__.py +19 -0
- evutils-0.3.0/src/evutils/types.py +90 -0
- evutils-0.3.0/src/evutils/utils/__init__.py +8 -0
- evutils-0.3.0/src/evutils/utils/_checker.py +32 -0
- evutils-0.3.0/src/evutils/vis/__init__.py +5 -0
- evutils-0.3.0/src/evutils/vis/open3d.py +32 -0
- evutils-0.3.0/src/evutils/vis/plot3d.py +182 -0
- evutils-0.3.0/src/evutils/vis/reconstructor/__init__.py +11 -0
- evutils-0.3.0/src/evutils/vis/reconstructor/_base.py +71 -0
- evutils-0.3.0/src/evutils/vis/reconstructor/metavision.py +71 -0
- evutils-0.3.0/src/evutils/vis/reconstructor/rpg.py +217 -0
- evutils-0.3.0/tests/io/conftest.py +104 -0
- evutils-0.3.0/tests/io/test_bin.py +0 -0
- evutils-0.3.0/tests/io/test_csv.py +84 -0
- evutils-0.3.0/tests/io/test_dat.py +0 -0
- evutils-0.3.0/tests/io/test_hdf5.py +0 -0
- evutils-0.3.0/tests/io/test_npz.py +0 -0
- evutils-0.3.0/tests/io/test_raw.py +164 -0
- evutils-0.3.0/tests/test_random.py +43 -0
- evutils-0.3.0/tests/test_types.py +17 -0
- evutils-0.3.0/tests/test_vis.py +8 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Release & Publish Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
id-token: write # Required for modern PyPI publishing and GitHub Pages deployment
|
|
10
|
+
pages: write # Required for GitHub Pages deployment
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build-and-publish-pypi:
|
|
14
|
+
name: Build & Publish to PyPI
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
enable-cache: true
|
|
24
|
+
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.10"
|
|
29
|
+
|
|
30
|
+
- name: Install build tools
|
|
31
|
+
run: uv pip install --system build cibuildwheel
|
|
32
|
+
|
|
33
|
+
- name: Build source distribution (sdist)
|
|
34
|
+
run: python -m build --sdist
|
|
35
|
+
|
|
36
|
+
- name: Build compiled wheels (cibuildwheel)
|
|
37
|
+
run: python -m cibuildwheel --output-dir dist
|
|
38
|
+
env:
|
|
39
|
+
CIBW_SKIP: "cp36-* cp37-* cp38-* cp39-* pp* *musllinux*"
|
|
40
|
+
CIBW_BUILD_FRONTEND: "build[uv]"
|
|
41
|
+
|
|
42
|
+
- name: Publish to PyPI
|
|
43
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
44
|
+
with:
|
|
45
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
46
|
+
|
|
47
|
+
build-and-publish-docs:
|
|
48
|
+
name: Build & Publish Sphinx Docs
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
steps:
|
|
51
|
+
- name: Checkout repository
|
|
52
|
+
uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- name: Install uv
|
|
55
|
+
uses: astral-sh/setup-uv@v5
|
|
56
|
+
with:
|
|
57
|
+
enable-cache: true
|
|
58
|
+
|
|
59
|
+
- name: Set up Python
|
|
60
|
+
uses: actions/setup-python@v5
|
|
61
|
+
with:
|
|
62
|
+
python-version: "3.10"
|
|
63
|
+
|
|
64
|
+
- name: Install package and docs dependencies
|
|
65
|
+
# uv compiles the C extension locally and installs dependencies instantly
|
|
66
|
+
run: uv pip install --system .[docs]
|
|
67
|
+
|
|
68
|
+
- name: Build Sphinx HTML
|
|
69
|
+
run: |
|
|
70
|
+
cd docs
|
|
71
|
+
make html
|
|
72
|
+
|
|
73
|
+
- name: Setup GitHub Pages
|
|
74
|
+
uses: actions/configure-pages@v4
|
|
75
|
+
|
|
76
|
+
- name: Upload artifact
|
|
77
|
+
uses: actions/upload-pages-artifact@v3
|
|
78
|
+
with:
|
|
79
|
+
path: 'docs/build/html'
|
|
80
|
+
|
|
81
|
+
- name: Deploy to GitHub Pages
|
|
82
|
+
id: deployment
|
|
83
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
- feature/*
|
|
8
|
+
- fix/*
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- feature/*
|
|
13
|
+
- fix/*
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Download submoduels
|
|
25
|
+
run: git submodule update --init --recursive
|
|
26
|
+
- name: Setup Python
|
|
27
|
+
uses: actions/setup-python@v2
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python }}
|
|
30
|
+
- name: Install Pytests and any other packages
|
|
31
|
+
run: pip install pytest
|
|
32
|
+
- name: Install package
|
|
33
|
+
run: pip install .
|
|
34
|
+
- name: Run Tests
|
|
35
|
+
run: pytest -s -v
|
evutils-0.3.0/.gitignore
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
__pycache__
|
|
2
|
+
build
|
|
3
|
+
*.egg-info
|
|
4
|
+
_version.py
|
|
5
|
+
data
|
|
6
|
+
models
|
|
7
|
+
|
|
8
|
+
# Event types
|
|
9
|
+
*.csv
|
|
10
|
+
*.h5
|
|
11
|
+
*.raw
|
|
12
|
+
*.bias
|
|
13
|
+
*.dat
|
|
14
|
+
*.txt
|
|
15
|
+
*.tmp_index
|
|
16
|
+
*.prof
|
|
17
|
+
*.svg
|
|
18
|
+
*.data
|
|
19
|
+
*.png
|
|
20
|
+
*.jpg
|
|
21
|
+
|
|
22
|
+
*.json
|
|
23
|
+
|
|
24
|
+
test.py
|
|
25
|
+
*.ipynb
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18)
|
|
2
|
+
project(evutils_native LANGUAGES C)
|
|
3
|
+
|
|
4
|
+
# --- Standard / flags -------------------------------------------------------
|
|
5
|
+
set(CMAKE_C_STANDARD 11)
|
|
6
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
7
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
8
|
+
|
|
9
|
+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
10
|
+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
|
11
|
+
endif()
|
|
12
|
+
|
|
13
|
+
# --- Sources ----------------------------------------------------------------
|
|
14
|
+
# Compile every .c under csrc/. CONFIGURE_DEPENDS re-globs when files are
|
|
15
|
+
# added/removed so dropping in evt3.c / evt2.c / ... needs no edit here.
|
|
16
|
+
# (If you prefer an explicit list for reproducibility, replace this glob.)
|
|
17
|
+
file(GLOB EVUTILS_SOURCES CONFIGURE_DEPENDS
|
|
18
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/csrc/*.c")
|
|
19
|
+
|
|
20
|
+
add_library(evutils_native SHARED ${EVUTILS_SOURCES})
|
|
21
|
+
|
|
22
|
+
target_include_directories(evutils_native
|
|
23
|
+
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/csrc/include")
|
|
24
|
+
|
|
25
|
+
set_target_properties(evutils_native PROPERTIES
|
|
26
|
+
OUTPUT_NAME "evutils_native"
|
|
27
|
+
# Export all symbols on Windows without needing __declspec annotations.
|
|
28
|
+
# (For a curated public ABI later, switch to an explicit export macro.)
|
|
29
|
+
WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
30
|
+
|
|
31
|
+
if(MSVC)
|
|
32
|
+
target_compile_options(evutils_native PRIVATE /O2 /W3)
|
|
33
|
+
else()
|
|
34
|
+
target_compile_options(evutils_native PRIVATE
|
|
35
|
+
-O3 -Wall -Wextra
|
|
36
|
+
$<$<CONFIG:Debug>:-O0 -g>)
|
|
37
|
+
endif()
|
|
38
|
+
|
|
39
|
+
# --- Install ----------------------------------------------------------------
|
|
40
|
+
# When built through scikit-build-core (i.e. via `uv build` / pip), drop the
|
|
41
|
+
# shared library *inside* the python package directory in the wheel, so the
|
|
42
|
+
# ctypes loader finds it next to evutils/__init__.py.
|
|
43
|
+
if(DEFINED SKBUILD_PROJECT_NAME)
|
|
44
|
+
install(TARGETS evutils_native
|
|
45
|
+
LIBRARY DESTINATION "${SKBUILD_PROJECT_NAME}"
|
|
46
|
+
RUNTIME DESTINATION "${SKBUILD_PROJECT_NAME}")
|
|
47
|
+
else()
|
|
48
|
+
# Standalone `cmake --build build` leaves the .so in build/ where the
|
|
49
|
+
# loader's dev-mode search also looks.
|
|
50
|
+
install(TARGETS evutils_native
|
|
51
|
+
LIBRARY DESTINATION lib
|
|
52
|
+
RUNTIME DESTINATION bin)
|
|
53
|
+
endif()
|
evutils-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2024 Jakub Mandula
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
evutils-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: evutils
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Utilities for event-based vision
|
|
5
|
+
Keywords: events,dvs,neuromorphic,vision,event-based
|
|
6
|
+
Author-Email: Jakub Mandula <jakub.mandula@pbl.ee.ethz.ch>
|
|
7
|
+
License: Copyright (c) 2024 Jakub Mandula
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Requires-Dist: numpy>=2.0.0
|
|
28
|
+
Requires-Dist: tqdm>=4.41
|
|
29
|
+
Requires-Dist: matplotlib>=3.1
|
|
30
|
+
Requires-Dist: opencv-python>=4.2
|
|
31
|
+
Requires-Dist: numba>=0.57
|
|
32
|
+
Requires-Dist: scipy>=1.15.3
|
|
33
|
+
Requires-Dist: pandas>=2.3.3
|
|
34
|
+
Provides-Extra: torch
|
|
35
|
+
Requires-Dist: torch>=2.0; extra == "torch"
|
|
36
|
+
Provides-Extra: hdf5
|
|
37
|
+
Requires-Dist: hdf5plugin==6.0.0; extra == "hdf5"
|
|
38
|
+
Requires-Dist: h5py==3.16.0; extra == "hdf5"
|
|
39
|
+
Provides-Extra: test
|
|
40
|
+
Requires-Dist: pytest>=9.0.2; extra == "test"
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: sphinx>=8.0.0; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinx-autoapi>=3.6.1; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinx-autodoc-typehints>=3.0.1; extra == "docs"
|
|
45
|
+
Requires-Dist: sphinx-rtd-theme>=3.1.0; extra == "docs"
|
|
46
|
+
Requires-Dist: sphinx_book_theme>=1.0.0; extra == "docs"
|
|
47
|
+
Requires-Dist: pydata_sphinx_theme>=0.19.0; extra == "docs"
|
|
48
|
+
Requires-Dist: myst-parser>=4.0.0; extra == "docs"
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: evutils[docs,hdf5,test,torch]; extra == "dev"
|
|
51
|
+
Description-Content-Type: text/markdown
|
|
52
|
+
|
|
53
|
+
EV Utils
|
|
54
|
+
========
|
|
55
|
+
|
|
56
|
+
EV-utils is a collection of utilities for working event based data inspired by the [event_utils](https://github.com/TimoStoff/event_utils) library. This library aims at being camera independent (yet also supporting specific camera vendors) with minimal dependencies but also performent. The library is divided into severla modules some of which can be used without installing all the dependencies. These include:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
└── augment - Event augmentations
|
|
60
|
+
└── dataset - Wrappers for various dataset loaders
|
|
61
|
+
└── events
|
|
62
|
+
└── io
|
|
63
|
+
├── reader
|
|
64
|
+
└── writer
|
|
65
|
+
└── random
|
|
66
|
+
└── torch
|
|
67
|
+
└── types
|
|
68
|
+
└── vis
|
|
69
|
+
├── histogram
|
|
70
|
+
└── reconstructor
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
### From Git
|
|
77
|
+
```bash
|
|
78
|
+
git clone --recurse-submodules git@git.ee.ethz.ch:pbl/research/event-camera/evutils.git
|
|
79
|
+
|
|
80
|
+
cd evutils
|
|
81
|
+
pip install .
|
|
82
|
+
pip install -e . # Use this to install an editable version of the package
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quick API overview
|
|
86
|
+
|
|
87
|
+
### `augment`
|
|
88
|
+
|
|
89
|
+
Event augmentations
|
|
90
|
+
|
|
91
|
+
### `dataset`
|
|
92
|
+
|
|
93
|
+
Wrappers for various dataset loaders
|
|
94
|
+
|
|
95
|
+
### `io`
|
|
96
|
+
|
|
97
|
+
The `io` module provides methods for reading and writing events into various event formats. It provides a simple `.read()` and `.write()` interface as well as more advanced interfaces using iterators and slicing.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from evutils.io.reader import EventReader_RAW
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
ev_file = EventReader_RAW("raw_file.raw", delta_t=10e3)
|
|
104
|
+
|
|
105
|
+
events = ev_file.read()
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `utils`
|
|
110
|
+
|
|
111
|
+
Various utility functions
|
|
112
|
+
|
|
113
|
+
### `random`
|
|
114
|
+
|
|
115
|
+
Generating random events and adding noise to event recordings
|
|
116
|
+
|
|
117
|
+
### `types`
|
|
118
|
+
|
|
119
|
+
This provides several standard types for representing Events in numpy arrays
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### `vis`
|
|
123
|
+
|
|
124
|
+
The `vis` moduels provides several methods for visualizing the events (for example as histograms), but also provides a streamlined interface for more complex visualization techneques, such as using the [E2Vid](https://github.com/uzh-rpg/rpg_e2vid) reconstructor.
|
|
125
|
+
|
|
126
|
+
You need to download the pretrained weights:
|
|
127
|
+
```bash
|
|
128
|
+
wget "http://rpg.ifi.uzh.ch/data/E2VID/models/E2VID_lightweight.pth.tar" -O models/E2VID_lightweight.pth.tar
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from evutils.vis.reconstructor import RPG_Reconstructor
|
|
134
|
+
|
|
135
|
+
reconstructor = RPG_Reconstructor(1280, 720)
|
|
136
|
+
|
|
137
|
+
img = reconstructor.gen_frame(events)
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Running tests
|
|
142
|
+
|
|
143
|
+
You can run tests on using the pytest utility:
|
|
144
|
+
```bash
|
|
145
|
+
pytest -s
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## Acknowledgements
|
|
150
|
+
|
|
151
|
+
Thanks to all the contributors for supporting this project:
|
|
152
|
+
|
|
153
|
+
* Elia Franc
|
|
154
|
+
* Jakub Mandula
|
evutils-0.3.0/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
EV Utils
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
EV-utils is a collection of utilities for working event based data inspired by the [event_utils](https://github.com/TimoStoff/event_utils) library. This library aims at being camera independent (yet also supporting specific camera vendors) with minimal dependencies but also performent. The library is divided into severla modules some of which can be used without installing all the dependencies. These include:
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
└── augment - Event augmentations
|
|
8
|
+
└── dataset - Wrappers for various dataset loaders
|
|
9
|
+
└── events
|
|
10
|
+
└── io
|
|
11
|
+
├── reader
|
|
12
|
+
└── writer
|
|
13
|
+
└── random
|
|
14
|
+
└── torch
|
|
15
|
+
└── types
|
|
16
|
+
└── vis
|
|
17
|
+
├── histogram
|
|
18
|
+
└── reconstructor
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### From Git
|
|
25
|
+
```bash
|
|
26
|
+
git clone --recurse-submodules git@git.ee.ethz.ch:pbl/research/event-camera/evutils.git
|
|
27
|
+
|
|
28
|
+
cd evutils
|
|
29
|
+
pip install .
|
|
30
|
+
pip install -e . # Use this to install an editable version of the package
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick API overview
|
|
34
|
+
|
|
35
|
+
### `augment`
|
|
36
|
+
|
|
37
|
+
Event augmentations
|
|
38
|
+
|
|
39
|
+
### `dataset`
|
|
40
|
+
|
|
41
|
+
Wrappers for various dataset loaders
|
|
42
|
+
|
|
43
|
+
### `io`
|
|
44
|
+
|
|
45
|
+
The `io` module provides methods for reading and writing events into various event formats. It provides a simple `.read()` and `.write()` interface as well as more advanced interfaces using iterators and slicing.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from evutils.io.reader import EventReader_RAW
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
ev_file = EventReader_RAW("raw_file.raw", delta_t=10e3)
|
|
52
|
+
|
|
53
|
+
events = ev_file.read()
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### `utils`
|
|
58
|
+
|
|
59
|
+
Various utility functions
|
|
60
|
+
|
|
61
|
+
### `random`
|
|
62
|
+
|
|
63
|
+
Generating random events and adding noise to event recordings
|
|
64
|
+
|
|
65
|
+
### `types`
|
|
66
|
+
|
|
67
|
+
This provides several standard types for representing Events in numpy arrays
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### `vis`
|
|
71
|
+
|
|
72
|
+
The `vis` moduels provides several methods for visualizing the events (for example as histograms), but also provides a streamlined interface for more complex visualization techneques, such as using the [E2Vid](https://github.com/uzh-rpg/rpg_e2vid) reconstructor.
|
|
73
|
+
|
|
74
|
+
You need to download the pretrained weights:
|
|
75
|
+
```bash
|
|
76
|
+
wget "http://rpg.ifi.uzh.ch/data/E2VID/models/E2VID_lightweight.pth.tar" -O models/E2VID_lightweight.pth.tar
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from evutils.vis.reconstructor import RPG_Reconstructor
|
|
82
|
+
|
|
83
|
+
reconstructor = RPG_Reconstructor(1280, 720)
|
|
84
|
+
|
|
85
|
+
img = reconstructor.gen_frame(events)
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Running tests
|
|
90
|
+
|
|
91
|
+
You can run tests on using the pytest utility:
|
|
92
|
+
```bash
|
|
93
|
+
pytest -s
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## Acknowledgements
|
|
98
|
+
|
|
99
|
+
Thanks to all the contributors for supporting this project:
|
|
100
|
+
|
|
101
|
+
* Elia Franc
|
|
102
|
+
* Jakub Mandula
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#include "evutils/evutils.h"
|
|
2
|
+
|
|
3
|
+
#ifndef EVUTILS_VERSION
|
|
4
|
+
#define EVUTILS_VERSION "0.0.1"
|
|
5
|
+
#endif
|
|
6
|
+
|
|
7
|
+
const char *evutils_version(void) {
|
|
8
|
+
return EVUTILS_VERSION;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
size_t evutils_debug_fill_soa(event_buffer_soa_t *buf, uint64_t t0) {
|
|
12
|
+
if (!buf || !buf->t || !buf->x || !buf->y || !buf->p) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
const size_t n = buf->capacity;
|
|
16
|
+
for (size_t i = 0; i < n; ++i) {
|
|
17
|
+
buf->t[i] = t0 + (uint64_t)i;
|
|
18
|
+
buf->x[i] = (uint16_t)(i % 640u);
|
|
19
|
+
buf->y[i] = (uint16_t)(i % 480u);
|
|
20
|
+
buf->p[i] = (uint8_t)(i & 1u);
|
|
21
|
+
}
|
|
22
|
+
buf->size = n;
|
|
23
|
+
return n;
|
|
24
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* evutils — EVT3 parser public interface.
|
|
2
|
+
*
|
|
3
|
+
* This declares the EVT3 ABI exactly as your parser already exposes it, plus
|
|
4
|
+
* three small lifecycle functions for the opaque parser state. Python never
|
|
5
|
+
* needs to know the layout of evt3_state_t — it only holds the pointer.
|
|
6
|
+
*
|
|
7
|
+
* ACTION REQUIRED in evt3.c: implement the three lifecycle functions below.
|
|
8
|
+
* They are thin wrappers around whatever you already do to zero-initialise
|
|
9
|
+
* your state struct, e.g.:
|
|
10
|
+
*
|
|
11
|
+
* struct evt3_state_s { uint64_t ts; uint16_t y, vecbase_x; uint8_t vecbase_p; ... };
|
|
12
|
+
* evt3_state_t *EVT3_state_create(void) { return calloc(1, sizeof(evt3_state_t)); }
|
|
13
|
+
* void EVT3_state_reset(evt3_state_t *s) { memset(s, 0, sizeof(*s)); }
|
|
14
|
+
* void EVT3_state_destroy(evt3_state_t *s) { free(s); }
|
|
15
|
+
*/
|
|
16
|
+
#ifndef EVUTILS_EVT3_H
|
|
17
|
+
#define EVUTILS_EVT3_H
|
|
18
|
+
|
|
19
|
+
#include "evutils/types.h"
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
extern "C" {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
/* Returned by the chunk parsers to tell the caller why parsing stopped.
|
|
26
|
+
* NOTE: these values are a placeholder. If your evt3.c already defines this
|
|
27
|
+
* enum, delete this copy and include yours — but keep the Python side
|
|
28
|
+
* (_native.py) in sync with whatever the real values are. */
|
|
29
|
+
typedef enum evt3_parse_status_e {
|
|
30
|
+
EVT3_STATUS_OK = 0, /* reached end of input cleanly */
|
|
31
|
+
EVT3_STATUS_INPUT_EXHAUSTED = 1, /* ran out of input mid-group (carry) */
|
|
32
|
+
EVT3_STATUS_OUTPUT_FULL = 2, /* event/trigger buffer hit capacity */
|
|
33
|
+
EVT3_STATUS_ERROR = 3 /* malformed stream */
|
|
34
|
+
} evt3_parse_status_t;
|
|
35
|
+
|
|
36
|
+
/* Opaque parser state. Definition lives in evt3.c. */
|
|
37
|
+
typedef struct evt3_state_s evt3_state_t;
|
|
38
|
+
|
|
39
|
+
evt3_state_t *EVT3_state_create(void);
|
|
40
|
+
void EVT3_state_reset(evt3_state_t *state);
|
|
41
|
+
void EVT3_state_destroy(evt3_state_t *state);
|
|
42
|
+
|
|
43
|
+
typedef struct evt3_input_buffer_s {
|
|
44
|
+
const uint16_t *begin;
|
|
45
|
+
const uint16_t *end;
|
|
46
|
+
} evt3_input_buffer_t;
|
|
47
|
+
|
|
48
|
+
typedef struct evt3_parser_result_s {
|
|
49
|
+
const uint16_t *current;
|
|
50
|
+
evt3_parse_status_t status;
|
|
51
|
+
} evt3_parser_result_t;
|
|
52
|
+
|
|
53
|
+
evt3_parser_result_t EVT3_parse_chunk(
|
|
54
|
+
evt3_state_t *state,
|
|
55
|
+
const evt3_input_buffer_t *input_buffer,
|
|
56
|
+
event_buffer_t *event_buffer,
|
|
57
|
+
trigger_buffer_t *trigger_buffer);
|
|
58
|
+
|
|
59
|
+
evt3_parser_result_t EVT3_parse_chunk_soa(
|
|
60
|
+
evt3_state_t *state,
|
|
61
|
+
const evt3_input_buffer_t *input_buffer,
|
|
62
|
+
event_buffer_soa_t *event_buffer,
|
|
63
|
+
trigger_buffer_t *trigger_buffer);
|
|
64
|
+
|
|
65
|
+
#ifdef __cplusplus
|
|
66
|
+
}
|
|
67
|
+
#endif
|
|
68
|
+
|
|
69
|
+
#endif /* EVUTILS_EVT3_H */
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* evutils — library-level entry points.
|
|
2
|
+
*
|
|
3
|
+
* Small surface that does not belong to any one format: a version string and
|
|
4
|
+
* a debug probe used by the test suite to validate the Python <-> C SoA
|
|
5
|
+
* buffer hand-off without depending on a real parser being linked in yet.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef EVUTILS_H
|
|
8
|
+
#define EVUTILS_H
|
|
9
|
+
|
|
10
|
+
#include "evutils/types.h"
|
|
11
|
+
|
|
12
|
+
#ifdef __cplusplus
|
|
13
|
+
extern "C" {
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
/* Returns a static, NUL-terminated version string. */
|
|
17
|
+
const char *evutils_version(void);
|
|
18
|
+
|
|
19
|
+
/* DEBUG ONLY. Fills `buf` with `buf->capacity` synthetic events:
|
|
20
|
+
* t[i] = t0 + i, x[i] = i % 640, y[i] = i % 480, p[i] = i & 1
|
|
21
|
+
* Sets buf->size and returns the number written. Lets the Python test
|
|
22
|
+
* confirm that numpy-allocated columns are written in place by C.
|
|
23
|
+
* Returns 0 if any column pointer is NULL. */
|
|
24
|
+
size_t evutils_debug_fill_soa(event_buffer_soa_t *buf, uint64_t t0);
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#endif /* EVUTILS_H */
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* evutils — shared event/trigger/buffer types.
|
|
2
|
+
*
|
|
3
|
+
* This is the single source of truth for the C ABI that the Python ctypes
|
|
4
|
+
* layer mirrors (see src/evutils/_native.py). If you change a struct here,
|
|
5
|
+
* update the matching ctypes.Structure there.
|
|
6
|
+
*
|
|
7
|
+
* Layout notes (these matter for the Python bindings):
|
|
8
|
+
* - event32_t is 12 bytes: t@0 (4), x@4 (2), y@6 (2), p@8 (1), + 3 pad.
|
|
9
|
+
* The AoS numpy dtype must therefore use itemsize=12, not 9.
|
|
10
|
+
* - The SoA buffer uses uint64 timestamps; the AoS event_t uses uint32.
|
|
11
|
+
* (See the note in README about reconciling 32- vs 64-bit time.)
|
|
12
|
+
*/
|
|
13
|
+
#ifndef EVUTILS_TYPES_H
|
|
14
|
+
#define EVUTILS_TYPES_H
|
|
15
|
+
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
#include <stddef.h>
|
|
18
|
+
|
|
19
|
+
#ifdef __cplusplus
|
|
20
|
+
extern "C" {
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
typedef struct event32_s {
|
|
24
|
+
uint32_t t;
|
|
25
|
+
uint16_t x;
|
|
26
|
+
uint16_t y;
|
|
27
|
+
uint8_t p;
|
|
28
|
+
} event32_t;
|
|
29
|
+
|
|
30
|
+
typedef struct event64_s {
|
|
31
|
+
uint64_t t;
|
|
32
|
+
uint16_t x;
|
|
33
|
+
uint16_t y;
|
|
34
|
+
uint8_t p;
|
|
35
|
+
} event64_t;
|
|
36
|
+
|
|
37
|
+
typedef event32_t event_t;
|
|
38
|
+
|
|
39
|
+
typedef struct trigger64_s {
|
|
40
|
+
uint64_t t;
|
|
41
|
+
uint8_t id;
|
|
42
|
+
uint8_t p;
|
|
43
|
+
} trigger64_t;
|
|
44
|
+
|
|
45
|
+
typedef struct trigger32_s {
|
|
46
|
+
uint32_t t;
|
|
47
|
+
uint8_t id;
|
|
48
|
+
uint8_t p;
|
|
49
|
+
} trigger32_t;
|
|
50
|
+
|
|
51
|
+
typedef trigger32_t trigger_t;
|
|
52
|
+
|
|
53
|
+
/* Struct-of-arrays event buffer (preferred for the numpy path: one dtype per
|
|
54
|
+
* column, no struct padding to reconcile). */
|
|
55
|
+
typedef struct event_buffer_soa_s {
|
|
56
|
+
uint64_t *t;
|
|
57
|
+
uint16_t *x;
|
|
58
|
+
uint16_t *y;
|
|
59
|
+
uint8_t *p;
|
|
60
|
+
size_t capacity;
|
|
61
|
+
size_t size;
|
|
62
|
+
} event_buffer_soa_t;
|
|
63
|
+
|
|
64
|
+
/* Array-of-structs event buffer. */
|
|
65
|
+
typedef struct event_buffer_s {
|
|
66
|
+
event_t *events;
|
|
67
|
+
size_t capacity;
|
|
68
|
+
size_t size;
|
|
69
|
+
} event_buffer_t;
|
|
70
|
+
|
|
71
|
+
typedef struct trigger_buffer_s {
|
|
72
|
+
trigger_t *triggers;
|
|
73
|
+
size_t capacity;
|
|
74
|
+
size_t size;
|
|
75
|
+
} trigger_buffer_t;
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif /* EVUTILS_TYPES_H */
|