opennvr-app-sdk 0.4.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.
- opennvr_app_sdk-0.4.0/.gitignore +276 -0
- opennvr_app_sdk-0.4.0/LICENSE +202 -0
- opennvr_app_sdk-0.4.0/PKG-INFO +106 -0
- opennvr_app_sdk-0.4.0/README.md +75 -0
- opennvr_app_sdk-0.4.0/docs/events-consumption.md +49 -0
- opennvr_app_sdk-0.4.0/docs/tier0-consumption.md +119 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/__init__.py +176 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/_version.py +4 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/aio.py +306 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/alert_subscriber.py +229 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/alerts.py +608 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/cameras.py +159 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/client.py +420 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/config.py +42 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/contract.py +846 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/credentials.py +146 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/detector.py +359 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/domain_events.py +109 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/domain_subscriber.py +156 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/events.py +152 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/frame_app.py +274 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/frame_sources.py +207 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/geometry.py +264 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/infer_stream.py +148 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/manifest.py +321 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/nats_loop.py +113 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/state.py +179 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/tier0.py +230 -0
- opennvr_app_sdk-0.4.0/opennvr_app_sdk/usercontext.py +146 -0
- opennvr_app_sdk-0.4.0/pyproject.toml +60 -0
- opennvr_app_sdk-0.4.0/tests/conftest.py +29 -0
- opennvr_app_sdk-0.4.0/uv.lock +404 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Root-level ignores
|
|
2
|
+
|
|
3
|
+
# ============================================
|
|
4
|
+
# SENSITIVE DATA - NEVER COMMIT
|
|
5
|
+
# ============================================
|
|
6
|
+
# Environment variables
|
|
7
|
+
.env
|
|
8
|
+
.env.*
|
|
9
|
+
!.env.example
|
|
10
|
+
|
|
11
|
+
# Cryptographic keys and certificates
|
|
12
|
+
server/keys/*.pem
|
|
13
|
+
server/keys/*.key
|
|
14
|
+
server/keys/*.crt
|
|
15
|
+
server/keys/*.cert
|
|
16
|
+
server/keys/*.p12
|
|
17
|
+
server/keys/*.pfx
|
|
18
|
+
server/keys/*.jks
|
|
19
|
+
!server/keys/.gitkeep
|
|
20
|
+
byok-test-certs/
|
|
21
|
+
|
|
22
|
+
# M1b-fixup H-3: locally-generated MediaMTX self-signed certs
|
|
23
|
+
mediamtx-certs/
|
|
24
|
+
|
|
25
|
+
# ISSUE-6: locally-generated nginx TLS-reverse-proxy self-signed cert.
|
|
26
|
+
# Each operator's deployment mints its own keypair on first boot via
|
|
27
|
+
# nginx-certs-init; never committed.
|
|
28
|
+
nginx-certs/
|
|
29
|
+
|
|
30
|
+
# Agent examples' self-signed TLS pairs (camera-agent[-lite]-certs-init).
|
|
31
|
+
agent-certs/
|
|
32
|
+
|
|
33
|
+
# ISSUE-6 v3: host-hardening artifacts. The nft template + snapshot
|
|
34
|
+
# directories are operator-local — they reference the operator's
|
|
35
|
+
# specific interface names and contain `nft list ruleset` snapshots
|
|
36
|
+
# that may include details of their other firewall rules.
|
|
37
|
+
#
|
|
38
|
+
# ISSUE-9 fix: the pattern is anchored with a leading slash so it
|
|
39
|
+
# matches ONLY ``./host-hardening/`` (the operator artifact dir
|
|
40
|
+
# created by ``scripts/apply-camera-vlan-hardening.sh``), not
|
|
41
|
+
# ``./tests/host-hardening/`` (our regression test suites — which
|
|
42
|
+
# the un-anchored pattern accidentally excluded for the entire
|
|
43
|
+
# life of the ISSUE-6 → ISSUE-8 series, leaving every "X tests
|
|
44
|
+
# green" claim in CHANGELOG referencing files that lived only in
|
|
45
|
+
# local working trees).
|
|
46
|
+
/host-hardening/
|
|
47
|
+
|
|
48
|
+
# Secrets and credentials
|
|
49
|
+
secrets/
|
|
50
|
+
*.secret
|
|
51
|
+
*_secret.txt
|
|
52
|
+
credentials.json
|
|
53
|
+
token.json
|
|
54
|
+
|
|
55
|
+
# ============================================
|
|
56
|
+
# GENERATED BUILD ARTIFACTS
|
|
57
|
+
# ============================================
|
|
58
|
+
# Generated recordings output
|
|
59
|
+
Recordings/
|
|
60
|
+
recordings/
|
|
61
|
+
!app/src/views/settings/recordings/
|
|
62
|
+
*.mp4
|
|
63
|
+
*.mkv
|
|
64
|
+
*.avi
|
|
65
|
+
*.webm
|
|
66
|
+
# …except the bundled talking-avatar clips (placeholders; swap your own in)
|
|
67
|
+
!examples/camera-agent/demo/avatar/*.mp4
|
|
68
|
+
!examples/camera-agent/demo/avatar/*.webm
|
|
69
|
+
|
|
70
|
+
# Python compiled
|
|
71
|
+
__pycache__/
|
|
72
|
+
*.py[cod]
|
|
73
|
+
*$py.class
|
|
74
|
+
*.so
|
|
75
|
+
*.pyo
|
|
76
|
+
*.pyd
|
|
77
|
+
.Python
|
|
78
|
+
build/
|
|
79
|
+
develop-eggs/
|
|
80
|
+
dist/
|
|
81
|
+
downloads/
|
|
82
|
+
eggs/
|
|
83
|
+
.eggs/
|
|
84
|
+
lib/
|
|
85
|
+
!app/src/lib/
|
|
86
|
+
lib64/
|
|
87
|
+
parts/
|
|
88
|
+
sdist/
|
|
89
|
+
var/
|
|
90
|
+
wheels/
|
|
91
|
+
share/python-wheels/
|
|
92
|
+
*.egg-info/
|
|
93
|
+
.installed.cfg
|
|
94
|
+
*.egg
|
|
95
|
+
MANIFEST
|
|
96
|
+
|
|
97
|
+
# Python virtual environments
|
|
98
|
+
venv/
|
|
99
|
+
env/
|
|
100
|
+
ENV/
|
|
101
|
+
.venv/
|
|
102
|
+
server/venv/
|
|
103
|
+
|
|
104
|
+
# uv lockfiles (tracked in git for reproducibility)
|
|
105
|
+
# Uncomment if you don't want to track lockfiles:
|
|
106
|
+
# uv.lock
|
|
107
|
+
|
|
108
|
+
# Frontend builds
|
|
109
|
+
app/dist/
|
|
110
|
+
app/dist-ssr/
|
|
111
|
+
app/dev-dist/
|
|
112
|
+
app/node_modules/
|
|
113
|
+
app/.cache/
|
|
114
|
+
|
|
115
|
+
# ============================================
|
|
116
|
+
# LOGS AND DEBUG FILES
|
|
117
|
+
# ============================================
|
|
118
|
+
# Application logs
|
|
119
|
+
logs/
|
|
120
|
+
*.log
|
|
121
|
+
*.log.*
|
|
122
|
+
server/logs/*.log
|
|
123
|
+
server/logs/*.log.*
|
|
124
|
+
npm-debug.log*
|
|
125
|
+
yarn-debug.log*
|
|
126
|
+
yarn-error.log*
|
|
127
|
+
pnpm-debug.log*
|
|
128
|
+
lerna-debug.log*
|
|
129
|
+
|
|
130
|
+
# Debug files
|
|
131
|
+
debug_*.py
|
|
132
|
+
debug_*.txt
|
|
133
|
+
*_debug.txt
|
|
134
|
+
server/debug_*.py
|
|
135
|
+
server/debug_*.txt
|
|
136
|
+
|
|
137
|
+
# ============================================
|
|
138
|
+
# TEMPORARY AND TEST FILES
|
|
139
|
+
# ============================================
|
|
140
|
+
# Ad-hoc scratch test scripts at the repo root or in server/ are ignored
|
|
141
|
+
# (they're typically one-off diagnostics that shouldn't ship). Real test
|
|
142
|
+
# suites under server/tests/ ARE tracked — the negation below re-includes
|
|
143
|
+
# them so pytest discovery works in CI.
|
|
144
|
+
test_*.py
|
|
145
|
+
*_test.py
|
|
146
|
+
server/test_*.py
|
|
147
|
+
!server/tests/test_*.py
|
|
148
|
+
!server/tests/**/test_*.py
|
|
149
|
+
# KAI-C's pytest suite (A2.4): same negation pattern as server/tests/.
|
|
150
|
+
!kai-c/test/test_*.py
|
|
151
|
+
# Example-app pytest suites (A2.5+): each example/{slug}/tests/ is part
|
|
152
|
+
# of the shipped artifact and must be tracked.
|
|
153
|
+
!examples/**/tests/test_*.py
|
|
154
|
+
# detect-pipeline (Tier-0) pytest suite: same negation pattern — the tests
|
|
155
|
+
# live in detect-pipeline/test/ (singular) and MUST be tracked so CI runs them.
|
|
156
|
+
!detect-pipeline/test/test_*.py
|
|
157
|
+
# App SDK pytest suite: same negation pattern as server/tests/. Without
|
|
158
|
+
# this the blanket ``test_*.py`` above silently untracked the whole
|
|
159
|
+
# sdk/opennvr-app-sdk/tests/ suite.
|
|
160
|
+
!sdk/opennvr-app-sdk/tests/test_*.py
|
|
161
|
+
# App template smoke test: part of the shipped scaffold — the generator
|
|
162
|
+
# copies it into every new app and FIRST_DETECTOR.md promises it passes
|
|
163
|
+
# out of the box. Without this negation the blanket ``test_*.py`` above
|
|
164
|
+
# silently untracked it (review finding: fresh clones got "no tests ran").
|
|
165
|
+
!templates/opennvr-app/tests/test_*.py
|
|
166
|
+
# App-installer pytest suite: same negation pattern.
|
|
167
|
+
!scripts/app-installer/tests/test_*.py
|
|
168
|
+
server/scripts/check_*.py
|
|
169
|
+
server/scripts/get_*.py
|
|
170
|
+
server/scripts/delete_*.py
|
|
171
|
+
server/scripts/update_*.py
|
|
172
|
+
server/scripts/debug_*.py
|
|
173
|
+
server/scripts/setup_venv.py
|
|
174
|
+
server/scripts/logging_summary.py
|
|
175
|
+
server/scripts/inspect_schema.py
|
|
176
|
+
server/check_*.py
|
|
177
|
+
server/get_*.py
|
|
178
|
+
server/delete_*.py
|
|
179
|
+
server/update_*.py
|
|
180
|
+
*.dat
|
|
181
|
+
*.tmp
|
|
182
|
+
*.temp
|
|
183
|
+
*.cache
|
|
184
|
+
|
|
185
|
+
# Database dumps and backups
|
|
186
|
+
*.sql
|
|
187
|
+
*.db
|
|
188
|
+
*.sqlite
|
|
189
|
+
*.sqlite3
|
|
190
|
+
*.dump
|
|
191
|
+
|
|
192
|
+
# ============================================
|
|
193
|
+
# CONFIGURATION FILES (LOCAL OVERRIDES)
|
|
194
|
+
# ============================================
|
|
195
|
+
# MediaMTX configs (should use default from repo)
|
|
196
|
+
server/mediamtx*.yml
|
|
197
|
+
!mediamtx.yml
|
|
198
|
+
|
|
199
|
+
# Local configs
|
|
200
|
+
*.local
|
|
201
|
+
*.local.*
|
|
202
|
+
!mediamtx.local.yml
|
|
203
|
+
config.local.*
|
|
204
|
+
|
|
205
|
+
# ============================================
|
|
206
|
+
# OS GENERATED FILES
|
|
207
|
+
# ============================================
|
|
208
|
+
.DS_Store
|
|
209
|
+
.DS_Store?
|
|
210
|
+
._*
|
|
211
|
+
.Spotlight-V100
|
|
212
|
+
.Trashes
|
|
213
|
+
ehthumbs.db
|
|
214
|
+
Thumbs.db
|
|
215
|
+
desktop.ini
|
|
216
|
+
*~
|
|
217
|
+
|
|
218
|
+
# ============================================
|
|
219
|
+
# IDE AND EDITOR FILES
|
|
220
|
+
# ============================================
|
|
221
|
+
.vscode/
|
|
222
|
+
.idea/
|
|
223
|
+
*.swp
|
|
224
|
+
*.swo
|
|
225
|
+
*.swn
|
|
226
|
+
*.bak
|
|
227
|
+
.project
|
|
228
|
+
.classpath
|
|
229
|
+
.c9/
|
|
230
|
+
*.launch
|
|
231
|
+
.settings/
|
|
232
|
+
.metadata
|
|
233
|
+
|
|
234
|
+
# ============================================
|
|
235
|
+
# THIRD-PARTY EXECUTABLES
|
|
236
|
+
# ============================================
|
|
237
|
+
# MediaMTX binary
|
|
238
|
+
mediamtx/
|
|
239
|
+
mediamtx.exe
|
|
240
|
+
mediamtx
|
|
241
|
+
|
|
242
|
+
# ============================================
|
|
243
|
+
# DOCUMENTATION (ANALYSIS/DESIGN DOCS)
|
|
244
|
+
# ============================================
|
|
245
|
+
# These are analysis docs, not part of codebase
|
|
246
|
+
CURRENT_PLAYBACK_ARCHITECTURE.md
|
|
247
|
+
KEYS_DIRECTORY_ANALYSIS.md
|
|
248
|
+
VOD_PLAYBACK_POSSIBILITIES.md
|
|
249
|
+
CLOUD_AI_IMPLEMENTATION.txt
|
|
250
|
+
RECORDING_RETENTION_IMPLEMENTATION.md
|
|
251
|
+
ENDPOINT_SECURITY_ANALYSIS.md
|
|
252
|
+
IMPLEMENTATION_COMPLETE.md
|
|
253
|
+
KAVACH_COMPLIANCE_REPORT.md
|
|
254
|
+
|
|
255
|
+
# ============================================
|
|
256
|
+
# LOCAL NESTED REPOS (DEV ONLY)
|
|
257
|
+
# ============================================
|
|
258
|
+
# AI-adapters is a separate repo
|
|
259
|
+
AI-adapters/
|
|
260
|
+
|
|
261
|
+
# ============================================
|
|
262
|
+
|
|
263
|
+
# Temporary text files (analysis/debug)
|
|
264
|
+
*_analysis.txt
|
|
265
|
+
# supervisord config built into image
|
|
266
|
+
!supervisord.conf
|
|
267
|
+
|
|
268
|
+
# Launcher-written host network hints (mounted into opennvr-core)
|
|
269
|
+
data/net-hints/
|
|
270
|
+
|
|
271
|
+
# KAI-C runtime adapter-registration receipts (#371) — machine state,
|
|
272
|
+
# never source. In Docker this lives on the opennvr_kai_c_state volume.
|
|
273
|
+
kai-c-state/
|
|
274
|
+
|
|
275
|
+
# make sdk-docs output (generated, see docs/SDK_REFERENCE.md)
|
|
276
|
+
sdk/opennvr-app-sdk/docs/api/
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: opennvr-app-sdk
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Shared SDK for OpenNVR monitoring apps: §11.5 alert dispatch, zone geometry, keyed TTL state, app manifests, and the Detector / FrameApp base loops.
|
|
5
|
+
Project-URL: Homepage, https://opennvr.org
|
|
6
|
+
Project-URL: Documentation, https://github.com/open-nvr/open-nvr/blob/main/docs/SDK_REFERENCE.md
|
|
7
|
+
Project-URL: Developer program, https://github.com/open-nvr/open-nvr/blob/main/docs/DEVELOPER_PROGRAM.md
|
|
8
|
+
Project-URL: Source, https://github.com/open-nvr/open-nvr/tree/main/sdk/opennvr-app-sdk
|
|
9
|
+
Project-URL: Changelog, https://github.com/open-nvr/open-nvr/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/open-nvr/open-nvr/issues?q=label%3Asdk
|
|
11
|
+
Author: OpenNVR contributors
|
|
12
|
+
License: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: computer-vision,nvr,opennvr,sdk,surveillance,video
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Multimedia :: Video
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: httpx<1.0,>=0.27
|
|
27
|
+
Requires-Dist: nats-py>=2.6
|
|
28
|
+
Requires-Dist: pyyaml<7.0,>=6.0
|
|
29
|
+
Requires-Dist: websockets>=13.0
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# opennvr-app-sdk
|
|
33
|
+
|
|
34
|
+
The SDK for building vision apps on [OpenNVR](https://opennvr.org), the
|
|
35
|
+
self-hosted AI video platform. Cameras, Tier-0 detections, pluggable
|
|
36
|
+
inference, an event bus, recordings, an operator alert inbox, users and
|
|
37
|
+
per-camera permissions, and a catalog every deployment opens — all
|
|
38
|
+
already running. You write the rule, the model or the workflow; this
|
|
39
|
+
package is the only import you need.
|
|
40
|
+
|
|
41
|
+
Apache-2.0 — ship your app under any licence, closed included.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install opennvr-app-sdk
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## A detector in one method
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from opennvr_app_sdk import Alert, AppManifest, Detector, Param, app
|
|
51
|
+
|
|
52
|
+
class Loitering(Detector):
|
|
53
|
+
manifest = AppManifest(
|
|
54
|
+
id="loitering", name="Loitering", version="1.0.0", category="perimeter",
|
|
55
|
+
requires_tasks=["object_detection"],
|
|
56
|
+
params=[Param("dwell_s", float, default=30.0)],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def setup(self):
|
|
60
|
+
self.present = self.keyed_state(ttl=10.0) # forgets a camera 10 s after the last person
|
|
61
|
+
|
|
62
|
+
def on_detections(self, camera_id, detections, event):
|
|
63
|
+
people = [d for d in detections if d.get("label") == "person"]
|
|
64
|
+
if not people:
|
|
65
|
+
return
|
|
66
|
+
rec = self.present.touch(camera_id)
|
|
67
|
+
if rec.age >= self.cfg.dwell_s and not rec.alerted:
|
|
68
|
+
rec.alerted = True
|
|
69
|
+
yield Alert(title="Loitering", description=f"{len(people)} person(s) for {rec.age:.0f}s",
|
|
70
|
+
camera_id=camera_id, severity="medium")
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
raise SystemExit(app(Loitering).run())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
That app subscribes to the platform's detections, serves the registry
|
|
77
|
+
contract (`/health`, `/state`, `/manifest`, config form, actions),
|
|
78
|
+
registers itself in the App Catalog, is issued its own credential, and
|
|
79
|
+
fires alerts that reach the operator inbox — none of which you wrote.
|
|
80
|
+
|
|
81
|
+
## The platform, from an app
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from opennvr_app_sdk import OpenNVR # or opennvr_app_sdk.aio.AsyncOpenNVR
|
|
85
|
+
|
|
86
|
+
nvr = OpenNVR() # OPENNVR_URL + the app's key
|
|
87
|
+
for cam in nvr.cameras(): # only cameras assigned to this app
|
|
88
|
+
jpeg = nvr.snapshot(cam)
|
|
89
|
+
det = nvr.ai.infer("yolov8", jpeg, task="object_detection", camera_id=cam.handle)
|
|
90
|
+
nvr.state.set("last_seen", {"cam1": 12.5}) # durable, survives restarts
|
|
91
|
+
clips = nvr.recordings("cam1").list(start="2026-09-05T00:00:00Z")
|
|
92
|
+
mine = nvr.alerts.inbox(unacked=True)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Where to go next
|
|
96
|
+
|
|
97
|
+
* [Developer program](https://github.com/open-nvr/open-nvr/blob/main/docs/DEVELOPER_PROGRAM.md) — the deal: no fee, your licence, the compatibility promise.
|
|
98
|
+
* [Your first detector](https://github.com/open-nvr/open-nvr/blob/main/docs/FIRST_DETECTOR.md) — scaffold, run against a stack, list in the catalog.
|
|
99
|
+
* [SDK reference](https://github.com/open-nvr/open-nvr/blob/main/docs/SDK_REFERENCE.md) — every public name, by task.
|
|
100
|
+
* [Platform client](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_PLATFORM.md), [app surfaces](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_SURFACES.md), [credentials](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_CREDENTIALS.md), [event contracts](https://github.com/open-nvr/open-nvr/blob/main/docs/EVENT_CONTRACTS.md).
|
|
101
|
+
* [Example apps](https://github.com/open-nvr/open-nvr/tree/main/examples) — thirteen first-party apps built on this SDK.
|
|
102
|
+
|
|
103
|
+
Compatibility: the app-registry contract is versioned (`api_version`)
|
|
104
|
+
and tested in the OpenNVR repository on every change; `min_sdk_version`
|
|
105
|
+
only moves when an older SDK would misbehave. Issues tagged `sdk` at
|
|
106
|
+
[open-nvr/open-nvr](https://github.com/open-nvr/open-nvr/issues).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# opennvr-app-sdk
|
|
2
|
+
|
|
3
|
+
The SDK for building vision apps on [OpenNVR](https://opennvr.org), the
|
|
4
|
+
self-hosted AI video platform. Cameras, Tier-0 detections, pluggable
|
|
5
|
+
inference, an event bus, recordings, an operator alert inbox, users and
|
|
6
|
+
per-camera permissions, and a catalog every deployment opens — all
|
|
7
|
+
already running. You write the rule, the model or the workflow; this
|
|
8
|
+
package is the only import you need.
|
|
9
|
+
|
|
10
|
+
Apache-2.0 — ship your app under any licence, closed included.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install opennvr-app-sdk
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## A detector in one method
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from opennvr_app_sdk import Alert, AppManifest, Detector, Param, app
|
|
20
|
+
|
|
21
|
+
class Loitering(Detector):
|
|
22
|
+
manifest = AppManifest(
|
|
23
|
+
id="loitering", name="Loitering", version="1.0.0", category="perimeter",
|
|
24
|
+
requires_tasks=["object_detection"],
|
|
25
|
+
params=[Param("dwell_s", float, default=30.0)],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def setup(self):
|
|
29
|
+
self.present = self.keyed_state(ttl=10.0) # forgets a camera 10 s after the last person
|
|
30
|
+
|
|
31
|
+
def on_detections(self, camera_id, detections, event):
|
|
32
|
+
people = [d for d in detections if d.get("label") == "person"]
|
|
33
|
+
if not people:
|
|
34
|
+
return
|
|
35
|
+
rec = self.present.touch(camera_id)
|
|
36
|
+
if rec.age >= self.cfg.dwell_s and not rec.alerted:
|
|
37
|
+
rec.alerted = True
|
|
38
|
+
yield Alert(title="Loitering", description=f"{len(people)} person(s) for {rec.age:.0f}s",
|
|
39
|
+
camera_id=camera_id, severity="medium")
|
|
40
|
+
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
raise SystemExit(app(Loitering).run())
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
That app subscribes to the platform's detections, serves the registry
|
|
46
|
+
contract (`/health`, `/state`, `/manifest`, config form, actions),
|
|
47
|
+
registers itself in the App Catalog, is issued its own credential, and
|
|
48
|
+
fires alerts that reach the operator inbox — none of which you wrote.
|
|
49
|
+
|
|
50
|
+
## The platform, from an app
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from opennvr_app_sdk import OpenNVR # or opennvr_app_sdk.aio.AsyncOpenNVR
|
|
54
|
+
|
|
55
|
+
nvr = OpenNVR() # OPENNVR_URL + the app's key
|
|
56
|
+
for cam in nvr.cameras(): # only cameras assigned to this app
|
|
57
|
+
jpeg = nvr.snapshot(cam)
|
|
58
|
+
det = nvr.ai.infer("yolov8", jpeg, task="object_detection", camera_id=cam.handle)
|
|
59
|
+
nvr.state.set("last_seen", {"cam1": 12.5}) # durable, survives restarts
|
|
60
|
+
clips = nvr.recordings("cam1").list(start="2026-09-05T00:00:00Z")
|
|
61
|
+
mine = nvr.alerts.inbox(unacked=True)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Where to go next
|
|
65
|
+
|
|
66
|
+
* [Developer program](https://github.com/open-nvr/open-nvr/blob/main/docs/DEVELOPER_PROGRAM.md) — the deal: no fee, your licence, the compatibility promise.
|
|
67
|
+
* [Your first detector](https://github.com/open-nvr/open-nvr/blob/main/docs/FIRST_DETECTOR.md) — scaffold, run against a stack, list in the catalog.
|
|
68
|
+
* [SDK reference](https://github.com/open-nvr/open-nvr/blob/main/docs/SDK_REFERENCE.md) — every public name, by task.
|
|
69
|
+
* [Platform client](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_PLATFORM.md), [app surfaces](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_SURFACES.md), [credentials](https://github.com/open-nvr/open-nvr/blob/main/docs/APP_CREDENTIALS.md), [event contracts](https://github.com/open-nvr/open-nvr/blob/main/docs/EVENT_CONTRACTS.md).
|
|
70
|
+
* [Example apps](https://github.com/open-nvr/open-nvr/tree/main/examples) — thirteen first-party apps built on this SDK.
|
|
71
|
+
|
|
72
|
+
Compatibility: the app-registry contract is versioned (`api_version`)
|
|
73
|
+
and tested in the OpenNVR repository on every change; `min_sdk_version`
|
|
74
|
+
only moves when an older SDK would misbehave. Issues tagged `sdk` at
|
|
75
|
+
[open-nvr/open-nvr](https://github.com/open-nvr/open-nvr/issues).
|