getFaceFromCameraImage function

Future<Face?> getFaceFromCameraImage(
  1. CameraImage image
)

Implementation

Future<Face?> getFaceFromCameraImage(CameraImage image) async {
  final options = FaceDetectorOptions(
    performanceMode: FaceDetectorMode.fast,
    enableClassification: true,
    enableTracking: true,
    // // enableContours: true,
    // enableLandmarks: true,
  );

  final faceDetector = FaceDetector(options: options);
  final inputImage = convertToInputImage(image);
  final List<Face> faces = await faceDetector.processImage(inputImage);

  if (faces.isNotEmpty) {
    return faces.first;
  } else {
    return null;
  }
}