Skip to content

Commit

Permalink
videoanalysis: improve logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Apr 7, 2023
1 parent 7d5defd commit 2383f16
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.0.122",
"version": "0.0.123",
"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/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera

const start = Date.now();
let detections = 0;
const currentDetections = new Set<string>();
let lastReport = 0;
try {
for await (const detected
of await this.objectDetection.generateObjectDetections(await generator(), {
Expand All @@ -348,6 +350,22 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase<VideoCamera & Camera
detections++;
// this.console.warn('dps', detections / (Date.now() - start) * 1000);

if (!this.hasMotionType) {
for (const d of detected.detected.detections) {
currentDetections.add(d.className);
}

const now = Date.now();
if (now > lastReport + 3000) {
const found = [...currentDetections.values()];
if (!found.length)
found.push('[no detections]');
this.console.log(`[${Math.round((now - start) / 100) / 10}s] Detected:`, ...found);
currentDetections.clear();
lastReport = now;
}
}

if (detected.detected.detectionId) {
const jpeg = await detected.videoFrame.toBuffer({
format: 'jpg',
Expand Down

0 comments on commit 2383f16

Please sign in to comment.