Don't show the individual clusters but now accordingly with the new version of Face Recogntion.

pull/767/head
Matias De lellis 2023-08-08 20:38:15 -03:00
parent 68e8204ee6
commit df918a04de
1 changed files with 12 additions and 11 deletions

View File

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