@camera.ui/camera-ui-wasm-motion 0.0.13 → 0.0.15
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.
- package/bundle.zip +0 -0
- package/package.json +17 -38
- package/CHANGELOG.md +0 -8
- package/CONTRIBUTING.md +0 -1
- package/LICENSE.md +0 -22
- package/README.md +0 -1
- package/dist/defaults.d.ts +0 -4
- package/dist/defaults.js +0 -5
- package/dist/defaults.js.map +0 -1
- package/dist/detector.d.ts +0 -22
- package/dist/detector.js +0 -239
- package/dist/detector.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.js +0 -60
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -6
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/wasm/build/detector.d.ts +0 -147
- package/dist/wasm/build/detector.js +0 -108
- package/dist/wasm/build/detector.wasm +0 -0
package/bundle.zip
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,53 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "WASM Motion",
|
|
3
3
|
"name": "@camera.ui/camera-ui-wasm-motion",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"description": "camera.ui wasm motion detection plugin",
|
|
6
6
|
"author": "seydx (https://github.com/seydx/camera.ui)",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
|
-
"type": "
|
|
8
|
+
"type": "commonjs",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "rimraf dist && npm run build:wasm && tsc
|
|
10
|
+
"build": "rimraf dist && npm run build:wasm && tsc",
|
|
11
11
|
"build:wasm": "cd ./src/wasm && asc assembly/* --config asconfig.json && cd ../../",
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"update": "updates --update ./",
|
|
12
|
+
"bundle": "npm run format && npm run lint && npm run build && cui bundle",
|
|
13
|
+
"format": "prettier --write \"src/\" --ignore-unknown --no-error-on-unmatched-pattern",
|
|
15
14
|
"install-updates": "npm i --save",
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"@camera.ui/types": "^0.0.77",
|
|
24
|
-
"@rushstack/eslint-patch": "^1.10.4",
|
|
25
|
-
"@types/fs-extra": "^11.0.4",
|
|
26
|
-
"@types/node": "^22.7.6",
|
|
27
|
-
"@types/ws": "^8.5.12",
|
|
28
|
-
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
|
29
|
-
"@typescript-eslint/parser": "^8.10.0",
|
|
30
|
-
"assemblyscript": "^0.27.30",
|
|
31
|
-
"assemblyscript-prettier": "^3.0.1",
|
|
32
|
-
"concurrently": "^9.0.1",
|
|
33
|
-
"copyfiles": "^2.4.1",
|
|
34
|
-
"eslint": "8.57.0",
|
|
35
|
-
"eslint-config-prettier": "^9.1.0",
|
|
36
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
37
|
-
"fs-extra": "^11.2.0",
|
|
38
|
-
"prettier": "^3.3.3",
|
|
39
|
-
"rimraf": "^6.0.1",
|
|
40
|
-
"set-interval-async": "^3.0.3",
|
|
41
|
-
"sharp": "^0.33.5",
|
|
42
|
-
"typescript": "^5.6.3",
|
|
43
|
-
"updates": "^16.4.0"
|
|
15
|
+
"lint": "eslint .",
|
|
16
|
+
"lint:fix": "eslint --fix .",
|
|
17
|
+
"prepublishOnly": "node -e \"if(!process.env.SAFE_PUBLISH){console.error('Error: Please use @camera.ui/cli to publish the plugin:\\n npm run publish:alpha\\n npm run publish:beta\\n npm run publish:latest\\n');process.exit(1)}\"",
|
|
18
|
+
"publish:alpha": "cui publish --alpha",
|
|
19
|
+
"publish:beta": "cui publish --beta",
|
|
20
|
+
"publish:latest": "cui publish --latest",
|
|
21
|
+
"update": "updates --update ./"
|
|
44
22
|
},
|
|
45
23
|
"bugs": {
|
|
46
24
|
"url": "https://github.com/seydx/camera.ui/issues"
|
|
47
25
|
},
|
|
48
26
|
"engines": {
|
|
49
|
-
"camera.ui": ">=0.0.34-alpha.
|
|
50
|
-
"node": ">=20.
|
|
27
|
+
"camera.ui": ">=0.0.34-alpha.4",
|
|
28
|
+
"node": ">=20.18.0"
|
|
51
29
|
},
|
|
52
30
|
"homepage": "https://github.com/seydx/camera.ui#readme",
|
|
53
31
|
"keywords": [
|
|
@@ -66,6 +44,7 @@
|
|
|
66
44
|
"dependencies": [],
|
|
67
45
|
"options": {
|
|
68
46
|
"extendedMotionDetection": false
|
|
69
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"bundled": true
|
|
70
49
|
}
|
|
71
|
-
}
|
|
50
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
All notable changes to this project will be documented in this file.
|
|
2
|
-
|
|
3
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
4
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
|
-
|
|
6
|
-
## [X.X.X] - ???
|
|
7
|
-
|
|
8
|
-
- Initial Release
|
package/CONTRIBUTING.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# Contributing
|
package/LICENSE.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023-2024 seydx <dev@seydx.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# @camera.ui/camera-ui-wasm-motion
|
package/dist/defaults.d.ts
DELETED
package/dist/defaults.js
DELETED
package/dist/defaults.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
|
package/dist/detector.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { CameraDevice, CameraStorage, PluginAPI } from '@camera.ui/types';
|
|
2
|
-
import type { CameraStorageValues } from './types.js';
|
|
3
|
-
export declare class CameraDetector {
|
|
4
|
-
cameraStorage: CameraStorage<CameraStorageValues>;
|
|
5
|
-
private api;
|
|
6
|
-
private cameraDevice;
|
|
7
|
-
private cameraLogger;
|
|
8
|
-
private started;
|
|
9
|
-
private closed;
|
|
10
|
-
private restarting;
|
|
11
|
-
private wasmExports?;
|
|
12
|
-
constructor(cameraDevice: CameraDevice, api: PluginAPI);
|
|
13
|
-
start(): Promise<void>;
|
|
14
|
-
close(): void;
|
|
15
|
-
private initiateWASM;
|
|
16
|
-
private setupMemory;
|
|
17
|
-
private startDetection;
|
|
18
|
-
private restart;
|
|
19
|
-
private detect;
|
|
20
|
-
private defaultSettings;
|
|
21
|
-
private createCameraStorage;
|
|
22
|
-
}
|
package/dist/detector.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import { instantiate } from '@assemblyscript/loader';
|
|
2
|
-
import { readFileSync } from 'node:fs';
|
|
3
|
-
import { dirname, resolve } from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { DEFAULT_BLUR_RADIUS, DEFAULT_DILATION_SIZE, DEFAULT_MOTION_AREA, DEFAULT_THRESHOLD } from './defaults.js';
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = dirname(__filename);
|
|
8
|
-
export class CameraDetector {
|
|
9
|
-
cameraStorage;
|
|
10
|
-
api;
|
|
11
|
-
cameraDevice;
|
|
12
|
-
cameraLogger;
|
|
13
|
-
started = false;
|
|
14
|
-
closed = false;
|
|
15
|
-
restarting = false;
|
|
16
|
-
wasmExports;
|
|
17
|
-
constructor(cameraDevice, api) {
|
|
18
|
-
this.api = api;
|
|
19
|
-
this.cameraDevice = cameraDevice;
|
|
20
|
-
this.cameraLogger = cameraDevice.logger;
|
|
21
|
-
this.cameraStorage = this.createCameraStorage();
|
|
22
|
-
this.cameraDevice.onConnected.subscribe((connected) => {
|
|
23
|
-
if (connected) {
|
|
24
|
-
this.start();
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.close();
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async start() {
|
|
32
|
-
if (!this.started) {
|
|
33
|
-
this.started = true;
|
|
34
|
-
this.closed = false;
|
|
35
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Starting motion detection');
|
|
36
|
-
await this.initiateWASM();
|
|
37
|
-
await this.startDetection();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
close() {
|
|
41
|
-
if (this.started && !this.closed) {
|
|
42
|
-
this.started = false;
|
|
43
|
-
this.closed = true;
|
|
44
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Stopping motion detection');
|
|
45
|
-
// reset wasm?
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
async initiateWASM() {
|
|
49
|
-
if (this.wasmExports) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const wasmModule = await instantiate(readFileSync(resolve(__dirname, './wasm/build/detector.wasm')), {
|
|
53
|
-
console: {
|
|
54
|
-
log: (messagePtr) => {
|
|
55
|
-
console.log(this.wasmExports.__getString(messagePtr));
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
env: {
|
|
59
|
-
abort: (msgPtr, filePtr, line, column) => {
|
|
60
|
-
const msg = this.wasmExports.__getString(msgPtr);
|
|
61
|
-
const file = this.wasmExports.__getString(filePtr);
|
|
62
|
-
console.error(`Abort called at ${file}:${line}:${column}`, msg);
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
this.wasmExports = wasmModule.exports;
|
|
67
|
-
this.setupMemory();
|
|
68
|
-
}
|
|
69
|
-
setupMemory() {
|
|
70
|
-
if (!this.wasmExports) {
|
|
71
|
-
throw new Error('Wasm not initiated');
|
|
72
|
-
}
|
|
73
|
-
const [width, height] = this.cameraDevice.frameWorkerSettings.resolution.split('x').map((v) => parseInt(v, 10));
|
|
74
|
-
this.wasmExports.initialize(width, height);
|
|
75
|
-
}
|
|
76
|
-
async startDetection() {
|
|
77
|
-
try {
|
|
78
|
-
await this.detect();
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
this.cameraLogger.error(this.cameraDevice.name, 'Error generating frames', error);
|
|
82
|
-
await this.restart();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
async restart() {
|
|
86
|
-
if (this.restarting || this.closed) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
this.restarting = true;
|
|
90
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Restarting motion detection in 2s...');
|
|
91
|
-
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
92
|
-
this.restarting = false;
|
|
93
|
-
if (this.cameraDevice.connected && !this.closed) {
|
|
94
|
-
await this.startDetection();
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Camera not connected, not restarting');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async detect() {
|
|
101
|
-
if (!this.wasmExports) {
|
|
102
|
-
throw new Error('Wasm not initiated');
|
|
103
|
-
}
|
|
104
|
-
const { detectMotion, getNumBoxes, __newArray, __getInt32Array, __pin, __unpin, __collect, Uint8Array_ID } = this.wasmExports;
|
|
105
|
-
for await (const frame of this.cameraDevice.getFrames()) {
|
|
106
|
-
if (this.closed || this.restarting) {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
const motionArea = this.cameraStorage.values.area;
|
|
110
|
-
const threshold = this.cameraStorage.values.threshold;
|
|
111
|
-
const blurRadius = this.cameraStorage.values.blurRadius;
|
|
112
|
-
const dilationSize = this.cameraStorage.values.dilationSize;
|
|
113
|
-
const frameImage = await frame.toBuffer({
|
|
114
|
-
format: {
|
|
115
|
-
to: 'gray',
|
|
116
|
-
},
|
|
117
|
-
resize: {
|
|
118
|
-
width: 640,
|
|
119
|
-
height: 0,
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
if (this.closed || this.restarting) {
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
const inputPtr = __pin(__newArray(Uint8Array_ID.value, frameImage.image));
|
|
126
|
-
const resultPtr = detectMotion(inputPtr, threshold, blurRadius, dilationSize, motionArea);
|
|
127
|
-
const numBoxes = getNumBoxes();
|
|
128
|
-
const boxesArray = __getInt32Array(resultPtr);
|
|
129
|
-
const detections = [];
|
|
130
|
-
for (let i = 0; i < numBoxes; i++) {
|
|
131
|
-
const x = boxesArray[i * 4];
|
|
132
|
-
const y = boxesArray[i * 4 + 1];
|
|
133
|
-
const w = boxesArray[i * 4 + 2];
|
|
134
|
-
const h = boxesArray[i * 4 + 3];
|
|
135
|
-
detections.push({
|
|
136
|
-
label: 'motion',
|
|
137
|
-
confidence: 1,
|
|
138
|
-
boundingBox: [x, y, x + w, y + h],
|
|
139
|
-
inputWidth: frameImage.info.width,
|
|
140
|
-
inputHeight: frameImage.info.height,
|
|
141
|
-
origWidth: frame.metadata.origWidth,
|
|
142
|
-
origHeight: frame.metadata.origHeight,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
__unpin(inputPtr);
|
|
146
|
-
__collect();
|
|
147
|
-
await this.cameraDevice.updateState('motion', { detections: detections }, frame);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
defaultSettings() {
|
|
151
|
-
if (this.cameraStorage.values.area !== DEFAULT_MOTION_AREA) {
|
|
152
|
-
this.cameraStorage.setValue('area', DEFAULT_MOTION_AREA);
|
|
153
|
-
}
|
|
154
|
-
if (this.cameraStorage.values.threshold !== DEFAULT_THRESHOLD) {
|
|
155
|
-
this.cameraStorage.setValue('threshold', DEFAULT_THRESHOLD);
|
|
156
|
-
}
|
|
157
|
-
if (this.cameraStorage.values.blurRadius !== DEFAULT_BLUR_RADIUS) {
|
|
158
|
-
this.cameraStorage.setValue('blurRadius', DEFAULT_BLUR_RADIUS);
|
|
159
|
-
}
|
|
160
|
-
if (this.cameraStorage.values.dilationSize !== DEFAULT_DILATION_SIZE) {
|
|
161
|
-
this.cameraStorage.setValue('dilationSize', DEFAULT_DILATION_SIZE);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
createCameraStorage() {
|
|
165
|
-
const cameraStorage = this.api.storageController.createCameraStorage(this, this.cameraDevice.id, {
|
|
166
|
-
area: {
|
|
167
|
-
type: 'number',
|
|
168
|
-
key: 'area',
|
|
169
|
-
title: 'Area',
|
|
170
|
-
description: 'Minimum area for a motion detection',
|
|
171
|
-
store: true,
|
|
172
|
-
defaultValue: DEFAULT_MOTION_AREA,
|
|
173
|
-
minimum: 10,
|
|
174
|
-
maximum: 1000,
|
|
175
|
-
step: 1,
|
|
176
|
-
required: true,
|
|
177
|
-
onSet: async (newValue, oldValue) => {
|
|
178
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion area changed from ${oldValue} to ${newValue}`);
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
threshold: {
|
|
182
|
-
type: 'number',
|
|
183
|
-
key: 'threshold',
|
|
184
|
-
title: 'Threshold',
|
|
185
|
-
description: 'Threshold for motion detection',
|
|
186
|
-
store: true,
|
|
187
|
-
defaultValue: DEFAULT_THRESHOLD,
|
|
188
|
-
minimum: 1,
|
|
189
|
-
maximum: 255,
|
|
190
|
-
step: 1,
|
|
191
|
-
required: true,
|
|
192
|
-
onSet: async (newValue, oldValue) => {
|
|
193
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion threshold changed from ${oldValue} to ${newValue}`);
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
blurRadius: {
|
|
197
|
-
type: 'number',
|
|
198
|
-
key: 'blurRadius',
|
|
199
|
-
title: 'Blur Radius',
|
|
200
|
-
description: 'Blur radius for motion detection',
|
|
201
|
-
store: true,
|
|
202
|
-
defaultValue: DEFAULT_BLUR_RADIUS,
|
|
203
|
-
minimum: 1,
|
|
204
|
-
maximum: 21,
|
|
205
|
-
step: 1,
|
|
206
|
-
required: true,
|
|
207
|
-
onSet: async (newValue, oldValue) => {
|
|
208
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion blur radius changed from ${oldValue} to ${newValue}`);
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
dilationSize: {
|
|
212
|
-
type: 'number',
|
|
213
|
-
key: 'dilationSize',
|
|
214
|
-
title: 'Dilation Size',
|
|
215
|
-
description: 'Dilation size for motion detection',
|
|
216
|
-
store: true,
|
|
217
|
-
defaultValue: DEFAULT_DILATION_SIZE,
|
|
218
|
-
minimum: 1,
|
|
219
|
-
maximum: 21,
|
|
220
|
-
step: 1,
|
|
221
|
-
required: true,
|
|
222
|
-
onSet: async (newValue, oldValue) => {
|
|
223
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion dilation size changed from ${oldValue} to ${newValue}`);
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
reset: {
|
|
227
|
-
type: 'button',
|
|
228
|
-
title: 'Default Settings',
|
|
229
|
-
key: 'default',
|
|
230
|
-
description: 'Reset motion detection settings to default',
|
|
231
|
-
onSet: async () => {
|
|
232
|
-
this.defaultSettings();
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
return cameraStorage;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
//# sourceMappingURL=detector.js.map
|
package/dist/detector.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMnH,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAItC,MAAM,OAAO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YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,qCAAqC,QAAQ,OAAO,QAAQ,EAAE,CAAC,CAAC;gBAChH,CAAC;aACF;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,kBAAkB;gBACzB,GAAG,EAAE,SAAS;gBACd,WAAW,EAAE,4CAA4C;gBACzD,KAAK,EAAE,KAAK,IAAI,EAAE;oBAChB,IAAI,CAAC,eAAe,EAAE,CAAC;gBACzB,CAAC;aACF;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { BasePlugin, CameraDevice, FormSubmitResponse, LoggerService, PluginAPI } from '@camera.ui/types';
|
|
2
|
-
export default class WASMMotion implements BasePlugin {
|
|
3
|
-
logger: LoggerService;
|
|
4
|
-
api: PluginAPI;
|
|
5
|
-
private cameras;
|
|
6
|
-
private detectors;
|
|
7
|
-
constructor(logger: LoggerService, api: PluginAPI);
|
|
8
|
-
configureCameras(cameras: CameraDevice[]): void;
|
|
9
|
-
onFormSubmit(actionId: string, payload: any): Promise<FormSubmitResponse | void>;
|
|
10
|
-
private start;
|
|
11
|
-
private stop;
|
|
12
|
-
private cameraSelected;
|
|
13
|
-
private cameraDeselected;
|
|
14
|
-
private createDetector;
|
|
15
|
-
private removeDetector;
|
|
16
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { CameraDetector } from './detector.js';
|
|
2
|
-
export default class WASMMotion {
|
|
3
|
-
logger;
|
|
4
|
-
api;
|
|
5
|
-
cameras = new Map();
|
|
6
|
-
detectors = new Map();
|
|
7
|
-
constructor(logger, api) {
|
|
8
|
-
this.api = api;
|
|
9
|
-
this.logger = logger;
|
|
10
|
-
this.api.on('finishLaunching', this.start.bind(this));
|
|
11
|
-
this.api.on('shutdown', this.stop.bind(this));
|
|
12
|
-
this.api.deviceManager.on('cameraSelected', this.cameraSelected.bind(this));
|
|
13
|
-
this.api.deviceManager.on('cameraDeselected', this.cameraDeselected.bind(this));
|
|
14
|
-
}
|
|
15
|
-
configureCameras(cameras) {
|
|
16
|
-
for (const camera of cameras) {
|
|
17
|
-
this.cameras.set(camera.id, camera);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
21
|
-
async onFormSubmit(actionId, payload) { }
|
|
22
|
-
async start() {
|
|
23
|
-
this.logger.log('Plugin started');
|
|
24
|
-
for (const camera of this.cameras) {
|
|
25
|
-
this.createDetector(camera[1]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
stop() {
|
|
29
|
-
this.logger.log('Plugin stopped');
|
|
30
|
-
for (const detector of this.detectors.values()) {
|
|
31
|
-
detector.close();
|
|
32
|
-
}
|
|
33
|
-
this.detectors.clear();
|
|
34
|
-
}
|
|
35
|
-
cameraSelected(camera, extension) {
|
|
36
|
-
this.logger.log(`Camera added (${extension}): ${camera.name}`);
|
|
37
|
-
this.cameras.set(camera.id, camera);
|
|
38
|
-
this.createDetector(camera);
|
|
39
|
-
}
|
|
40
|
-
cameraDeselected(cameraId, extension) {
|
|
41
|
-
const camera = this.cameras.get(cameraId);
|
|
42
|
-
if (camera) {
|
|
43
|
-
this.logger.log(`Camera removed (${extension}): ${camera.name}`);
|
|
44
|
-
this.removeDetector(cameraId);
|
|
45
|
-
this.cameras.delete(cameraId);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
createDetector(cameraDevice) {
|
|
49
|
-
const detector = new CameraDetector(cameraDevice, this.api);
|
|
50
|
-
this.detectors.set(cameraDevice.id, detector);
|
|
51
|
-
}
|
|
52
|
-
removeDetector(cameraId) {
|
|
53
|
-
const detector = this.detectors.get(cameraId);
|
|
54
|
-
if (detector) {
|
|
55
|
-
detector.close();
|
|
56
|
-
this.detectors.delete(cameraId);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,CAAC,OAAO,OAAO,UAAU;IACtB,MAAM,CAAgB;IACtB,GAAG,CAAY;IAEd,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEtD,YAAY,MAAqB,EAAE,GAAc;QAC/C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9C,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,gBAAgB,CAAC,OAAuB;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,6DAA6D;IACtD,KA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c,CAAC,YAA0B;QAC/C,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEO,cAAc,CAAC,QAAgB;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
declare namespace __AdaptedExports {
|
|
2
|
-
/** Exported memory */
|
|
3
|
-
export const memory: WebAssembly.Memory;
|
|
4
|
-
// Exported runtime interface
|
|
5
|
-
export function __new(size: number, id: number): number;
|
|
6
|
-
export function __pin(ptr: number): number;
|
|
7
|
-
export function __unpin(ptr: number): void;
|
|
8
|
-
export function __collect(): void;
|
|
9
|
-
export const __rtti_base: number;
|
|
10
|
-
/**
|
|
11
|
-
* assembly/console/log
|
|
12
|
-
* @param s `~lib/string/String`
|
|
13
|
-
*/
|
|
14
|
-
export function log(s: string): void;
|
|
15
|
-
/**
|
|
16
|
-
* assembly/index/initialize
|
|
17
|
-
* @param w `i32`
|
|
18
|
-
* @param h `i32`
|
|
19
|
-
*/
|
|
20
|
-
export function initialize(w: number, h: number): void;
|
|
21
|
-
/**
|
|
22
|
-
* assembly/index/detectMotion
|
|
23
|
-
* @param inputFrame `~lib/typedarray/Uint8Array`
|
|
24
|
-
* @param threshold `i32`
|
|
25
|
-
* @param radius `i32`
|
|
26
|
-
* @param dilationSize `i32`
|
|
27
|
-
* @param minArea `i32`
|
|
28
|
-
* @returns `~lib/typedarray/Int32Array`
|
|
29
|
-
*/
|
|
30
|
-
export function detectMotion(inputFrame: Uint8Array, threshold: number, radius: number, dilationSize: number, minArea: number): Int32Array;
|
|
31
|
-
/**
|
|
32
|
-
* assembly/index/getNumBoxes
|
|
33
|
-
* @returns `i32`
|
|
34
|
-
*/
|
|
35
|
-
export function getNumBoxes(): number;
|
|
36
|
-
/** assembly/index/Uint8Array_ID */
|
|
37
|
-
export const Uint8Array_ID: {
|
|
38
|
-
/** @type `u32` */
|
|
39
|
-
get value(): number
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* assembly/test/blurFrameSIMD
|
|
43
|
-
* @param framePtr `usize`
|
|
44
|
-
* @param tempFramePtr `usize`
|
|
45
|
-
* @param width `i32`
|
|
46
|
-
* @param height `i32`
|
|
47
|
-
* @param radius `i32`
|
|
48
|
-
*/
|
|
49
|
-
export function blurFrameSIMD(framePtr: number, tempFramePtr: number, width: number, height: number, radius: number): void;
|
|
50
|
-
/**
|
|
51
|
-
* assembly/test/detectMotionSIMD
|
|
52
|
-
* @param prevFramePtr `usize`
|
|
53
|
-
* @param currentFramePtr `usize`
|
|
54
|
-
* @param width `i32`
|
|
55
|
-
* @param height `i32`
|
|
56
|
-
* @param threshold `i32`
|
|
57
|
-
* @param motionMaskPtr `usize`
|
|
58
|
-
*/
|
|
59
|
-
export function detectMotionSIMD(prevFramePtr: number, currentFramePtr: number, width: number, height: number, threshold: number, motionMaskPtr: number): void;
|
|
60
|
-
/**
|
|
61
|
-
* assembly/test/dilateMotionMask
|
|
62
|
-
* @param motionMaskPtr `usize`
|
|
63
|
-
* @param tempMaskPtr `usize`
|
|
64
|
-
* @param width `i32`
|
|
65
|
-
* @param height `i32`
|
|
66
|
-
* @param dilationSize `i32`
|
|
67
|
-
*/
|
|
68
|
-
export function dilateMotionMask(motionMaskPtr: number, tempMaskPtr: number, width: number, height: number, dilationSize: number): void;
|
|
69
|
-
/**
|
|
70
|
-
* assembly/test/calculateBoundingBoxes
|
|
71
|
-
* @param motionMaskPtr `usize`
|
|
72
|
-
* @param visitedPtr `usize`
|
|
73
|
-
* @param width `i32`
|
|
74
|
-
* @param height `i32`
|
|
75
|
-
* @param motionArea `i32`
|
|
76
|
-
* @param boundingBoxesPtr `usize`
|
|
77
|
-
* @param stackXPtr `usize`
|
|
78
|
-
* @param stackYPtr `usize`
|
|
79
|
-
* @returns `i32`
|
|
80
|
-
*/
|
|
81
|
-
export function calculateBoundingBoxes(motionMaskPtr: number, visitedPtr: number, width: number, height: number, motionArea: number, boundingBoxesPtr: number, stackXPtr: number, stackYPtr: number): number;
|
|
82
|
-
/**
|
|
83
|
-
* assembly/test/calculateBoundingBoxesSIMD
|
|
84
|
-
* @param motionMaskPtr `usize`
|
|
85
|
-
* @param visitedPtr `usize`
|
|
86
|
-
* @param width `i32`
|
|
87
|
-
* @param height `i32`
|
|
88
|
-
* @param motionArea `i32`
|
|
89
|
-
* @param boundingBoxesPtr `usize`
|
|
90
|
-
* @param stackXPtr `usize`
|
|
91
|
-
* @param stackYPtr `usize`
|
|
92
|
-
* @returns `i32`
|
|
93
|
-
*/
|
|
94
|
-
export function calculateBoundingBoxesSIMD(motionMaskPtr: number, visitedPtr: number, width: number, height: number, motionArea: number, boundingBoxesPtr: number, stackXPtr: number, stackYPtr: number): number;
|
|
95
|
-
/**
|
|
96
|
-
* assembly/test2/detectMotion
|
|
97
|
-
* @param prevFramePtr `usize`
|
|
98
|
-
* @param curFramePtr `usize`
|
|
99
|
-
* @param blurFrame1Ptr `usize`
|
|
100
|
-
* @param blurFrame2Ptr `usize`
|
|
101
|
-
* @param motionMaskPtr `usize`
|
|
102
|
-
* @param dilateMaskPtr `usize`
|
|
103
|
-
* @param boundingBoxesPtr `usize`
|
|
104
|
-
* @param width `i32`
|
|
105
|
-
* @param height `i32`
|
|
106
|
-
* @param blurRadius `i32`
|
|
107
|
-
* @param threshold `i32`
|
|
108
|
-
* @param dilationSize `i32`
|
|
109
|
-
* @param motionArea `i32`
|
|
110
|
-
* @returns `i32`
|
|
111
|
-
*/
|
|
112
|
-
export function detectMotion(prevFramePtr: number, curFramePtr: number, blurFrame1Ptr: number, blurFrame2Ptr: number, motionMaskPtr: number, dilateMaskPtr: number, boundingBoxesPtr: number, width: number, height: number, blurRadius: number, threshold: number, dilationSize: number, motionArea: number): number;
|
|
113
|
-
/**
|
|
114
|
-
* assembly/test3/blurFrame
|
|
115
|
-
* @param framePtr `usize`
|
|
116
|
-
* @param blurPtr `usize`
|
|
117
|
-
* @param width `i32`
|
|
118
|
-
* @param height `i32`
|
|
119
|
-
* @param radius `i32`
|
|
120
|
-
*/
|
|
121
|
-
export function blurFrame(framePtr: number, blurPtr: number, width: number, height: number, radius: number): void;
|
|
122
|
-
/**
|
|
123
|
-
* assembly/test3/detectMotion
|
|
124
|
-
* @param frame1Ptr `usize`
|
|
125
|
-
* @param frame2Ptr `usize`
|
|
126
|
-
* @param blurredFrame1Ptr `usize`
|
|
127
|
-
* @param blurredFrame2Ptr `usize`
|
|
128
|
-
* @param maskPtr `usize`
|
|
129
|
-
* @param dilatePtr `usize`
|
|
130
|
-
* @param visitedPtr `usize`
|
|
131
|
-
* @param queuePtr `usize`
|
|
132
|
-
* @param boxesPtr `usize`
|
|
133
|
-
* @param width `i32`
|
|
134
|
-
* @param height `i32`
|
|
135
|
-
* @param blurRadius `i32`
|
|
136
|
-
* @param dilationSize `i32`
|
|
137
|
-
* @param motionThreshold `i32`
|
|
138
|
-
* @param motionArea `i32`
|
|
139
|
-
* @returns `i32`
|
|
140
|
-
*/
|
|
141
|
-
export function detectMotion(frame1Ptr: number, frame2Ptr: number, blurredFrame1Ptr: number, blurredFrame2Ptr: number, maskPtr: number, dilatePtr: number, visitedPtr: number, queuePtr: number, boxesPtr: number, width: number, height: number, blurRadius: number, dilationSize: number, motionThreshold: number, motionArea: number): number;
|
|
142
|
-
}
|
|
143
|
-
/** Instantiates the compiled WebAssembly module with the given imports. */
|
|
144
|
-
export declare function instantiate(module: WebAssembly.Module, imports: {
|
|
145
|
-
console: unknown,
|
|
146
|
-
env: unknown,
|
|
147
|
-
}): Promise<typeof __AdaptedExports>;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
export async function instantiate(module, imports = {}) {
|
|
2
|
-
const __module0 = imports.console;
|
|
3
|
-
const adaptedImports = {
|
|
4
|
-
console: Object.assign(Object.create(__module0), {
|
|
5
|
-
log(s) {
|
|
6
|
-
// assembly/console/log(~lib/string/String) => void
|
|
7
|
-
s = __liftString(s >>> 0);
|
|
8
|
-
__module0.log(s);
|
|
9
|
-
},
|
|
10
|
-
}),
|
|
11
|
-
env: Object.assign(Object.create(globalThis), imports.env || {}, {
|
|
12
|
-
abort(message, fileName, lineNumber, columnNumber) {
|
|
13
|
-
// ~lib/builtins/abort(~lib/string/String | null?, ~lib/string/String | null?, u32?, u32?) => void
|
|
14
|
-
message = __liftString(message >>> 0);
|
|
15
|
-
fileName = __liftString(fileName >>> 0);
|
|
16
|
-
lineNumber = lineNumber >>> 0;
|
|
17
|
-
columnNumber = columnNumber >>> 0;
|
|
18
|
-
(() => {
|
|
19
|
-
// @external.js
|
|
20
|
-
throw Error(`${message} in ${fileName}:${lineNumber}:${columnNumber}`);
|
|
21
|
-
})();
|
|
22
|
-
},
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
const { exports } = await WebAssembly.instantiate(module, adaptedImports);
|
|
26
|
-
const memory = exports.memory || imports.env.memory;
|
|
27
|
-
const adaptedExports = Object.setPrototypeOf({
|
|
28
|
-
log(s) {
|
|
29
|
-
// assembly/console/log(~lib/string/String) => void
|
|
30
|
-
s = __lowerString(s) || __notnull();
|
|
31
|
-
exports.log(s);
|
|
32
|
-
},
|
|
33
|
-
detectMotion(inputFrame, threshold, radius, dilationSize, minArea) {
|
|
34
|
-
// assembly/index/detectMotion(~lib/typedarray/Uint8Array, i32, i32, i32, i32) => ~lib/typedarray/Int32Array
|
|
35
|
-
inputFrame = __lowerTypedArray(Uint8Array, 4, 0, inputFrame) || __notnull();
|
|
36
|
-
return __liftTypedArray(Int32Array, exports.detectMotion(inputFrame, threshold, radius, dilationSize, minArea) >>> 0);
|
|
37
|
-
},
|
|
38
|
-
Uint8Array_ID: {
|
|
39
|
-
// assembly/index/Uint8Array_ID: u32
|
|
40
|
-
valueOf() { return this.value; },
|
|
41
|
-
get value() {
|
|
42
|
-
return exports.Uint8Array_ID.value >>> 0;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
}, exports);
|
|
46
|
-
function __liftString(pointer) {
|
|
47
|
-
if (!pointer) return null;
|
|
48
|
-
const
|
|
49
|
-
end = pointer + new Uint32Array(memory.buffer)[pointer - 4 >>> 2] >>> 1,
|
|
50
|
-
memoryU16 = new Uint16Array(memory.buffer);
|
|
51
|
-
let
|
|
52
|
-
start = pointer >>> 1,
|
|
53
|
-
string = "";
|
|
54
|
-
while (end - start > 1024) string += String.fromCharCode(...memoryU16.subarray(start, start += 1024));
|
|
55
|
-
return string + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
56
|
-
}
|
|
57
|
-
function __lowerString(value) {
|
|
58
|
-
if (value == null) return 0;
|
|
59
|
-
const
|
|
60
|
-
length = value.length,
|
|
61
|
-
pointer = exports.__new(length << 1, 2) >>> 0,
|
|
62
|
-
memoryU16 = new Uint16Array(memory.buffer);
|
|
63
|
-
for (let i = 0; i < length; ++i) memoryU16[(pointer >>> 1) + i] = value.charCodeAt(i);
|
|
64
|
-
return pointer;
|
|
65
|
-
}
|
|
66
|
-
function __liftTypedArray(constructor, pointer) {
|
|
67
|
-
if (!pointer) return null;
|
|
68
|
-
return new constructor(
|
|
69
|
-
memory.buffer,
|
|
70
|
-
__getU32(pointer + 4),
|
|
71
|
-
__dataview.getUint32(pointer + 8, true) / constructor.BYTES_PER_ELEMENT
|
|
72
|
-
).slice();
|
|
73
|
-
}
|
|
74
|
-
function __lowerTypedArray(constructor, id, align, values) {
|
|
75
|
-
if (values == null) return 0;
|
|
76
|
-
const
|
|
77
|
-
length = values.length,
|
|
78
|
-
buffer = exports.__pin(exports.__new(length << align, 1)) >>> 0,
|
|
79
|
-
header = exports.__new(12, id) >>> 0;
|
|
80
|
-
__setU32(header + 0, buffer);
|
|
81
|
-
__dataview.setUint32(header + 4, buffer, true);
|
|
82
|
-
__dataview.setUint32(header + 8, length << align, true);
|
|
83
|
-
new constructor(memory.buffer, buffer, length).set(values);
|
|
84
|
-
exports.__unpin(buffer);
|
|
85
|
-
return header;
|
|
86
|
-
}
|
|
87
|
-
function __notnull() {
|
|
88
|
-
throw TypeError("value must not be null");
|
|
89
|
-
}
|
|
90
|
-
let __dataview = new DataView(memory.buffer);
|
|
91
|
-
function __setU32(pointer, value) {
|
|
92
|
-
try {
|
|
93
|
-
__dataview.setUint32(pointer, value, true);
|
|
94
|
-
} catch {
|
|
95
|
-
__dataview = new DataView(memory.buffer);
|
|
96
|
-
__dataview.setUint32(pointer, value, true);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function __getU32(pointer) {
|
|
100
|
-
try {
|
|
101
|
-
return __dataview.getUint32(pointer, true);
|
|
102
|
-
} catch {
|
|
103
|
-
__dataview = new DataView(memory.buffer);
|
|
104
|
-
return __dataview.getUint32(pointer, true);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return adaptedExports;
|
|
108
|
-
}
|
|
Binary file
|