isMouthHorizontallyCentered static method

bool isMouthHorizontallyCentered(
  1. double centerXStart,
  2. double centerXEnd,
  3. Map<FaceContourType, FaceContour?> contours
)

Implementation

static bool isMouthHorizontallyCentered(
  double centerXStart,
  double centerXEnd,
  Map<FaceContourType, FaceContour?> contours,
) {
  //  Mouth center alignment
  final upperLip = contours[FaceContourType.upperLipTop]?.points;
  bool isMouthHorizontallyCentered = true;
  if (upperLip != null && upperLip.isNotEmpty) {
    final mouthCenterX =
        upperLip.map((p) => p.x).reduce((a, b) => a + b) / upperLip.length;
    isMouthHorizontallyCentered =
        mouthCenterX >= centerXStart && mouthCenterX <= centerXEnd;
  }
  return isMouthHorizontallyCentered;
}