@camera.ui/camera-ui-rust-motion 0.0.16 → 0.0.18
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 +14 -27
- package/CHANGELOG.md +0 -8
- package/CONTRIBUTING.md +0 -1
- package/LICENSE.md +0 -22
- package/README.md +0 -1
- package/binary/rust_detector_freebsd/detector.node +0 -0
- package/binary/rust_detector_linux_arm64/detector.node +0 -0
- package/binary/rust_detector_linux_x64/detector.node +0 -0
- package/binary/rust_detector_macos/detector.node +0 -0
- package/binary/rust_detector_riscv64/detector.node +0 -0
- package/binary/rust_detector_windows_x64/detector.node +0 -0
- 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 -20
- package/dist/detector.js +0 -206
- 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 -18
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/addon.d.ts +0 -3
- package/dist/utils/addon.js +0 -59
- package/dist/utils/addon.js.map +0 -1
package/bundle.zip
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "RUST Motion",
|
|
3
3
|
"name": "@camera.ui/camera-ui-rust-motion",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.18",
|
|
5
5
|
"description": "camera.ui rust 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
10
|
"build": "rimraf dist && tsc",
|
|
11
11
|
"build:rust": "napi build --release",
|
|
@@ -18,39 +18,25 @@
|
|
|
18
18
|
"build:riscv64": "CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target riscv64gc-unknown-linux-gnu --release && npm run build:rust",
|
|
19
19
|
"build:freebsd": "cross-env RUSTFLAGS='-C target-feature=+avx2,+sse4.1' CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target x86_64-unknown-freebsd --release && npm run build:rust",
|
|
20
20
|
"build:linux-arm64": "cross-env RUSTFLAGS='-C target-feature=+neon' CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target aarch64-unknown-linux-gnu --release && npm run build:rust",
|
|
21
|
+
"bundle": "npm run format && npm run lint && npm run build && cui bundle",
|
|
21
22
|
"clean": "cargo clean && rimraf --glob *.node",
|
|
22
23
|
"clean:cargo": "cargo clean",
|
|
23
24
|
"format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern && cargo fmt",
|
|
24
25
|
"install-updates": "npm i --save",
|
|
25
|
-
"
|
|
26
|
-
"lint": "
|
|
26
|
+
"lint": "cargo clippy && eslint .",
|
|
27
|
+
"lint:fix": "cargo clippy --fix && eslint --fix .",
|
|
28
|
+
"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)}\"",
|
|
29
|
+
"publish:alpha": "cui publish --alpha",
|
|
30
|
+
"publish:beta": "cui publish --beta",
|
|
31
|
+
"publish:latest": "cui publish --latest",
|
|
27
32
|
"update": "updates --update ./"
|
|
28
33
|
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@camera.ui/types": "^0.0.77",
|
|
31
|
-
"@napi-rs/cli": "^2.18.4",
|
|
32
|
-
"@rushstack/eslint-patch": "^1.10.4",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
|
34
|
-
"@typescript-eslint/parser": "^8.10.0",
|
|
35
|
-
"concurrently": "^9.0.1",
|
|
36
|
-
"copyfiles": "^2.4.1",
|
|
37
|
-
"cross-env": "^7.0.3",
|
|
38
|
-
"eslint": "8.57.0",
|
|
39
|
-
"eslint-config-prettier": "^9.1.0",
|
|
40
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
41
|
-
"prettier": "^3.3.3",
|
|
42
|
-
"rimraf": "^6.0.1",
|
|
43
|
-
"set-interval-async": "^3.0.3",
|
|
44
|
-
"sharp": "^0.33.5",
|
|
45
|
-
"typescript": "^5.6.3",
|
|
46
|
-
"updates": "^16.4.0"
|
|
47
|
-
},
|
|
48
34
|
"bugs": {
|
|
49
35
|
"url": "https://github.com/seydx/camera.ui/issues"
|
|
50
36
|
},
|
|
51
37
|
"engines": {
|
|
52
|
-
"camera.ui": ">=0.0.34-alpha.
|
|
53
|
-
"node": ">=20.
|
|
38
|
+
"camera.ui": ">=0.0.34-alpha.4",
|
|
39
|
+
"node": ">=20.18.0"
|
|
54
40
|
},
|
|
55
41
|
"homepage": "https://github.com/seydx/camera.ui#readme",
|
|
56
42
|
"keywords": [
|
|
@@ -84,6 +70,7 @@
|
|
|
84
70
|
"dependencies": [],
|
|
85
71
|
"options": {
|
|
86
72
|
"extendedMotionDetection": true
|
|
87
|
-
}
|
|
73
|
+
},
|
|
74
|
+
"bundled": true
|
|
88
75
|
}
|
|
89
|
-
}
|
|
76
|
+
}
|
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-rust-motion
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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,20 +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 imageProcessor;
|
|
12
|
-
constructor(cameraDevice: CameraDevice, api: PluginAPI);
|
|
13
|
-
start(): Promise<void>;
|
|
14
|
-
close(): void;
|
|
15
|
-
private startDetection;
|
|
16
|
-
private restart;
|
|
17
|
-
private detect;
|
|
18
|
-
private defaultSettings;
|
|
19
|
-
private createCameraStorage;
|
|
20
|
-
}
|
package/dist/detector.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_BLUR_RADIUS, DEFAULT_DILATION_SIZE, DEFAULT_MOTION_AREA, DEFAULT_THRESHOLD } from './defaults.js';
|
|
2
|
-
import { getAddon } from './utils/addon.js';
|
|
3
|
-
import {} from './types.js';
|
|
4
|
-
const addon = getAddon();
|
|
5
|
-
export class CameraDetector {
|
|
6
|
-
cameraStorage;
|
|
7
|
-
api;
|
|
8
|
-
cameraDevice;
|
|
9
|
-
cameraLogger;
|
|
10
|
-
started = false;
|
|
11
|
-
closed = false;
|
|
12
|
-
restarting = false;
|
|
13
|
-
imageProcessor;
|
|
14
|
-
constructor(cameraDevice, api) {
|
|
15
|
-
this.api = api;
|
|
16
|
-
this.cameraDevice = cameraDevice;
|
|
17
|
-
this.cameraLogger = cameraDevice.logger;
|
|
18
|
-
this.cameraStorage = this.createCameraStorage();
|
|
19
|
-
if (!addon) {
|
|
20
|
-
this.cameraLogger.error(this.cameraDevice.name, `Failed to load motion detection addon! Platform: ${process.platform}, Arch: ${process.arch}`);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.imageProcessor = new addon.ImageProcessor();
|
|
24
|
-
this.cameraDevice.onConnected.subscribe((connected) => {
|
|
25
|
-
if (connected) {
|
|
26
|
-
this.start();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.close();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
async start() {
|
|
34
|
-
if (!this.started) {
|
|
35
|
-
this.started = true;
|
|
36
|
-
this.closed = false;
|
|
37
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Starting motion detection');
|
|
38
|
-
await this.startDetection();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
close() {
|
|
42
|
-
if (!this.closed) {
|
|
43
|
-
this.started = false;
|
|
44
|
-
this.closed = true;
|
|
45
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Stopping motion detection');
|
|
46
|
-
this.imageProcessor.resetState();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async startDetection() {
|
|
50
|
-
try {
|
|
51
|
-
await this.detect();
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
this.imageProcessor.resetState();
|
|
55
|
-
this.cameraLogger.error(this.cameraDevice.name, 'Error generating frames', error);
|
|
56
|
-
await this.restart();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async restart() {
|
|
60
|
-
if (this.restarting || this.closed) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
this.restarting = true;
|
|
64
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Restarting motion detection in 2s...');
|
|
65
|
-
this.imageProcessor.resetState();
|
|
66
|
-
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
67
|
-
this.restarting = false;
|
|
68
|
-
if (this.cameraDevice.connected && !this.closed) {
|
|
69
|
-
await this.startDetection();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.cameraLogger.log(this.cameraDevice.name, 'Camera is not connected, skipping restart');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async detect() {
|
|
76
|
-
for await (const frame of this.cameraDevice.getFrames()) {
|
|
77
|
-
if (this.closed || this.restarting) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
const motionArea = this.cameraStorage.values.area;
|
|
81
|
-
const threshold = this.cameraStorage.values.threshold;
|
|
82
|
-
const dilationSize = this.cameraStorage.values.dilationSize;
|
|
83
|
-
let blurRadius = this.cameraStorage.values.blurRadius;
|
|
84
|
-
if (blurRadius % 2 === 0) {
|
|
85
|
-
blurRadius += 1;
|
|
86
|
-
}
|
|
87
|
-
const frameImage = await frame.toBuffer({
|
|
88
|
-
format: {
|
|
89
|
-
to: 'gray',
|
|
90
|
-
},
|
|
91
|
-
resize: {
|
|
92
|
-
width: 640,
|
|
93
|
-
height: 0,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
if (this.closed || this.restarting) {
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
const detections = [];
|
|
100
|
-
const { width, height } = frameImage.info;
|
|
101
|
-
const boundingBoxes = this.imageProcessor.processImage(frameImage.image, width, height, threshold, blurRadius, dilationSize, motionArea);
|
|
102
|
-
for (const box of boundingBoxes) {
|
|
103
|
-
detections.push({
|
|
104
|
-
label: 'motion',
|
|
105
|
-
confidence: 1,
|
|
106
|
-
boundingBox: box,
|
|
107
|
-
inputWidth: frameImage.info.width,
|
|
108
|
-
inputHeight: frameImage.info.height,
|
|
109
|
-
origWidth: frame.metadata.origWidth,
|
|
110
|
-
origHeight: frame.metadata.origHeight,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
await this.cameraDevice.updateState('motion', { detections: detections }, frame);
|
|
114
|
-
}
|
|
115
|
-
this.imageProcessor.resetState();
|
|
116
|
-
}
|
|
117
|
-
defaultSettings() {
|
|
118
|
-
if (this.cameraStorage.values.area !== DEFAULT_MOTION_AREA) {
|
|
119
|
-
this.cameraStorage.setValue('area', DEFAULT_MOTION_AREA);
|
|
120
|
-
}
|
|
121
|
-
if (this.cameraStorage.values.threshold !== DEFAULT_THRESHOLD) {
|
|
122
|
-
this.cameraStorage.setValue('threshold', DEFAULT_THRESHOLD);
|
|
123
|
-
}
|
|
124
|
-
if (this.cameraStorage.values.blurRadius !== DEFAULT_BLUR_RADIUS) {
|
|
125
|
-
this.cameraStorage.setValue('blurRadius', DEFAULT_BLUR_RADIUS);
|
|
126
|
-
}
|
|
127
|
-
if (this.cameraStorage.values.dilationSize !== DEFAULT_DILATION_SIZE) {
|
|
128
|
-
this.cameraStorage.setValue('dilationSize', DEFAULT_DILATION_SIZE);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
createCameraStorage() {
|
|
132
|
-
const cameraStorage = this.api.storageController.createCameraStorage(this, this.cameraDevice.id, {
|
|
133
|
-
area: {
|
|
134
|
-
type: 'number',
|
|
135
|
-
key: 'area',
|
|
136
|
-
title: 'Area',
|
|
137
|
-
description: 'Minimum area for a motion detection',
|
|
138
|
-
store: true,
|
|
139
|
-
defaultValue: DEFAULT_MOTION_AREA,
|
|
140
|
-
minimum: 10,
|
|
141
|
-
maximum: 1000,
|
|
142
|
-
step: 1,
|
|
143
|
-
required: true,
|
|
144
|
-
onSet: async (newValue, oldValue) => {
|
|
145
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion area changed from ${oldValue} to ${newValue}`);
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
threshold: {
|
|
149
|
-
type: 'number',
|
|
150
|
-
key: 'threshold',
|
|
151
|
-
title: 'Threshold',
|
|
152
|
-
description: 'Threshold for motion detection',
|
|
153
|
-
store: true,
|
|
154
|
-
defaultValue: DEFAULT_THRESHOLD,
|
|
155
|
-
minimum: 1,
|
|
156
|
-
maximum: 255,
|
|
157
|
-
step: 1,
|
|
158
|
-
required: true,
|
|
159
|
-
onSet: async (newValue, oldValue) => {
|
|
160
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion threshold changed from ${oldValue} to ${newValue}`);
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
blurRadius: {
|
|
164
|
-
type: 'number',
|
|
165
|
-
key: 'blurRadius',
|
|
166
|
-
title: 'Blur Radius',
|
|
167
|
-
description: 'Blur radius for motion detection',
|
|
168
|
-
store: true,
|
|
169
|
-
defaultValue: DEFAULT_BLUR_RADIUS,
|
|
170
|
-
minimum: 1,
|
|
171
|
-
maximum: 21,
|
|
172
|
-
step: 1,
|
|
173
|
-
required: true,
|
|
174
|
-
onSet: async (newValue, oldValue) => {
|
|
175
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion blur radius changed from ${oldValue} to ${newValue}`);
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
dilationSize: {
|
|
179
|
-
type: 'number',
|
|
180
|
-
key: 'dilationSize',
|
|
181
|
-
title: 'Dilation Size',
|
|
182
|
-
description: 'Dilation size for motion detection',
|
|
183
|
-
store: true,
|
|
184
|
-
defaultValue: DEFAULT_DILATION_SIZE,
|
|
185
|
-
minimum: 1,
|
|
186
|
-
maximum: 31,
|
|
187
|
-
step: 1,
|
|
188
|
-
required: true,
|
|
189
|
-
onSet: async (newValue, oldValue) => {
|
|
190
|
-
this.cameraLogger.log(this.cameraDevice.name, `Motion dilation size changed from ${oldValue} to ${newValue}`);
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
reset: {
|
|
194
|
-
type: 'button',
|
|
195
|
-
title: 'Default Settings',
|
|
196
|
-
key: 'default',
|
|
197
|
-
description: 'Reset motion detection settings to default',
|
|
198
|
-
onSet: async () => {
|
|
199
|
-
this.defaultSettings();
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
return cameraStorage;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
//# 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,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAA4B,MAAM,YAAY,CAAC;AAEtD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,MAAM,OAAO,cAAc;IAClB,aAAa,CAAqC;IAEjD,GAAG,CAAY;IACf,YAAY,CAAe;IAC3B,YAAY,CAAgB;IAE5B,OAAO,GAAG,KAAK,CAAC;IAChB,MAAM,GAAG,KAAK,CAAC;IACf,UAAU,GAAG,KAAK,CAAC;IAEnB,cAAc,CAAkB;IAExC,YAAY,YAA0B,EAAE,GAAc;QACpD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC;QAExC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,oDAAoD,OAAO,CAAC,QAAQ,WAAW,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC/I,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QAEjD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,S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,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,KAAK,EAAE,QAAgB,EAAE,QAAgB,EAAE,EAAE;oBAClD,IAAI,CAAC,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 RUSTMotion 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 RUSTMotion {
|
|
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) {
|
|
36
|
-
this.logger.log(`Camera added: ${camera.name}`);
|
|
37
|
-
this.cameras.set(camera.id, camera);
|
|
38
|
-
this.createDetector(camera);
|
|
39
|
-
}
|
|
40
|
-
cameraDeselected(cameraId) {
|
|
41
|
-
const camera = this.cameras.get(cameraId);
|
|
42
|
-
if (camera) {
|
|
43
|
-
this.logger.log(`Camera removed: ${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,M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AChC,CAAC;IACH,CAAC;IAEO,cAAc,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
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BoundingBox } from '@camera.ui/types';
|
|
2
|
-
export interface CameraStorageValues {
|
|
3
|
-
area: number;
|
|
4
|
-
threshold: number;
|
|
5
|
-
blurRadius: number;
|
|
6
|
-
dilationSize: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class ImageProcessor {
|
|
9
|
-
previousBlurredImage?: Uint8Array;
|
|
10
|
-
constructor();
|
|
11
|
-
processImage(frame: Uint8Array, width: number, height: number, threshold: number, blurRadius: number, dilateSize: number, minArea: number): BoundingBox[];
|
|
12
|
-
resetState(): void;
|
|
13
|
-
}
|
|
14
|
-
export interface Addon {
|
|
15
|
-
ImageProcessor: {
|
|
16
|
-
new (): ImageProcessor;
|
|
17
|
-
};
|
|
18
|
-
}
|
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":""}
|
package/dist/utils/addon.d.ts
DELETED
package/dist/utils/addon.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = dirname(__filename);
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
|
-
const ADDON_NAME = 'rust_detector';
|
|
8
|
-
export const decoderPath = () => {
|
|
9
|
-
const platform = process.platform;
|
|
10
|
-
const arch = process.arch;
|
|
11
|
-
let targetDir;
|
|
12
|
-
switch (platform) {
|
|
13
|
-
case 'darwin':
|
|
14
|
-
targetDir = `${ADDON_NAME}_macos`;
|
|
15
|
-
break;
|
|
16
|
-
case 'win32':
|
|
17
|
-
if (arch === 'x64') {
|
|
18
|
-
targetDir = `${ADDON_NAME}_windows_x64`;
|
|
19
|
-
}
|
|
20
|
-
break;
|
|
21
|
-
case 'linux':
|
|
22
|
-
if (arch === 'x64') {
|
|
23
|
-
targetDir = `${ADDON_NAME}_linux_x64`;
|
|
24
|
-
}
|
|
25
|
-
else if (arch === 'arm64') {
|
|
26
|
-
targetDir = `${ADDON_NAME}_linux_arm64`;
|
|
27
|
-
}
|
|
28
|
-
else if (arch === 'riscv64') {
|
|
29
|
-
targetDir = `${ADDON_NAME}_linux_riscv64`;
|
|
30
|
-
}
|
|
31
|
-
break;
|
|
32
|
-
case 'freebsd':
|
|
33
|
-
if (arch === 'x64') {
|
|
34
|
-
targetDir = `${ADDON_NAME}_freebsd`;
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
if (!targetDir) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
return join(__dirname, '../../binary', targetDir, 'detector.node');
|
|
42
|
-
};
|
|
43
|
-
let addon;
|
|
44
|
-
export const getAddon = () => {
|
|
45
|
-
if (!addon) {
|
|
46
|
-
const addonPath = decoderPath();
|
|
47
|
-
if (!addonPath) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
addon = require(addonPath);
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
//
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return addon;
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=addon.js.map
|
package/dist/utils/addon.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/utils/addon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,UAAU,GAAG,eAAe,CAAC;AAEnC,MAAM,CAAC,MAAM,WAAW,GAAG,GAAuB,EAAE;IAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1B,IAAI,SAA6B,CAAC;IAElC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,SAAS,GAAG,GAAG,UAAU,QAAQ,CAAC;YAClC,MAAM;QACR,KAAK,OAAO;YACV,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,SAAS,GAAG,GAAG,UAAU,cAAc,CAAC;YAC1C,CAAC;YACD,MAAM;QACR,KAAK,OAAO;YACV,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;gBACnB,SAAS,GAAG,GAAG,UAAU,YAAY,CAAC;YACxC,CAAC;iBAAM,IAAI,IAAI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