faceDetectionToRoi function

RectF faceDetectionToRoi(
  1. RectF boundingBox, {
  2. double expandFraction = 0.6,
})

Expands a face bounding box and turns it into a square ROI suitable for face mesh alignment.

Implementation

RectF faceDetectionToRoi(RectF boundingBox, {double expandFraction = 0.6}) {
  final RectF e = boundingBox.expand(expandFraction);
  final double cx = (e.xmin + e.xmax) * 0.5;
  final double cy = (e.ymin + e.ymax) * 0.5;
  final double s = math.max(e.w, e.h) * 0.5;
  return RectF(cx - s, cy - s, cx + s, cy + s);
}