diff --git a/plugins/objectdetector/package-lock.json b/plugins/objectdetector/package-lock.json index 3dad1b14d..1a5332540 100644 --- a/plugins/objectdetector/package-lock.json +++ b/plugins/objectdetector/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/objectdetector", - "version": "0.1.75", + "version": "0.1.76", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/objectdetector", - "version": "0.1.75", + "version": "0.1.76", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/objectdetector/package.json b/plugins/objectdetector/package.json index 1ef77e326..3a1cf1289 100644 --- a/plugins/objectdetector/package.json +++ b/plugins/objectdetector/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/objectdetector", - "version": "0.1.75", + "version": "0.1.76", "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/main.ts b/plugins/objectdetector/src/main.ts index 750473177..da141cbe1 100644 --- a/plugins/objectdetector/src/main.ts +++ b/plugins/objectdetector/src/main.ts @@ -405,7 +405,9 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase clearInterval(interval)); - const currentDetections = new Map(); + const stationaryDetections = new Map(); + const filteredDetections = new Map(); + const movingDetections = new Map(); let lastReport = 0; updatePipelineStatus('waiting result'); @@ -477,21 +479,31 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase d.className !== 'motion').length; - const numOriginalDetections = originalDetections.filter(d => d.className !== 'motion').length; - if (numZonedDetections !== numOriginalDetections) - currentDetections.set('filtered', (currentDetections.get('filtered') || 0) + 1); + for (const d of originalDetections) { + if (!zonedDetections.includes(d)) { + filteredDetections.set(d.className, Math.max(filteredDetections.get(d.className) || 0, d.score)); + } + } for (const d of detected.detected.detections) { - currentDetections.set(d.className, Math.max(currentDetections.get(d.className) || 0, d.score)); + const set = d.movement?.moving ? movingDetections : stationaryDetections; + set.set(d.className, Math.max(set.get(d.className) || 0, d.score)); } if (now > lastReport + 10000) { - const found = [...currentDetections.entries()].map(([className, score]) => `${className} (${score})`); - if (!found.length) - found.push('[no detections]'); - this.console.log(`[${Math.round((now - start) / 100) / 10}s] Detected:`, ...found); - currentDetections.clear(); + const classScores = (set: Map) => { + const found = [...set.entries()].map(([className, score]) => `${className} (${score})`); + if (!found.length) + found.push('[no detections]'); + return found; + }; + + this.console.log(`[${Math.round((now - start) / 100) / 10}s] Detected (stationary):`, ...classScores(stationaryDetections)); + this.console.log(`[${Math.round((now - start) / 100) / 10}s] Detected (moving) :`, ...classScores(movingDetections)); + this.console.log(`[${Math.round((now - start) / 100) / 10}s] Detected (filtered) :`, ...classScores(filteredDetections)); + this.console.log(`[${Math.round((now - start) / 100) / 10}s] Zones : ${zones.length}`); + stationaryDetections.clear(); + movingDetections.clear(); lastReport = now; } }