From 70c4d624663c04464d089a857690c5c2077b15d5 Mon Sep 17 00:00:00 2001 From: Koushik Dutta <koushd@gmail.com> Date: Fri, 22 Mar 2024 19:18:04 -0700 Subject: [PATCH] videonanalysis: add filtering options to smart motion sensor --- plugins/objectdetector/package-lock.json | 4 ++-- plugins/objectdetector/package.json | 2 +- .../objectdetector/src/smart-motionsensor.ts | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/objectdetector/package-lock.json b/plugins/objectdetector/package-lock.json index 685ece5e04..6a728f0624 100644 --- a/plugins/objectdetector/package-lock.json +++ b/plugins/objectdetector/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/objectdetector", - "version": "0.1.32", + "version": "0.1.33", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/objectdetector", - "version": "0.1.32", + "version": "0.1.33", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/objectdetector/package.json b/plugins/objectdetector/package.json index b07b48011b..ce1e9f20cc 100644 --- a/plugins/objectdetector/package.json +++ b/plugins/objectdetector/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/objectdetector", - "version": "0.1.32", + "version": "0.1.33", "description": "Scrypted Video Analysis Plugin. Installed alongside a detection service like OpenCV or TensorFlow.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/objectdetector/src/smart-motionsensor.ts b/plugins/objectdetector/src/smart-motionsensor.ts index 1d31f80398..5a31793b00 100644 --- a/plugins/objectdetector/src/smart-motionsensor.ts +++ b/plugins/objectdetector/src/smart-motionsensor.ts @@ -43,6 +43,18 @@ export class SmartMotionSensor extends ScryptedDeviceBase implements Settings, R type: 'number', defaultValue: 0.7, }, + requireDetectionThumbnail: { + title: 'Rquire Detections with Images', + description: 'When enabled, this sensor will ignore detections results that do not have images.', + type: 'boolean', + defaultValue: false, + }, + requireScryptedNvrDetections: { + title: 'Require Scrypted Detections', + description: 'When enabled, this sensor will ignore onboard camera detections.', + type: 'boolean', + defaultValue: false, + }, }); listener: EventListenerRegister; @@ -141,7 +153,13 @@ export class SmartMotionSensor extends ScryptedDeviceBase implements Settings, R this.listener = objectDetector.listen(ScryptedInterface.ObjectDetector, (source, details, data) => { const detected: ObjectsDetected = data; + + if (this.storageSettings.values.requireDetectionThumbnail && !detected.detectionId) + return false; + const match = detected.detections?.find(d => { + if (this.storageSettings.values.requireScryptedNvrDetections && !d.boundingBox) + return false; if (d.score && d.score < this.storageSettings.values.minScore) return false; if (!detections.includes(d.className))