Skip to content

Commit

Permalink
videonanalysis: add filtering options to smart motion sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Mar 23, 2024
1 parent c20c960 commit 70c4d62
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugins/objectdetector/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/objectdetector/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 18 additions & 0 deletions plugins/objectdetector/src/smart-motionsensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 70c4d62

Please sign in to comment.