detectFace static method

Future<FaceDetectionResult> detectFace({
  1. bool accurateMode = false,
  2. Map<String, dynamic>? accuracyConfig,
})

Implementation

static Future<FaceDetectionResult> detectFace(
    {bool accurateMode = false, Map<String, dynamic>? accuracyConfig}) async {
  if (!_initialized) return FaceDetectionResult(detected: false);

  final videoElements = html.document.getElementsByTagName('video');
  if (videoElements.isEmpty) return FaceDetectionResult(detected: false);

  try {
    final result = await js_util.promiseToFuture<FaceDetectionResult>(js_util
        .callMethod(window, 'detectFace',
            [videoElements[0], accurateMode, js_util.jsify(accuracyConfig)]));
    return result;
  } catch (e) {
    print('Face detection error: $e');
    return FaceDetectionResult(detected: false);
  }
}