detectFacesWithSegmentationFromCameraFrame method

Future<DetectionWithSegmentationResult> detectFacesWithSegmentationFromCameraFrame(
  1. CameraFrame frame, {
  2. FaceDetectionMode mode = FaceDetectionMode.full,
  3. IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  4. double binaryThreshold = 0.5,
  5. int? maxDim,
})

Detects faces and generates a segmentation mask in parallel from a CameraFrame, with all OpenCV work off the UI thread.

The frame's bytes are transferred to both the detection and segmentation isolates; each does its own cvtColor + optional rotate before inference. Total wall time is still ~max(detect, segment) since the two run in parallel.

Implementation

Future<DetectionWithSegmentationResult>
detectFacesWithSegmentationFromCameraFrame(
  CameraFrame frame, {
  FaceDetectionMode mode = FaceDetectionMode.full,
  IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  double binaryThreshold = 0.5,
  int? maxDim,
}) {
  _requireReady();
  _requireSegmentationReady();
  return _detectAndSegmentImpl(
    detectOp: 'detectCameraFrame',
    detectFields: _cameraFrameFields(frame, {
      'mode': mode.name,
      'maxDim': maxDim,
    }),
    segmentOp: 'segmentCameraFrame',
    segmentFields: _cameraFrameFields(frame, {
      'outputFormat': outputFormat.index,
      'binaryThreshold': binaryThreshold,
      'maxDim': maxDim,
    }),
  );
}