|
@@ -19,6 +19,7 @@ class FaceInfo {
|
|
final String faceID;
|
|
final String faceID;
|
|
final double? faceScore;
|
|
final double? faceScore;
|
|
final double? blurValue;
|
|
final double? blurValue;
|
|
|
|
+ final bool? badFace;
|
|
final List<double>? embedding;
|
|
final List<double>? embedding;
|
|
final Vector? vEmbedding;
|
|
final Vector? vEmbedding;
|
|
int? clusterId;
|
|
int? clusterId;
|
|
@@ -29,6 +30,7 @@ class FaceInfo {
|
|
required this.faceID,
|
|
required this.faceID,
|
|
this.faceScore,
|
|
this.faceScore,
|
|
this.blurValue,
|
|
this.blurValue,
|
|
|
|
+ this.badFace,
|
|
this.embedding,
|
|
this.embedding,
|
|
this.vEmbedding,
|
|
this.vEmbedding,
|
|
this.clusterId,
|
|
this.clusterId,
|
|
@@ -312,6 +314,8 @@ class FaceClusteringService {
|
|
faceID: face.faceID,
|
|
faceID: face.faceID,
|
|
faceScore: face.faceScore,
|
|
faceScore: face.faceScore,
|
|
blurValue: face.blurValue,
|
|
blurValue: face.blurValue,
|
|
|
|
+ badFace: face.faceScore < kMinHighQualityFaceScore ||
|
|
|
|
+ face.blurValue < kLaplacianSoftThreshold,
|
|
vEmbedding: Vector.fromList(
|
|
vEmbedding: Vector.fromList(
|
|
EVector.fromBuffer(face.embeddingBytes).values,
|
|
EVector.fromBuffer(face.embeddingBytes).values,
|
|
dtype: DType.float32,
|
|
dtype: DType.float32,
|
|
@@ -388,12 +392,10 @@ class FaceClusteringService {
|
|
double closestDistance = double.infinity;
|
|
double closestDistance = double.infinity;
|
|
late double thresholdValue;
|
|
late double thresholdValue;
|
|
if (useDynamicThreshold) {
|
|
if (useDynamicThreshold) {
|
|
- final bool badFace =
|
|
|
|
- (sortedFaceInfos[i].faceScore! < kMinHighQualityFaceScore ||
|
|
|
|
- sortedFaceInfos[i].blurValue! < kLaplacianSoftThreshold);
|
|
|
|
- thresholdValue =
|
|
|
|
- badFace ? conservativeDistanceThreshold : distanceThreshold;
|
|
|
|
- if (badFace) dynamicThresholdCount++;
|
|
|
|
|
|
+ thresholdValue = sortedFaceInfos[i].badFace!
|
|
|
|
+ ? conservativeDistanceThreshold
|
|
|
|
+ : distanceThreshold;
|
|
|
|
+ if (sortedFaceInfos[i].badFace!) dynamicThresholdCount++;
|
|
} else {
|
|
} else {
|
|
thresholdValue = distanceThreshold;
|
|
thresholdValue = distanceThreshold;
|
|
}
|
|
}
|
|
@@ -414,6 +416,10 @@ class FaceClusteringService {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
if (distance < closestDistance) {
|
|
if (distance < closestDistance) {
|
|
|
|
+ if (sortedFaceInfos[j].badFace! &&
|
|
|
|
+ distance > conservativeDistanceThreshold) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
closestDistance = distance;
|
|
closestDistance = distance;
|
|
closestIdx = j;
|
|
closestIdx = j;
|
|
// if (distance < distanceThreshold) {
|
|
// if (distance < distanceThreshold) {
|