Limit faces to only those with confidence > 0.9

Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
James Ketrenos 2020-01-08 21:33:09 -08:00
parent 23c43a8fd6
commit 1b32b1ea7c
3 changed files with 14 additions and 4 deletions

View File

@ -147,6 +147,8 @@ long int chainLength(FaceLink *pLink) {
return count; return count;
} }
long int maxPts = 0;
long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) { long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
long int C = 0; long int C = 0;
for (long int i = 0; i < faceCount; i++) { for (long int i = 0; i < faceCount; i++) {
@ -157,6 +159,10 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
FaceLink *pNeighbors = RangeQuery(ppFaces, faceCount, pFace, eps); FaceLink *pNeighbors = RangeQuery(ppFaces, faceCount, pFace, eps);
long neighborCount = chainLength(pNeighbors); long neighborCount = chainLength(pNeighbors);
if (neighborCount > maxPts) {
maxPts = neighborCount;
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
}
if (neighborCount < minPts) { if (neighborCount < minPts) {
pFace->clusterType = NOISE; pFace->clusterType = NOISE;
freeChain(pNeighbors); freeChain(pNeighbors);
@ -193,6 +199,10 @@ long int DBSCAN(Face **ppFaces, long int faceCount, double eps, int minPts) {
FaceLink *pSubNeighbors = RangeQuery(ppFaces, faceCount, pQ, eps); FaceLink *pSubNeighbors = RangeQuery(ppFaces, faceCount, pQ, eps);
neighborCount = chainLength(pSubNeighbors); neighborCount = chainLength(pSubNeighbors);
if (neighborCount >= minPts) { if (neighborCount >= minPts) {
if (neighborCount > maxPts) {
maxPts = neighborCount;
fprintf(stderr, "New max with id %ld: %ld\n", pFace->faceId, maxPts);
}
pQ->clusterType = CORE; pQ->clusterType = CORE;
/* Append these neighbors to the end of the chain */ /* Append these neighbors to the end of the chain */
FaceLink *pTmp = pLink; FaceLink *pTmp = pLink;
@ -291,7 +301,7 @@ int main(int argc, char *argv[]) {
} }
count++; count++;
if (count % 1000 == 0) { if (count % 1000 == 0) {
fprintf(stderr, "...read %ld...\n", count); fprintf(stderr, "Read %ld%% of descriptors.\n", (100 * count / entries));
} }
} }
closedir(faceDir); closedir(faceDir);

View File

@ -155,7 +155,7 @@ require("./db/photos").then(function(db) {
const image = await canvas.loadImage(picturesPath + photoPath); const image = await canvas.loadImage(picturesPath + photoPath);
const detections = await faceapi.detectAllFaces(image, const detections = await faceapi.detectAllFaces(image,
new faceapi.SsdMobilenetv1Options({ new faceapi.SsdMobilenetv1Options({
minConfidence: 0.8 minConfidence: 0.9
}) })
).withFaceLandmarks(); ).withFaceLandmarks();

View File

@ -161,7 +161,7 @@ require("./db/photos").then(function(db) {
loader = canvas.loadImage(picturesPath + file).then(async (image) => { loader = canvas.loadImage(picturesPath + file).then(async (image) => {
const detectors = await faceapi.detectAllFaces(image, const detectors = await faceapi.detectAllFaces(image,
new faceapi.SsdMobilenetv1Options({ new faceapi.SsdMobilenetv1Options({
minConfidence: 0.8 minConfidence: 0.9
}) })
).withFaceLandmarks(); ).withFaceLandmarks();