MediaPipeTasksVision Framework Reference

ImageSegmenterOptions

struct ImageSegmenterOptions: Sendable

Options for configuring an ImageSegmenter task.

Not Equatable or Hashable because liveStreamResultHandler is a closure.

  • Creates options for single-image segmentation that output confidence masks only.

    Declaration

    Swift

    init(baseOptions: BaseOptions = BaseOptions(), runningMode: VisionRunningMode = .image, displayNamesLocale: String = "en", outputConfidenceMasks: Bool = true, outputCategoryMask: Bool = false, liveStreamResultHandler: ImageSegmenterOptions.LiveStreamResultHandler? = nil)
  • Base options for model loading and hardware acceleration delegation.

    Declaration

    Swift

    var baseOptions: BaseOptions
  • Locale used for display names from the TFLite Model Metadata.

    Declaration

    Swift

    var displayNamesLocale: String
  • Handler for .liveStream results. Must be nil in .image and .video modes.

    Declaration

    Swift

    var liveStreamResultHandler: ImageSegmenterOptions.LiveStreamResultHandler?
  • Whether to output a UInt8 category mask.

    Declaration

    Swift

    var outputCategoryMask: Bool
  • Whether to output per-category Float32 confidence masks.

    Declaration

    Swift

    var outputConfidenceMasks: Bool
  • Execution mode of the segmenter. .liveStream requires liveStreamResultHandler.

    Declaration

    Swift

    var runningMode: VisionRunningMode
  • Receives asynchronous .liveStream segmentation results (or errors) with their input timestamp on a private serial queue.

    Declaration

    Swift

    typealias LiveStreamResultHandler = @Sendable (Result<ImageSegmenterResult, any Error>, Int) -> Void