diff --git a/plugins/objectdetector/package-lock.json b/plugins/objectdetector/package-lock.json index e8c6347cd..b9312a3c5 100644 --- a/plugins/objectdetector/package-lock.json +++ b/plugins/objectdetector/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/objectdetector", - "version": "0.0.138", + "version": "0.0.140", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/objectdetector", - "version": "0.0.138", + "version": "0.0.140", "license": "Apache-2.0", "dependencies": { "@scrypted/common": "file:../../common", diff --git a/plugins/objectdetector/package.json b/plugins/objectdetector/package.json index 87bc4f834..631e7dfaa 100644 --- a/plugins/objectdetector/package.json +++ b/plugins/objectdetector/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/objectdetector", - "version": "0.0.138", + "version": "0.0.140", "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/ffmpeg-videoframes-no-sharp.ts b/plugins/objectdetector/src/ffmpeg-videoframes-no-sharp.ts index 6d9ddb554..e3b71e54f 100644 --- a/plugins/objectdetector/src/ffmpeg-videoframes-no-sharp.ts +++ b/plugins/objectdetector/src/ffmpeg-videoframes-no-sharp.ts @@ -19,6 +19,7 @@ async function createRawImageMediaObject(image: RawImage): Promise image.toBuffer(options), toImage: (options: ImageOptions) => image.toImage(options), + close: () => image.close(), }); return ret; @@ -28,6 +29,10 @@ class RawImage implements Image, RawFrame { constructor(public data: Buffer, public width: number, public height: number, public format: ImageFormat) { } + async close(): Promise { + this.data = undefined; + } + checkOptions(options: ImageOptions) { if (options?.resize || options?.crop) throw new Error('resize and crop are not supported'); diff --git a/plugins/objectdetector/src/ffmpeg-videoframes.ts b/plugins/objectdetector/src/ffmpeg-videoframes.ts index cef001b45..d3e225914 100644 --- a/plugins/objectdetector/src/ffmpeg-videoframes.ts +++ b/plugins/objectdetector/src/ffmpeg-videoframes.ts @@ -37,6 +37,7 @@ async function createVipsMediaObject(image: VipsImage): Promise image.close(), }); return ret; @@ -52,6 +53,11 @@ class VipsImage implements Image { constructor(public image: sharp.Sharp, public width: number, public height: number, public channels: number) { } + async close(): Promise { + this.image?.destroy(); + this.image = undefined; + } + toImageInternal(options: ImageOptions) { const transformed = this.image.clone(); if (options?.crop) { diff --git a/plugins/objectdetector/src/main.ts b/plugins/objectdetector/src/main.ts index 378f9795f..ffd6e3f11 100644 --- a/plugins/objectdetector/src/main.ts +++ b/plugins/objectdetector/src/main.ts @@ -270,10 +270,13 @@ class ObjectDetectionMixin extends SettingsMixinDeviceBase { this.console.error('Video Analysis ended with error', e); }).finally(() => { - if (!this.hasMotionType) + if (!this.hasMotionType) { this.plugin.objectDetectionEnded(this.console, options.snapshotPipeline); - else + this.console.log('Video Analysis object detection ended.'); + } + else { this.console.log('Video Analysis motion detection ended.'); + } signal.resolve(); }); }