Skip to content

Commit

Permalink
feat(api): update frigate sub label
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko committed May 23, 2022
1 parent cc617c9 commit ad40018
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions api/src/constants/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions api/src/controllers/recognize.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 10 additions & 0 deletions api/src/util/frigate.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ad40018

Please sign in to comment.