isFaceState static method
bool
isFaceState(
- Face face
)
Implementation
static bool isFaceState(Face face) {
// Update stored values for next frame
var previousBoundingBox = face.boundingBox;
var previousEulerY = face.headEulerAngleY!;
// Set thresholds for what you consider "stable"
const positionThreshold = 10.0; // pixels
const angleThreshold = 5.0; // degrees
bool isStable = false;
final dx =
(face.boundingBox.center.dx - previousBoundingBox.center.dx).abs();
final dy =
(face.boundingBox.center.dy - previousBoundingBox.center.dy).abs();
final angleDiff = (face.headEulerAngleY! - previousEulerY).abs();
isStable = dx < positionThreshold &&
dy < positionThreshold &&
angleDiff < angleThreshold;
return isStable;
}