ObjectDetectorOptions
struct ObjectDetectorOptions: SendableConfiguration options for the MediaPipe ObjectDetector task.
Conforms to Sendable (Equatable and Hashable are omitted because liveStreamResultHandler is an escaping closure).
-
init(baseOptions:runningMode:displayNamesLocale:maxResults:scoreThreshold:categoryAllowlist:categoryDenylist:liveStreamResultHandler:)
Creates
ObjectDetectorOptionswith 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
runningModeis.liveStream.Declaration
Swift
var liveStreamResultHandler: ObjectDetectorOptions.LiveStreamResultHandler? -
Maximum number of top-scored detections to return (
< 0returns all;0is invalid).Declaration
Swift
var maxResults: Int -
Execution mode (
image,video, orliveStream).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