One Logo Pool Ball
Vision · IOS API REFERENCE

InstanceMaskObservation

struct · iOS 18.0+ · SDK 27.1

struct InstanceMaskObservation

An observation that contains an instance mask that labels instances in the mask.

Members (12)

get · iOS 18.0+

allInstancesMask

TypeScript
get allInstancesMask(): PixelBufferObservation
Swift declaration
let allInstancesMask: PixelBufferObservation

The resulting mask that represents all instances. A pixel can only correspond to one instance. A 0 represents the background, and all other values represent the indices of the instances.

method · iOS 18.0+

generateScaledMask

TypeScript
generateScaledMask(instances: _Foundation_IndexSet, requestHandler: ImageRequestHandler): _CoreVideo_CVBuffer
Swift declaration
func generateScaledMask(for instances: IndexSet, scaledToImageFrom requestHandler: ImageRequestHandler) throws -> CVPixelBuffer

Creates a high-resolution mask representing a combination of the instances you specify. The image produced has the same resolution as the image in the `requestHandler`. - Parameters: - instances: An IndexSet of selected instances, where 0 is the background. - requestHandler: A request handler containing an image. - Returns: The pixel buffer that contains the mask.

method · iOS 18.0+

generateMask

TypeScript
generateMask(instances: _Foundation_IndexSet): _CoreVideo_CVBuffer
Swift declaration
func generateMask(for instances: IndexSet) throws -> CVPixelBuffer

Creates a low-resolution mask from the instances you specify. - Parameters: - instances: An IndexSet of selected instances, where 0 is the background. - Returns: The pixel buffer that contains the mask.

get · iOS 18.0+

confidence

TypeScript
get confidence(): number
Swift declaration
let confidence: Float

The level of confidence normalized to `[0, 1]` where `1` is most confident. The only exception is results coming from `CoreMLRequest`, where confidence values are forwarded as is from relevant CoreML models

get · iOS 18.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 18.0+

allInstances

TypeScript
get allInstances(): _Foundation_IndexSet
Swift declaration
let allInstances: IndexSet

The collection that contains all instances, excluding the background.

method · iOS 18.0+

instanceAtPoint

TypeScript
instanceAtPoint(point: NormalizedPoint): _Foundation_IndexSet
Swift declaration
func instanceAtPoint(_ point: NormalizedPoint) -> IndexSet

Creates an index set containing the instance found at the specified point.

method · iOS 18.0+

generateMaskedImage

TypeScript
generateMaskedImage(instances: _Foundation_IndexSet, requestHandler: ImageRequestHandler, croppedToInstancesExtent?: boolean): _CoreVideo_CVBuffer
Swift declaration
func generateMaskedImage(for instances: IndexSet, imageFrom requestHandler: ImageRequestHandler, croppedToInstancesExtent: Bool = false) throws -> CVPixelBuffer

Creates a high-resolution image with everything except for the instances you specify masked out. The image produced has the same resolution as the image in the `requestHandler`. - Parameters: - instances: An IndexSet of selected instances, where 0 is the background. - requestHandler: A request handler containing an image to be masked. - croppedToInstancesExtent: Crops the image to the smallest rectangle contaning all instances - Returns: The pixel buffer that contains the image.

get · iOS 18.0+

originatingRequestDescriptor

TypeScript
get originatingRequestDescriptor(): (RequestDescriptor) | null
Swift declaration
let originatingRequestDescriptor: RequestDescriptor?

The descriptor of the request that produced the observation.

get · iOS 18.0+

uuid

TypeScript
get uuid(): string
Swift declaration
let uuid: UUID

The unique identifier for the observation.

get · iOS 18.0+

timeRange

TypeScript
get timeRange(): (_CoreMedia_CMTimeRange) | null
Swift declaration
let timeRange: CMTimeRange?

The time range of the reported observation. When evaluating a sequence of image buffers, use this property to determine each observation’s start time and duration.

init · iOS 18.0+

init

TypeScript
static init(observation: VNInstanceMaskObservation): (InstanceMaskObservation) | null
Swift declaration
init?(_ observation: VNInstanceMaskObservation)

Skipped declarations

No declarations were skipped in this snapshot.

All Vision types →