detectFacesFromBytes method

Future<List<Face>> detectFacesFromBytes(
  1. Uint8List imageBytes, {
  2. FaceDetectionMode mode = FaceDetectionMode.full,
})

Detects faces in encoded image bytes and returns detailed results.

The imageBytes parameter should contain encoded image data (JPEG, PNG, etc.). For pre-decoded cv.Mat input, use detectFacesFromMat instead.

The mode parameter controls which features are computed:

Returns a List of Face objects, one per detected face.

Throws StateError if initialize has not been called successfully. Throws FormatException if the image bytes cannot be decoded.

Implementation

Future<List<Face>> detectFacesFromBytes(
  Uint8List imageBytes, {
  FaceDetectionMode mode = FaceDetectionMode.full,
}) async {
  _requireReady();
  final List<dynamic> result;
  try {
    result = await _sendDetectionRequest<List<dynamic>>('detect', {
      'bytes': TransferableTypedData.fromList([imageBytes]),
      'mode': mode.name,
    });
  } catch (e) {
    rethrowOrFormatException(e, imageBytes);
  }
  return _applyGates(_deserializeFacesFast(result));
}