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))); }