[mob] Handle error and empty face in visibility detector
This commit is contained in:
parent
cbc7034d47
commit
b00ab0541e
|
@ -1,3 +1,4 @@
|
|||
import "package:logging/logging.dart";
|
||||
import "package:photos/face/model/box.dart";
|
||||
import "package:photos/face/model/landmark.dart";
|
||||
|
||||
|
@ -49,6 +50,10 @@ class Detection {
|
|||
|
||||
// TODO: iterate on better scoring logic, current is a placeholder
|
||||
int getVisibilityScore() {
|
||||
try {
|
||||
if (isEmpty) {
|
||||
return -1;
|
||||
}
|
||||
final double aspectRatio = box.width / box.height;
|
||||
final double eyeDistance = (landmarks[1].x - landmarks[0].x).abs();
|
||||
final double mouthDistance = (landmarks[4].x - landmarks[3].x).abs();
|
||||
|
@ -79,5 +84,9 @@ class Detection {
|
|||
}
|
||||
|
||||
return score.clamp(0, 100).toInt();
|
||||
} catch (e) {
|
||||
Logger("FaceDetection").warning('Error calculating visibility score:', e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue