findFaces method

Future<List<Face>> findFaces(
  1. Bitmap bitmap
)

Finds all the faces found in a given Bitmap.

Returns an array of Face for each face found.

See: https://developer.android.com/reference/android/media/FaceDetector#findFaces(android.graphics.Bitmap,%20android.media.FaceDetector.Face[])

Implementation

Future<List<Face>> findFaces(final Bitmap bitmap) async {
  assert(Platform.isAndroid);
  final request = <String, dynamic>{
    'width': width,
    'height': height,
    'maxFaces': maxFaces,
    'bitmapName': bitmap.assetName, // TODO: support dynamic images as well
  };
  final response = await _channel.invokeMethod('findFaces', request);
  return response.cast<List<dynamic>>().map((final List<dynamic> input) {
    final result = input.cast<double>();
    return Face(
      confidence: result[0],
      midPoint: PointF(result[1], result[2]),
      eyesDistance: result[3],
      poseX: result[4],
      poseY: result[5],
      poseZ: result[6],
    );
  }).toList();
}