MediaPipeTasksVision Framework Reference

ObjectDetectorOptions

struct ObjectDetectorOptions: Sendable

Configuration options for the MediaPipe ObjectDetector task.

Conforms to Sendable (Equatable and Hashable are omitted because liveStreamResultHandler is an escaping closure).

  • Creates ObjectDetectorOptions with the specified configuration.

    Declaration

    Swift

    init(baseOptions: BaseOptions = BaseOptions(), runningMode: VisionRunningMode = .image, displayNamesLocale: String = "en", maxResults: Int = -1, scoreThreshold: Float = 0.0, categoryAllowlist: [String] = [], categoryDenylist: [String] = [], liveStreamResultHandler: ObjectDetectorOptions.LiveStreamResultHandler? = nil)
  • Model asset and hardware delegate configuration.

    Declaration

    Swift

    var baseOptions: BaseOptions
  • Category names to include exclusively (mutually exclusive with categoryDenylist).

    Declaration

    Swift

    var categoryAllowlist: [String]
  • Category names to exclude (mutually exclusive with categoryAllowlist).

    Declaration

    Swift

    var categoryDenylist: [String]
  • BCP-47 locale for localized category display names in model metadata.

    Declaration

    Swift

    var displayNamesLocale: String
  • Asynchronous delivery closure required when runningMode is .liveStream.

    Declaration

    Swift

    var liveStreamResultHandler: ObjectDetectorOptions.LiveStreamResultHandler?
  • Maximum number of top-scored detections to return (< 0 returns all; 0 is invalid).

    Declaration

    Swift

    var maxResults: Int
  • Execution mode (image, video, or liveStream).

    Declaration

    Swift

    var runningMode: VisionRunningMode
  • Minimum confidence score threshold overriding model metadata.

    Declaration

    Swift

    var scoreThreshold: Float
  • Asynchronous callback invoked on a serial queue with live-stream detection results.

    Declaration

    Swift

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