One Logo Pool Ball
Vision · IOS API REFERENCE

CoreMLRequest

struct · iOS 18.0+ · SDK 27.1

struct CoreMLRequest

An image analysis request that uses a Core ML model to process images. The results array of a Core ML-based image analysis request contains a different observation type, depending on the kind of MLModel object you use: * If the model predicts a single feature, the model’s `modelDescription` object has a non-nil value for `predictedFeatureName` and Vision treats the model as a classifier. The results are `ClassificationObservation` objects. * If the model’s outputs include at least one output with a feature type of `MLFeatureType.image`, Vision treats that model as an image-to-image model. The results are `PixelBufferObservation` objects. * Otherwise, Vision treats the model as a general predictor model. The results are `CoreMLFeatureValueObservation` objects. - Note: Vision forwards all confidence values from Core ML models as-is and doesn’t normalize them to [0, 1].

Members (12)

get · iOS 18.0+

descriptor

TypeScript
get descriptor(): RequestDescriptor
Swift declaration
var descriptor: RequestDescriptor { get }

An enum that identifies the request and request revision.

get · iOS 18.0+

modelContainer

TypeScript
get modelContainer(): CoreMLModelContainer
Swift declaration
let modelContainer: CoreMLModelContainer

The model to base the image analysis request on. This object wraps a Core ML model.

get · iOS 18.0+

regionOfInterest

TypeScript
get regionOfInterest(): NormalizedRect
Swift declaration
var regionOfInterest: NormalizedRect

The region of the image in which Vision will perform the request. The rectangle is normalized to the dimensions of the processed image. Its origin is specified relative to the image's lower-left corner. By default, the region of interest will be the full image.

set · iOS 18.0+

regionOfInterest

TypeScript
set regionOfInterest(value: NormalizedRect)
Swift declaration
var regionOfInterest: NormalizedRect

The region of the image in which Vision will perform the request. The rectangle is normalized to the dimensions of the processed image. Its origin is specified relative to the image's lower-left corner. By default, the region of interest will be the full image.

method · iOS 18.0+

setComputeDevice

TypeScript
setComputeDevice(computeDevice: (_CoreML_MLComputeDevice) | null, computeStage: ComputeStage): void
Swift declaration
mutating func setComputeDevice(_ computeDevice: MLComputeDevice?, for computeStage: ComputeStage)

Assigns a compute device for a compute stage. If the parameter `computeDevice` is `nil`, the framework removes any explicit compute device assignment and allows the framework to select the device. Configure any compute device for a given compute stage. When performing a request, the system makes a validity check. Use `supportedComputeStageDevices` to get valid compute devices for a request’s compute stages. - Parameters: - `computeDevice: `The compute device to assign to the compute stage. - `computeStage: `The compute stage.

get · iOS 18.0+

cropAndScaleAction

TypeScript
get cropAndScaleAction(): ImageCropAndScaleAction
Swift declaration
var cropAndScaleAction: ImageCropAndScaleAction
set · iOS 18.0+

cropAndScaleAction

TypeScript
set cropAndScaleAction(value: ImageCropAndScaleAction)
Swift declaration
var cropAndScaleAction: ImageCropAndScaleAction
get · iOS 18.0+

supportedRevisions

TypeScript
static get supportedRevisions(): Array<CoreMLRequest_Revision>
Swift declaration
static let supportedRevisions: [CoreMLRequest.Revision]
get · iOS 18.0+

supportedIdentifiers

TypeScript
get supportedIdentifiers(): (Array<string>) | null
Swift declaration
var supportedIdentifiers: [String]? { get }

The classification identifiers supported by the request. If the specific configuration is not supported, `nil` is returned.

get · iOS 18.0+

supportedComputeStageDevices

TypeScript
get supportedComputeStageDevices(): NativeMap<ComputeStage, Array<_CoreML_MLComputeDevice>>
Swift declaration
var supportedComputeStageDevices: [ComputeStage : [MLComputeDevice]] { get }
init · iOS 18.0+

init

TypeScript
static init(model: CoreMLModelContainer, revision?: (CoreMLRequest_Revision) | null): CoreMLRequest
Swift declaration
init(model: CoreMLModelContainer, _ revision: CoreMLRequest.Revision? = nil)

- Parameters: - model: The container for a CoreML model - revision: The specific algorithm or implementation revision that is to be used to perform the request.

get · iOS 18.0+

revision

TypeScript
get revision(): CoreMLRequest_Revision
Swift declaration
let revision: CoreMLRequest.Revision

The request's configured revision.

Skipped declarations

No declarations were skipped in this snapshot.

All Vision types →