diff --git a/README.md b/README.md index 71137e01..4a110bf6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ There's a lot of great open source software to perform facial recognition, but e ### Supported NVRs -- [Frigate](https://github.com/blakeblackshear/frigate) v0.8.0-0.9.0 +- [Frigate](https://github.com/blakeblackshear/frigate) v0.8.0-0.11.0 ## Integrations @@ -328,6 +328,10 @@ detect: frigate: url: + # if double take should send matches back to frigate as a sub label + # NOTE: requires frigate 0.11.0+ + update_sub_labels: false + # object labels that are allowed for facial recognition labels: - person diff --git a/api/src/constants/defaults.js b/api/src/constants/defaults.js index 5b29965f..0300c805 100644 --- a/api/src/constants/defaults.js +++ b/api/src/constants/defaults.js @@ -24,6 +24,7 @@ module.exports = { attempts: { latest: 10, snapshot: 10, mqtt: true, delay: 0 }, image: { height: 500 }, labels: ['person'], + update_sub_labels: false, }, mqtt: { topics: { diff --git a/api/src/controllers/recognize.controller.js b/api/src/controllers/recognize.controller.js index 7de86d6a..581b107f 100644 --- a/api/src/controllers/recognize.controller.js +++ b/api/src/controllers/recognize.controller.js @@ -180,6 +180,7 @@ module.exports.start = async (req, res) => { recognize.save.latest(camera, best, misses, unknown); mqtt.recognize(output); notify.publish(output, camera, results); + if (event.type === 'frigate') frigate.subLabel(event.topic, id, best); if (output.matches.length) IDS.push(id); if (results.length) emit('recognize', true); } catch (error) { diff --git a/api/src/util/frigate.util.js b/api/src/util/frigate.util.js index 33770d83..be9832af 100644 --- a/api/src/util/frigate.util.js +++ b/api/src/util/frigate.util.js @@ -5,6 +5,16 @@ const { FRIGATE, MQTT } = require('../constants')(); const frigate = this; +module.exports.subLabel = async (topic, id, best) => { + if (!FRIGATE.URL || !FRIGATE.UPDATE_SUB_LABELS || !best.length) return; + const names = best.map(({ name }) => name).join(', '); + await axios({ + method: 'post', + url: `${this.topicURL(topic)}/api/events/${id}/sub_label`, + data: { subLabel: names }, + }).catch((error) => console.error(`sublabel error: ${error.message}`)); +}; + module.exports.checks = async ({ id, frigateEventType: type,