Skip to content

Commit

Permalink
fix videoanalysis zones
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Jan 11, 2022
1 parent 6699850 commit 7baffed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ mp4
ui/node_modules
parseFFmpeg.js
parseUrl.js
systeminformation.js
systeminformation.js
parseRegions.js
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ ui
parseFFmpeg.js
parseUrl.js
systeminformation.js
parseRegions.js
7 changes: 0 additions & 7 deletions src/api/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,6 @@ class Database {
}

static async #ensureCameraDatabaseValues(settings) {
// old
delete settings.regions;

if (!settings.name) {
settings.name = defaultCameraSettingsEntry.name;
}
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 7 additions & 5 deletions src/controller/camera/services/videoanalysis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -340,7 +342,7 @@ class VideoAnalysisService {
};
}
})
.filter((coord) => coord?.length > 2),
.filter((coord) => coord),
};
}
})
Expand Down

0 comments on commit 7baffed

Please sign in to comment.