From 4b9899077c74da601fa5d497c929c264e8c03fa6 Mon Sep 17 00:00:00 2001 From: David Jakowenko Date: Sun, 12 Jun 2022 00:32:50 -0400 Subject: [PATCH] feat(frigate): stop_on_match config option to break process loop --- README.md | 4 ++++ api/src/constants/config.js | 9 ++++++++- api/src/constants/defaults.js | 1 + api/src/controllers/recognize.controller.js | 2 ++ api/src/schemas/index.js | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ac888d0e..cc3b921d 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,10 @@ frigate: # NOTE: requires frigate 0.11.0+ update_sub_labels: false + # stop the processing loop if a match is found + # if set to false all image attempts will be processed before determining the best match + stop_on_match: true + # object labels that are allowed for facial recognition labels: - person diff --git a/api/src/constants/config.js b/api/src/constants/config.js index ae848e95..a4e33823 100644 --- a/api/src/constants/config.js +++ b/api/src/constants/config.js @@ -125,7 +125,13 @@ module.exports.notify = () => { module.exports.frigate = ({ id, camera, topic }) => { const { topicURL } = require('../util/frigate.util'); - const { url, events, attempts, image } = JSON.parse(JSON.stringify(CONFIG.frigate)); + const { + url, + events, + attempts, + image, + stop_on_match: stopOnMatch, + } = JSON.parse(JSON.stringify(CONFIG.frigate)); const { masks } = module.exports; _.mergeWith(image, events?.[camera]?.image || {}, customizer); @@ -142,5 +148,6 @@ module.exports.frigate = ({ id, camera, topic }) => { return objectKeysToUpperCase({ url: { frigate: url, snapshot, latest }, attempts, + stop_on_match: stopOnMatch, }); }; diff --git a/api/src/constants/defaults.js b/api/src/constants/defaults.js index 0b6d21ae..640fcd4a 100644 --- a/api/src/constants/defaults.js +++ b/api/src/constants/defaults.js @@ -26,6 +26,7 @@ module.exports = { image: { height: 500 }, labels: ['person'], update_sub_labels: false, + stop_on_match: true, }, mqtt: { topics: { diff --git a/api/src/controllers/recognize.controller.js b/api/src/controllers/recognize.controller.js index 581b107f..8387a65a 100644 --- a/api/src/controllers/recognize.controller.js +++ b/api/src/controllers/recognize.controller.js @@ -107,6 +107,7 @@ module.exports.start = async (req, res) => { { id, MATCH_IDS, + breakMatch: FRIGATE.STOP_ON_MATCH, retries: FRIGATE.ATTEMPTS.LATEST, type: 'latest', url: FRIGATE.URL.LATEST, @@ -121,6 +122,7 @@ module.exports.start = async (req, res) => { { id, MATCH_IDS, + breakMatch: FRIGATE.STOP_ON_MATCH, retries: FRIGATE.ATTEMPTS.SNAPSHOT, type: 'snapshot', url: FRIGATE.URL.SNAPSHOT, diff --git a/api/src/schemas/index.js b/api/src/schemas/index.js index c8bbf823..8b1aca71 100644 --- a/api/src/schemas/index.js +++ b/api/src/schemas/index.js @@ -202,6 +202,7 @@ module.exports.detect = { confidence: { type: 'number' }, purge: { type: 'number' }, min_area: { type: 'number' }, + stop_on_match: { type: 'boolean' }, }, }, unknown: {