getSegmentationMaskFromCameraFrame method

Future<SegmentationMask> getSegmentationMaskFromCameraFrame(
  1. CameraFrame frame, {
  2. IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  3. double binaryThreshold = 0.5,
  4. int? maxDim,
})

Segments a CameraFrame to separate foreground from background, deferring YUV→BGR colour conversion and rotation to the segmentation isolate.

Throws StateError if initializeSegmentation hasn't been called. Throws SegmentationException on inference failure.

Implementation

Future<SegmentationMask> getSegmentationMaskFromCameraFrame(
  CameraFrame frame, {
  IsolateOutputFormat outputFormat = IsolateOutputFormat.float32,
  double binaryThreshold = 0.5,
  int? maxDim,
}) async {
  _requireReady();
  _requireSegmentationReady();
  final Map<String, dynamic> result =
      await _sendSegmentationRequest<Map<String, dynamic>>(
        'segmentCameraFrame',
        _cameraFrameFields(frame, {
          'outputFormat': outputFormat.index,
          'binaryThreshold': binaryThreshold,
          'maxDim': maxDim,
        }),
      );
  return _deserializeMask(result);
}