detectFacesFromCameraImage method
- Object cameraImage, {
- FaceDetectionMode mode = FaceDetectionMode.full,
- CameraFrameRotation? rotation,
- bool? isBgra,
- int? maxDim,
One-call wrapper for live camera streams: takes a CameraImage-shaped
object directly (any object exposing width, height, and planes with
bytes / bytesPerRow / bytesPerPixel) and runs YUV packing, colour
conversion, rotation, and downscale in the detection isolate - all off
the UI thread.
Returns an empty list (not an error) when the plane shape can't be
decoded. Throws at runtime if cameraImage doesn't expose the expected
shape.
isBgra selects BGRA vs. RGBA for the desktop single-plane path; ignored
for YUV input (Android/iOS). Defaults to true on macOS (BGRA) and
false on Windows/Linux (RGBA). Only pass this explicitly if you are
using a non-standard camera plugin that delivers a different format.
Throws StateError if initialize has not been called successfully.
Implementation
Future<List<Face>> detectFacesFromCameraImage(
Object cameraImage, {
FaceDetectionMode mode = FaceDetectionMode.full,
CameraFrameRotation? rotation,
bool? isBgra,
int? maxDim,
}) async {
_requireReady();
final frame = prepareCameraFrameFromImage(
cameraImage,
rotation: rotation,
isBgra: isBgra ?? Platform.isMacOS,
);
if (frame == null) return const <Face>[];
return detectFacesFromCameraFrame(frame, mode: mode, maxDim: maxDim);
}