One Logo Pool Ball
VisionKit · IOS API REFERENCE

ImageAnalysisInteraction.Subject

struct · iOS 16.0+ · SDK 27.1

struct Subject

An area of interest in an image that the framework identifies as a primary focal point. A *subject* is a foreground object in an image. A single image can have multiple subjects. For example, in an image of three different coffee mugs, the framework may classify all three mugs as separate subjects. In cases where the framework can't separate overlapping objects in a photo as individual subjects, a subject may consist of two or more objects. VisionKit enables your app to extract, or *lift*, the image subjects individually, or together, with the background removed. For more information, see ``ImageAnalysisInteraction/Subject/image``. An ``VisionKit/ImageAnalysisInteraction`` object contains an array of subjects (``VisionKit/ImageAnalysisInteraction/subjects``) that activates when ``ImageAnalysisInteraction/preferredInteractionTypes`` contains a subject-related option, such as ``ImageAnalysisInteraction/InteractionTypes/automatic``, or ``ImageAnalysisInteraction/InteractionTypes/imageSubject``. Your app can also present a button that gives more information on an image's subjects by enabling the ``ImageAnalysisInteraction/InteractionTypes/visualLookUp`` interaction type.

Members (2)

get · iOS 16.0+

image

TypeScript
get image(): Promise<_UIKit_UIImage>
Swift declaration
var image: UIImage { get async throws }

An image of the subjects with the background removed.

get · iOS 16.0+

bounds

TypeScript
get bounds(): Promise<{ x: number; y: number; width: number; height: number }>
Swift declaration
@MainActor var bounds: CGRect { get }

A rectangle that identifies the extremities of a subject within an image in relation to the interaction view's bounds. This property will always return `CGRect.zero` if the interaction isn't added to the view.

Skipped declarations

No declarations were skipped in this snapshot.

All VisionKit types →