@camera.ui/camera-ui-pamdiff 0.0.19 → 0.0.20

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 ADDED
Binary file
package/package.json CHANGED
@@ -1,45 +1,33 @@
1
1
  {
2
2
  "displayName": "Pam Diff",
3
3
  "name": "@camera.ui/camera-ui-pamdiff",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "description": "camera.ui pam diff plugin",
6
6
  "author": "seydx (https://github.com/seydx/camera.ui)",
7
7
  "main": "./dist/index.js",
8
- "type": "module",
8
+ "type": "commonjs",
9
9
  "scripts": {
10
10
  "build": "rimraf dist && tsc",
11
- "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern",
12
- "lint": "eslint --fix --ext .js,.ts .",
13
- "update": "updates --update ./",
11
+ "bundle": "npm run format && npm run lint && npm run build && cui bundle",
12
+ "format": "prettier --write \"src/\" --ignore-unknown --no-error-on-unmatched-pattern",
14
13
  "install-updates": "npm i --save",
15
- "prepublishOnly": "npm i --package-lock-only && npm run lint && npm run format && npm run build"
14
+ "lint": "eslint .",
15
+ "lint:fix": "eslint --fix .",
16
+ "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)}\"",
17
+ "publish:alpha": "cui publish --alpha",
18
+ "publish:beta": "cui publish --beta",
19
+ "publish:latest": "cui publish --latest",
20
+ "update": "updates --update ./"
16
21
  },
17
22
  "dependencies": {
18
- "pam-diff": "^1.2.1",
19
- "pipe2pam": "^0.7.1"
20
- },
21
- "devDependencies": {
22
- "@camera.ui/types": "^0.0.77",
23
- "@rushstack/eslint-patch": "^1.10.4",
24
- "@types/node": "^22.7.6",
25
- "@types/ws": "^8.5.12",
26
- "@typescript-eslint/eslint-plugin": "^8.10.0",
27
- "@typescript-eslint/parser": "^8.10.0",
28
- "concurrently": "^9.0.1",
29
- "eslint": "8.57.0",
30
- "eslint-config-prettier": "^9.1.0",
31
- "eslint-plugin-prettier": "^5.2.1",
32
- "prettier": "^3.3.3",
33
- "rimraf": "^6.0.1",
34
- "typescript": "^5.6.3",
35
- "updates": "^16.4.0"
23
+ "pam-diff": "^1.2.1"
36
24
  },
37
25
  "bugs": {
38
26
  "url": "https://github.com/seydx/camera.ui/issues"
39
27
  },
40
28
  "engines": {
41
- "camera.ui": ">=0.0.34-alpha.2",
42
- "node": ">=20.17.0"
29
+ "camera.ui": ">=0.0.34-alpha.4",
30
+ "node": ">=20.18.0"
43
31
  },
44
32
  "homepage": "https://github.com/seydx/camera.ui#readme",
45
33
  "keywords": [
@@ -59,6 +47,7 @@
59
47
  "dependencies": [],
60
48
  "options": {
61
49
  "extendedMotionDetection": true
62
- }
50
+ },
51
+ "bundled": true
63
52
  }
