From 7baffedebea9518ac3b057fc78994f8bd3dd75b7 Mon Sep 17 00:00:00 2001 From: SeydX Date: Tue, 11 Jan 2022 04:13:24 +0100 Subject: [PATCH] fix videoanalysis zones --- .gitignore | 3 ++- .npmignore | 1 + src/api/database.js | 7 ------- .../camera/services/videoanalysis.service.js | 12 +++++++----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index e873ce62..3f8b1227 100644 --- a/.gitignore +++ b/.gitignore @@ -157,4 +157,5 @@ mp4 ui/node_modules parseFFmpeg.js parseUrl.js -systeminformation.js \ No newline at end of file +systeminformation.js +parseRegions.js \ No newline at end of file diff --git a/.npmignore b/.npmignore index f4edc79d..7863601d 100644 --- a/.npmignore +++ b/.npmignore @@ -76,3 +76,4 @@ ui parseFFmpeg.js parseUrl.js systeminformation.js +parseRegions.js diff --git a/src/api/database.js b/src/api/database.js index 03a932e6..566efdd0 100644 --- a/src/api/database.js +++ b/src/api/database.js @@ -421,9 +421,6 @@ class Database { } static async #ensureCameraDatabaseValues(settings) { - // old - delete settings.regions; - if (!settings.name) { settings.name = defaultCameraSettingsEntry.name; } @@ -512,10 +509,6 @@ class Database { settings.videoanalysis = {}; } - // old - settings.videoanalysis.sensitivity = settings.videoanalysis.sensibility; - delete settings.videoanalysis.sensibility; - if (!(settings.videoanalysis.sensitivity >= 0 && settings.videoanalysis.sensitivity <= 100)) { settings.videoanalysis.sensitivity = defaultCameraSettingsEntry.videoanalysis.sensitivity; } diff --git a/src/controller/camera/services/videoanalysis.service.js b/src/controller/camera/services/videoanalysis.service.js index 2e779391..5a7e2a1f 100644 --- a/src/controller/camera/services/videoanalysis.service.js +++ b/src/controller/camera/services/videoanalysis.service.js @@ -58,14 +58,14 @@ class VideoAnalysisService { // 0 - 100 changeSensitivity(sensitivity) { - if (sensitivity >= 0 && this.videoanalysisSession?.pamDiff) { + if (sensitivity >= 0 && sensitivity <= 100 && this.videoanalysisSession?.pamDiff) { const value = 100 - sensitivity; // 0: MAX - 100: MIN - const difference = Math.round(value / 3) || 10; + const difference = Math.round(value / 3); // 0: MAX - 100: MIN - const percentage = value || 50; + const percentage = value; this.videoanalysisSession.pamDiff.setDifference(difference); this.videoanalysisSession.pamDiff.setPercent(percentage); @@ -323,7 +323,9 @@ class VideoAnalysisService { return state; } - #createRegions(regions, sensitivity) { + #createRegions(regions = [], sensitivity) { + sensitivity = sensitivity >= 100 && sensitivity <= 100 ? sensitivity : 50; + const zones = regions ?.map((region, index) => { if (region.coords?.length > 2) { @@ -340,7 +342,7 @@ class VideoAnalysisService { }; } }) - .filter((coord) => coord?.length > 2), + .filter((coord) => coord), }; } })