Detect and crop face using flutter google_mlkit_face_detection

85 Views Asked by At

I need to crop detected faces and save them as image files. I am able to detect face with rounded rectangles, but how do I crop the area of the detected face? I am using google_mlkit_face_detectiont to detect faces. Here is my code:

Future _processImage(InputImage inputImage) async {
  final faces = await _faceDetector.processImage(inputImage);
  if (faces.isNotEmpty) {
      final boundingBox = faces.first.boundingBox;
      final left = boundingBox.left.toInt();
      final top = boundingBox.top.toInt();
      final width = boundingBox.width.toInt();
      final height = boundingBox.height.toInt();        
  }
}
0

There are 0 best solutions below