From df918a04de2b1c3b8953f001f68215dace4c13fd Mon Sep 17 00:00:00 2001 From: Matias De lellis Date: Tue, 8 Aug 2023 20:38:15 -0300 Subject: [PATCH] Don't show the individual clusters but now accordingly with the new version of Face Recogntion. --- .../FaceRecognitionBackend.php | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/ClustersBackend/FaceRecognitionBackend.php b/lib/ClustersBackend/FaceRecognitionBackend.php index f490d5a7..cafaf18d 100644 --- a/lib/ClustersBackend/FaceRecognitionBackend.php +++ b/lib/ClustersBackend/FaceRecognitionBackend.php @@ -220,7 +220,12 @@ class FaceRecognitionBackend extends Backend return (int) $this->config->getAppValue('facerecognition', 'model', -1); } - private function getFaceRecognitionClusters(int $fileid = 0, bool $show_singles = false, bool $show_hidden = false) + private function minFaceInClusters(): int + { + return (int) $this->config->getAppValue('facerecognition', 'min_faces_in_cluster', 5); + } + + private function getFaceRecognitionClusters(int $fileid = 0) { $query = $this->tq->getBuilder(); @@ -250,18 +255,14 @@ class FaceRecognitionBackend extends Backend $query->addGroupBy('frp.user'); $query->where($query->expr()->isNull('frp.name')); - // WHERE these clusters contain fileid if specified + // The query change if we want the people in an fileid, or the unnamed clusters if ($fileid > 0) { + // WHERE these clusters contain fileid if specified $query->andWhere($query->expr()->eq('fri.file', $query->createNamedParameter($fileid))); - } - - // By default hides individual faces when they have no name. - if (!$show_singles && !$fileid) { - $query->having($query->expr()->gt($count, $query->expr()->literal(1, \PDO::PARAM_INT))); - } - - // By default it shows the people who were not hidden - if (!$show_hidden && !$fileid) { + } else { + // WHERE these clusters has a minimum number of faces + $query->having($query->expr()->gte($count, $query->expr()->literal($this->minFaceInClusters(), \PDO::PARAM_INT))); + // WHERE these clusters were not hidden due inconsistencies $query->andWhere($query->expr()->eq('frp.is_visible', $query->expr()->literal(1))); }