Skip to content

Commit

Permalink
v1.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jakowenko authored Oct 21, 2022
2 parents 35874f3 + c06d3e0 commit 301872a
Show file tree
Hide file tree
Showing 17 changed files with 370 additions and 1,575 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## [1.13.0-beta.4](https://github.com/jakowenko/double-take/compare/v1.13.0-beta.3...v1.13.0-beta.4) (2022-10-21)


### Features

* **mqtt & api:** total count for person, match, miss, and unknown ([#223](https://github.com/jakowenko/double-take/issues/223)) ([2bf4406](https://github.com/jakowenko/double-take/commit/2bf4406aa7e92b1b255e95475b5393d7345207e4))

## [1.13.0-beta.3](https://github.com/jakowenko/double-take/compare/v1.13.0-beta.2...v1.13.0-beta.3) (2022-10-20)


### Bug Fixes

* remove non alphanumeric characters from MQTT topic names ([#239](https://github.com/jakowenko/double-take/issues/239)) ([885d8a1](https://github.com/jakowenko/double-take/commit/885d8a112ae34e0f5632f3012a4ed63851cfa2ac))

## [1.13.0-beta.2](https://github.com/jakowenko/double-take/compare/v1.13.0-beta.1...v1.13.0-beta.2) (2022-10-20)


### Features

* support for MQTT TLS ([#241](https://github.com/jakowenko/double-take/issues/241)) ([7f37b78](https://github.com/jakowenko/double-take/commit/7f37b78d45f879d782d493595d76a14dbd31b7b5))

## [1.13.0-beta.1](https://github.com/jakowenko/double-take/compare/v1.12.1...v1.13.0-beta.1) (2022-10-19)


### Features

* frigate matches below an area target ([3365bc7](https://github.com/jakowenko/double-take/commit/3365bc78f893081fe69d784e3d6f968d3be561ce))

## [1.12.1](https://github.com/jakowenko/double-take/compare/v1.12.0...v1.12.1) (2022-06-17)


Expand Down
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ There's a lot of great open source software to perform facial recognition, but e

### Supported Detectors

- [CompreFace](https://github.com/exadel-inc/CompreFace) v0.5.0-1.0.0
- [CompreFace](https://github.com/exadel-inc/CompreFace)
- [Amazon Rekognition](https://aws.amazon.com/rekognition)
- [DeepStack](https://deepstack.cc) v2021.02.1-2022.01.01
- [DeepStack](https://deepstack.cc)
- [Facebox](https://machinebox.io)

### Supported NVRs

- [Frigate](https://github.com/blakeblackshear/frigate) v0.8.0-0.11.0
- [Frigate](https://github.com/blakeblackshear/frigate)

## Integrations

Expand Down Expand Up @@ -152,7 +152,8 @@ mqtt:
"type": "latest",
"duration": 0.28,
"detector": "compreface",
"filename": "2f07d1ad-9252-43fd-9233-2786a36a15a9.jpg"
"filename": "2f07d1ad-9252-43fd-9233-2786a36a15a9.jpg",
"base64": null
}
}
```
Expand All @@ -176,9 +177,13 @@ mqtt:
"type": "manual",
"duration": 0.8,
"detector": "compreface",
"filename": "4d8a14a9-96c5-4691-979b-0f2325311453.jpg"
"filename": "dcb772de-d8e8-4074-9bce-15dbba5955c5.jpg",
"base64": null
}
]
],
"misses": [],
"unknowns": [],
"counts": { "person": 1, "match": 1, "miss": 0, "unknown": 0 }
}
```

Expand Down Expand Up @@ -280,6 +285,16 @@ mqtt:
password:
client_id:
tls:
# cert chains in PEM format: /path/to/client.crt
cert:
# private keys in PEM format: /path/to/client.key
key:
# optionally override the trusted CA certificates: /path/to/ca.crt
ca:
# if true the server will reject any connection which is not authorized with the list of supplied CAs
reject_unauthorized: false
topics:
# mqtt topic for frigate message subscription
frigate: frigate/events
Expand Down Expand Up @@ -338,6 +353,11 @@ frigate:
# 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:
- person
Expand Down
4 changes: 2 additions & 2 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "double-take-api",
"version": "1.12.1",
"version": "1.13.0-beta.4",
"description": "Unified UI and API for processing and training images for facial recognition",
"scripts": {
"start": "node server.js",
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,
});
};
4 changes: 4 additions & 0 deletions api/src/constants/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ module.exports = {
labels: ['person'],
update_sub_labels: false,
stop_on_match: true,
min_area: 0,
},
mqtt: {
tls: {
reject_unauthorized: false,
},
topics: {
frigate: 'frigate/events',
matches: 'double-take/matches',
Expand Down
14 changes: 7 additions & 7 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 Expand Up @@ -148,7 +148,7 @@ module.exports.start = async (req, res) => {
);
}

const { best, misses, unknown, results, attempts } = recognize.normalize(
const { best, misses, unknowns, results, attempts, counts } = recognize.normalize(
await Promise.all(promises)
);

Expand All @@ -160,28 +160,28 @@ module.exports.start = async (req, res) => {
attempts,
camera,
zones,
counts,
matches: best,
misses,
unknowns,
};
if (unknown && Object.keys(unknown).length) output.unknown = unknown;
if (AUTH) output.token = jwt.sign({ route: 'storage', expiresIn: TOKEN.IMAGE });

if (resultsOutput === 'all') output.results = results;

console.log(`done processing ${camera}: ${id} in ${duration} sec`);

const loggedOutput = JSON.parse(JSON.stringify(output));
['matches', 'misses'].forEach((type) =>
['matches', 'misses', 'unknowns'].forEach((type) =>
loggedOutput[type].forEach((result) => delete result.base64)
);
if (loggedOutput.unknown) delete loggedOutput.unknown.base64;
console.log(loggedOutput);

PROCESSING = false;

res.send(output);

recognize.save.latest(camera, best, misses, unknown);
recognize.save.latest(camera, best, misses, unknowns[0]);
mqtt.recognize(output);
notify.publish(output, camera, results);
if (event.type === 'frigate') frigate.subLabel(event.topic, id, best);
Expand Down
12 changes: 8 additions & 4 deletions api/src/util/detectors/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ module.exports.normalize = ({ camera, detector, data }) =>
module.exports.checks = ({ MATCH, UNKNOWN, name, confidence, box }) => {
const checks = [];
if (name === 'unknown' && box.width * box.height < UNKNOWN.MIN_AREA) return false;
if (confidence < MATCH.CONFIDENCE)
checks.push(`confidence too low: ${confidence} < ${MATCH.CONFIDENCE}`);
if (box.width * box.height < MATCH.MIN_AREA)
checks.push(`box area too low: ${box.width * box.height} < ${MATCH.MIN_AREA}`);
if (name === 'unknown' && confidence < UNKNOWN.CONFIDENCE) {
checks.push(`confidence too low: ${confidence} < ${UNKNOWN.CONFIDENCE}`);
} else {
if (confidence < MATCH.CONFIDENCE)
checks.push(`confidence too low: ${confidence} < ${MATCH.CONFIDENCE}`);
if (box.width * box.height < MATCH.MIN_AREA)
checks.push(`box area too low: ${box.width * box.height} < ${MATCH.MIN_AREA}`);
}
return checks;
};
5 changes: 4 additions & 1 deletion api/src/util/detectors/deepstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ module.exports.remove = ({ name }) => {
};

module.exports.normalize = ({ camera, data }) => {
if (data.success === false) return [];
if (!data.success) {
console.warn('unexpected deepstack data');
return [];
}
const { MATCH, UNKNOWN } = config.detect(camera);
const normalized = data.predictions.flatMap((obj) => {
const confidence = parseFloat((obj.confidence * 100).toFixed(2));
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
Loading

0 comments on commit 301872a

Please sign in to comment.