detectFacesFromCameraFrame method

Future<List<Face>> detectFacesFromCameraFrame(
  1. CameraFrame frame, {
  2. FaceDetectionMode mode = FaceDetectionMode.full,
  3. int? maxDim,
})

Detects faces directly from a CameraFrame produced by prepareCameraFrame.

The frame's YUV→BGR colour conversion and any optional rotation happen inside the detection isolate, not on the calling thread. Use this from a CameraController.startImageStream callback to keep the UI thread free of OpenCV work.

Throws StateError if initialize has not been called successfully.

Implementation

Future<List<Face>> detectFacesFromCameraFrame(
  CameraFrame frame, {
  FaceDetectionMode mode = FaceDetectionMode.full,
  int? maxDim,
}) async {
  _requireReady();
  final List<dynamic> result = await _sendDetectionRequest<List<dynamic>>(
    'detectCameraFrame',
    _cameraFrameFields(frame, {'mode': mode.name, 'maxDim': maxDim}),
  );
  return _applyGates(_deserializeFacesFast(result));
}