detectFacesWithSegmentation method

Future<DetectionWithSegmentationResult> detectFacesWithSegmentation(
  1. Uint8List imageBytes, {
  2. FaceDetectionMode mode = FaceDetectionMode.full,
  3. IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  4. double binaryThreshold = 0.5,
})

Detects faces and generates segmentation mask in parallel.

Requires initializeSegmentation or initialize(withSegmentation: true).

Returns a DetectionWithSegmentationResult containing both faces and mask.

Processing time is approximately max(detectionTime, segmentationTime) rather than their sum, typically 40-50% faster than sequential calls.

Implementation

Future<DetectionWithSegmentationResult> detectFacesWithSegmentation(
  Uint8List imageBytes, {
  FaceDetectionMode mode = FaceDetectionMode.full,
  IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  double binaryThreshold = 0.5,
}) {
  _requireReady();
  _requireSegmentationReady();
  return _detectAndSegmentImpl(
    detectOp: 'detect',
    detectFields: {
      'bytes': TransferableTypedData.fromList([imageBytes]),
      'mode': mode.name,
    },
    segmentOp: 'segment',
    segmentFields: {
      'bytes': TransferableTypedData.fromList([imageBytes]),
      'outputFormat': outputFormat.index,
      'binaryThreshold': binaryThreshold,
    },
  );
}