Skip to content

Commit

Permalink
feat: frigate matches below an area target
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulak authored and jakowenko committed Oct 19, 2022
1 parent 35874f3 commit 3365bc7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ frigate:
# 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
# ignore detected areas so small that face recognition would be difficult
# quadrupling the min_area of the detector is a good start
# does not apply to MQTT events
min_area: 0
# object labels that are allowed for facial recognition
labels:
Expand Down
2 changes: 2 additions & 0 deletions api/src/constants/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ module.exports.frigate = ({ id, camera, topic }) => {
attempts,
image,
stop_on_match: stopOnMatch,
min_area: minArea,
} = JSON.parse(JSON.stringify(CONFIG.frigate));
const { masks } = module.exports;

Expand All @@ -152,5 +153,6 @@ module.exports.frigate = ({ id, camera, topic }) => {
url: { frigate: url, snapshot, latest },
attempts,
stop_on_match: stopOnMatch,
min_area: minArea,
});
};
1 change: 1 addition & 0 deletions api/src/constants/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
labels: ['person'],
update_sub_labels: false,
stop_on_match: true,
min_area: 0,
},
mqtt: {
topics: {
Expand Down
4 changes: 2 additions & 2 deletions api/src/controllers/recognize.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ module.exports.start = async (req, res) => {
if (event.type === 'frigate') {
const { type: frigateEventType, topic } = req.body;
const attributes = req.body.after ? req.body.after : req.body.before;
const { id, label, camera, current_zones: zones } = attributes;
event = { id, label, camera, zones, frigateEventType, topic, ...event };
const { id, label, camera, area, current_zones: zones } = attributes;
event = { id, label, camera, area, zones, frigateEventType, topic, ...event };
} else {
const { url, camera } = req.query;

Expand Down
5 changes: 5 additions & 0 deletions api/src/util/frigate.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports.checks = async ({
topic,
label,
camera,
area,
zones,
PROCESSING,
IDS,
Expand Down Expand Up @@ -63,6 +64,10 @@ module.exports.checks = async ({
return `${id} - ${label} label not in (${FRIGATE.LABELS.join(', ')})`;
}

if (FRIGATE.MIN_AREA > area) {
return `skipping object area smaller than ${FRIGATE.MIN_AREA} (${area})`;
}

if (IDS.includes(id)) {
return `already processed ${id}`;
}
Expand Down

0 comments on commit 3365bc7

Please sign in to comment.