64
- }
53
+ }
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-pamdiff
package/dist/camera.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { CameraDevice, PluginAPI } from '@camera.ui/types';
2
- export declare class CameraVideoanalysis {
3
- private api;
4
- private cameraLogger;
5
- private cameraDevice;
6
- private cameraStorage;
7
- private killed;
8
- private videoanalysisSession?;
9
- constructor(api: PluginAPI, cameraDevice: CameraDevice);
10
- start(): Promise<void>;
11
- stop(kill?: boolean): void;
12
- private restart;
13
- private reset;
14
- private startVideoanalysis;
15
- private reconfigure;
16
- private defaultSettings;
17
- private createCameraStorage;
18
- }
package/dist/camera.js DELETED
@@ -1,219 +0,0 @@
1
- import PamDiff from 'pam-diff';
2
- import P2P from 'pipe2pam';
3
- import { PassThrough } from 'stream';
4
- import { DEFAULT_DIFFERENCE, DEFAULT_MODE, DEFAULT_PERCENTAGE } from './constants.js';
5
- const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
6
- export class CameraVideoanalysis {
7
- api;
8
- cameraLogger;
9
- cameraDevice;
10
- cameraStorage;
11
- killed = false;
12
- videoanalysisSession;
13
- constructor(api, cameraDevice) {
14
- this.api = api;
15
- this.cameraLogger = cameraDevice.logger;
16
- this.cameraDevice = cameraDevice;
17
- this.cameraStorage = this.createCameraStorage();
18
- this.cameraDevice.onConnected.subscribe(async (connected) => {
19
- if (connected) {
20
- this.start();
21
- }
22
- else {
23
- this.stop(true);
24
- }
25
- });
26
- }
27
- async start() {
28
- try {
29
- this.cameraLogger.log('Starting videoanalysis');
30
- this.videoanalysisSession = await this.startVideoanalysis();
31
- }
32
- catch (error) {
33
- this.cameraLogger.error('An error occured during starting videoanalysis!', error);
34
- this.restart();
35
- }
36
- }
37
- stop(kill) {
38
- this.killed = kill || false;
39
- if (this.videoanalysisSession) {
40
- this.cameraLogger.log('Stopping videoanalysis session');
41
- this.videoanalysisSession.kill();
42
- this.videoanalysisSession = undefined;
43
- }
44
- }
45
- async restart() {
46
- this.cameraLogger.log('Restarting videoanalysis...');
47
- this.stop();
48
- await sleep(5000);
49
- if (!this.killed) {
50
- await this.start();
51
- }
52
- }
53
- reset() {
54
- this.videoanalysisSession?.kill();
55
- this.videoanalysisSession = undefined;
56
- }
57
- async startVideoanalysis() {
58
- this.reset();
59
- let isActive = true;
60
- const blobs = [];
61
- const difference = await this.cameraStorage.getValue('difference');
62
- const percent = await this.cameraStorage.getValue('percentage');
63
- this.cameraLogger.debug('Videoanalysis configuration:', { difference, percent });
64
- const pt = new PassThrough();
65
- const p2p = new P2P();
66
- const pamDiff = new PamDiff({
67
- difference,
68
- percent,
69
- response: 'blobs',
70
- });
71
- pt.pipe(p2p).pipe(pamDiff);
72
- const kill = () => {
73
- isActive = false;
74
- pt.end();
75
- p2p.end();
76
- pamDiff.end();
77
- };
78
- pamDiff.on('diff', (data) => {
79
- for (const trigger of data.trigger) {
80
- if (trigger.blobs) {
81
- blobs.push(...trigger.blobs);
82
- }
83
- }
84
- });
85
- let zeroDetections = 0;
86
- const motionDetection = async () => {
87
- for await (const frame of this.cameraDevice.getFrames()) {
88
- if (!isActive || this.killed) {
89
- break;
90
- }
91
- const mode = this.cameraStorage.values.mode;
92
- const tuplType = mode === 'gray' ? 'GRAYSCALE' : 'RGB';
93
- const depth = mode === 'gray' ? 1 : 3;
94
- const { image, info } = await frame.toBuffer({ format: { to: mode }, resize: { width: 640, height: 0 } });
95
- const header = ['P7', `WIDTH ${info.width}`, `HEIGHT ${info.height}`, `DEPTH ${depth}`, 'MAXVAL 255', `TUPLTYPE ${tuplType}`, 'ENDHDR'].join('\n') + '\n';
96
- pt.write(Buffer.from(header));
97
- pt.write(image);
98
- await sleep(1);
99
- const detections = [];
100
- while (blobs.length > 1) {
101
- const blob = blobs.shift();
102
- if (blob) {
103
- detections.push({
104
- label: 'motion',
105
- confidence: 1,
106
- boundingBox: [blob.minX, blob.minY, blob.maxX, blob.maxY],
107
- inputWidth: info.width,
108
- inputHeight: info.height,
109
- origWidth: frame.metadata.width,
110
- origHeight: frame.metadata.height,
111
- });
112
- }
113
- }
114
- if (!detections.length) {
115
- zeroDetections++;
116
- }
117
- else {
118
- zeroDetections = 0;
119
- }
120
- if (zeroDetections > 10) {
121
- zeroDetections = 0;
122
- await this.cameraDevice.updateState('motion', { detections }, frame);
123
- }
124
- else if (!zeroDetections) {
125
- await this.cameraDevice.updateState('motion', { detections }, frame);
126
- }
127
- }
128
- };
129
- motionDetection().catch((error) => {
130
- this.cameraLogger.error('An error occured during motion detection!', error);
131
- kill();
132
- this.restart();
133
- });
134
- return {
135
- isActive() {
136
- return isActive;
137
- },
138
- kill,
139
- pamDiff,
140
- p2p,
141
- };
142
- }
143
- async reconfigure({ difference, percentage }) {
144
- this.cameraLogger.log('Reconfiguring videoanalysis...');
145
- if (this.videoanalysisSession) {
146
- this.cameraDevice.updateState('motion', { detections: [] }).catch();
147
- percentage = percentage || this.videoanalysisSession.pamDiff.percent;
148
- difference = difference || this.videoanalysisSession.pamDiff.difference;
149
- this.cameraLogger.log(`New configuration: ${percentage}% / ${difference}`);
150
- this.videoanalysisSession.pamDiff.setPercent(percentage);
151
- this.videoanalysisSession.pamDiff.setDifference(difference);
152
- }
153
- }
154
- defaultSettings() {
155
- if (this.cameraStorage.values.difference !== DEFAULT_DIFFERENCE) {
156
- this.cameraStorage.setValue('difference', DEFAULT_DIFFERENCE);
157
- }
158
- if (this.cameraStorage.values.percentage !== DEFAULT_PERCENTAGE) {
159
- this.cameraStorage.setValue('percentage', DEFAULT_PERCENTAGE);
160
- }
161
- if (this.cameraStorage.values.mode !== DEFAULT_MODE) {
162
- this.cameraStorage.setValue('mode', DEFAULT_MODE);
163
- }
164
- }
165
- createCameraStorage() {
166
- const cameraStorage = this.api.storageController.createCameraStorage(this, this.cameraDevice.id, {
167
- difference: {
168
- type: 'number',
169
- key: 'difference',
170
- title: 'Motion Difference',
171
- description: 'The color difference required to trigger motion on a pixel',
172
- defaultValue: DEFAULT_DIFFERENCE,
173
- minimum: 1,
174
- maximum: 255,
175
- store: true,
176
- onSet: async (newValue) => {
177
- this.reconfigure({ difference: newValue });
178
- },
179
- },
180
- percentage: {
181
- type: 'number',
182
- key: 'percentage',
183
- title: 'Motion Percent',
184
- description: 'The percentage of pixels required to trigger motion',
185
- defaultValue: DEFAULT_PERCENTAGE,
186
- minimum: 0,
187
- maximum: 100,
188
- store: true,
189
- onSet: async (newValue) => {
190
- this.reconfigure({ percentage: newValue });
191
- },
192
- },
193
- mode: {
194
- type: 'string',
195
- key: 'mode',
196
- title: 'Motion Mode',
197
- description: 'The color mode used for motion detection',
198
- defaultValue: DEFAULT_MODE,
199
- store: true,
200
- enum: ['gray', 'rgb'],
201
- required: true,
202
- onSet: async () => {
203
- this.restart();
204
- },
205
- },
206
- reset: {
207
- type: 'button',
208
- title: 'Default Settings',
209
- key: 'default',
210
- description: 'Reset motion detection settings to default',
211
- onSet: async () => {
212
- this.defaultSettings();
213
- },
214
- },
215
- });
216
- return cameraStorage;
217
- }
218
- }
219
- //# sourceMappingURL=camera.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"camera.js","sourceRoot":"","sources":["../src/camera.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAA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,EAAE,CAAC,CAAC;gBAC7C,CAAC;aACF;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,YAAY;gBACjB,KAAK,EAAE,gBAAgB;gBACvB,WAAW,EAAE,qDAAqD;gBAClE,YAAY,EAAE,kBAAkB;gBAChC,OAAO,EAAE,CAAC;gBACV,OAAO,EAAE,GAAG;gBACZ,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,KAAK,EAAE,QAAgB,EAAE,EAAE;oBAChC,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC7C,CAAC;aACF;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,GAAG,EAAE,MAAM;gBACX,KAAK,EAAE,aAAa;gBACpB,WAAW,EAAE,0CAA0C;gBACvD,YAAY,EAAE,YAAY;gBAC1B,KAAK,EAAE,IAAI;gBACX,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;gBACrB,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,KAAK,IAAI,EAAE;oBAChB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,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"}
@@ -1,3 +0,0 @@
1
- export declare const DEFAULT_PERCENTAGE = 2;
2
- export declare const DEFAULT_DIFFERENCE = 9;
3
- export declare const DEFAULT_MODE = "gray";
package/dist/constants.js DELETED
@@ -1,4 +0,0 @@
1
- export const DEFAULT_PERCENTAGE = 2;
2
- export const DEFAULT_DIFFERENCE = 9;
3
- export const DEFAULT_MODE = 'gray';
4
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC"}
package/dist/index.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { BasePlugin, CameraDevice, FormSubmitResponse, LoggerService, PluginAPI } from '@camera.ui/types';
2
- export default class PamDiff implements BasePlugin {
3
- private cameras;
4
- private analyzedCameras;
5
- logger: LoggerService;
6
- api: PluginAPI;
7
- constructor(log: 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 configureCamera;
13
- private removeCamera;
14
- }
package/dist/index.js DELETED
@@ -1,51 +0,0 @@
1
- import { CameraVideoanalysis } from './camera.js';
2
- export default class PamDiff {
3
- cameras = new Map();
4
- analyzedCameras = new Map();
5
- logger;
6
- api;
7
- constructor(log, api) {
8
- this.logger = log;
9
- this.api = api;
10
- this.api.on('finishLaunching', this.start.bind(this));
11
- this.api.on('shutdown', this.stop.bind(this));
12
- }
13
- configureCameras(cameras) {
14
- for (const camera of cameras) {
15
- this.configureCamera(camera);
16
- }
17
- }
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- async onFormSubmit(actionId, payload) { }
20
- async start() {
21
- this.api.deviceManager.on('cameraSelected', (cameraDevice) => {
22
- this.configureCamera(cameraDevice);
23
- });
24
- this.api.deviceManager.on('cameraDeselected', async (cameraId) => {
25
- await this.removeCamera(cameraId);
26
- });
27
- }
28
- stop() {
29
- for (const [cameraId, analyzedCamera] of this.analyzedCameras) {
30
- analyzedCamera.stop();
31
- this.analyzedCameras.delete(cameraId);
32
- }
33
- }
34
- configureCamera(cameraDevice) {
35
- this.logger.log('Configuring Camera:', cameraDevice.name);
36
- const cameraPrebuffer = new CameraVideoanalysis(this.api, cameraDevice);
37
- this.cameras.set(cameraDevice.id, cameraDevice);
38
- this.analyzedCameras.set(cameraDevice.id, cameraPrebuffer);
39
- }
40
- async removeCamera(cameraId) {
41
- const cameraDevice = this.cameras.get(cameraId);
42
- if (cameraDevice) {
43
- this.logger.log('Removing Camera:', cameraDevice.name);
44
- this.analyzedCameras.get(cameraId)?.stop(true);
45
- this.analyzedCameras.delete(cameraId);
46
- this.cameras.delete(cameraId);
47
- this.api.storageController.removeCameraStorage(cameraId);
48
- }
49
- }
50
- }
51
- //# 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,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIlD,MAAM,CAAC,OAAO,OAAO,OAAO;IAClB,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,eAAe,GAAG,IAAI,GAAG,EAA+B,CAAC;IAE1D,MAAM,CAAgB;IACtB,GAAG,CAAY;IAEtB,YAAY,GAAkB,EAAE,GAAc;QAC5C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,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;IAChD,CAAC;IAEM,gBAAgB,CAAC,OAAuB;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,eAAe,CAAC,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,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;YAEvD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF"}
package/dist/types.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import type PamDiff from 'pam-diff';
2
- import type P2P from 'pipe2pam';
3
- export interface VideoanalysisSession {
4
- isActive(): boolean;
5
- kill: (reason?: string) => void;
6
- pamDiff: PamDiff;
7
- p2p: P2P;
8
- }
9
- export interface CameraStorageValues {
10
- difference: number;
11
- percentage: number;
12
- mode: 'gray' | 'rgb';
13
- }
14
- export interface PamDiffRegion {
15
- name: string;
16
- difference?: number;
17
- percent?: number;
18
- polygon?: PamDiffCoords[];
19
- }
20
- export interface PamDiffCoords {
21
- x: number;
22
- y: number;
23
- }
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- export {};
2
- // Compare this snippet from /types/pam-diff.d.ts:
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AA4BA,kDAAkD"}