detectFacesFromFilepath method

Future<List<Face>> detectFacesFromFilepath(
  1. String path, {
  2. FaceDetectionMode mode = FaceDetectionMode.full,
})

Detects faces in an image file at path.

Convenience wrapper that reads the file and calls detectFacesFromBytes. Not available on Flutter Web (uses dart:io).

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

Implementation

Future<List<Face>> detectFacesFromFilepath(
  String path, {
  FaceDetectionMode mode = FaceDetectionMode.full,
}) async {
  return _runTrackedDetection(() async {
    final bytes = await File(path).readAsBytes();
    // Preserve the previous error ordering: filepath I/O happens before the
    // detector readiness check performed by detectFacesFromBytes.
    _requireReady();
    return _detectFacesFromBytesUntracked(bytes, mode);
  });
}