[mob]Improve handling of multiple assignment of same faceID to different clusters

This commit is contained in:
Neeraj Gupta
2024-04-12 11:49:40 +05:30
parent 5710cb2d35
commit f3647df1e9

View File

@@ -170,7 +170,13 @@ class PersonService {
faceCount += cluster.faces.length;
for (var faceId in cluster.faces) {
if (faceIdToClusterID.containsKey(faceId)) {
throw Exception("Face $faceId is already assigned to a cluster");
final otherPersonID = clusterToPersonID[faceIdToClusterID[faceId]!];
if (otherPersonID != e.id) {
final otherPerson = await getPerson(otherPersonID!);
throw Exception(
"Face $faceId is already assigned to person $otherPersonID (${otherPerson!.data.name}) and person ${e.id} (${personData.name})",
);
}
}
faceIdToClusterID[faceId] = cluster.id;
}