An object that finds items in images that people can interact with, such
as subjects, text, and QR codes.
To use an `ImageAnalyzer` object, first create an
``ImageAnalyzer/Configuration`` object, and specify the types of items you
want to find in an image. Then pass the image you want to analyze and the
configuration object to an `ImageAnalyzer` object using the
``ImageAnalyzer/analyze(_:configuration:)`` or similar method. This method
returns an ``ImageAnalysis`` object that contains all the data VisionKit
needs to implement the Live Text interface.
Next, show the Live Text interface. For iOS apps, set the
interaction object of the view that contains the image to an instance of
``ImageAnalysisInteraction`` and set its
``ImageAnalysisInteraction/analysis`` property to the `ImageAnalysis`
object. To enable interactions with the image, set the interaction object’s
``ImageAnalysisInteraction/preferredInteractionTypes`` property. To
customize the Live Text interface, set the `ImageAnalysisInteraction
`object’s ``ImageAnalysisInteraction/delegate`` property and implement the
``ImageAnalysisInteractionDelegate`` protocol methods.
For macOS apps, add an `ImageAnalysisOverlayView` object above the view that
contains the image, and set its `analysis` property. To enable interactions
with the image, set the overlay view’s `preferredInteractionTypes` property.
Set the `ImageAnalysisOverlayView `object’s `delegate` property and
implement the `ImageAnalysisOverlayViewDelegate` protocol methods.
By default, the Live Text interface starts immediately when you show the
view.
Members (9)
get · iOS 16.0+
isSupported
TypeScript
static get isSupported(): boolean
Swift declaration
final class var isSupported: Bool { get }
A Boolean value that indicates whether the device supports image analysis.
Check this property at runtime to determine if the device supports finding text, machine-readable codes, and subjects
in images. The system sets this property to `true` on devices that have an A12 Bionic chip or later.
For more information on the kinds of things the analyzer finds in images, see ``ImageAnalyzer/AnalysisTypes``.
- Note: If image analysis is a fundamental requirement for your app's operation,
you can prevent unsupported devices from installing your app. Add the
<doc://com.apple.documentation/documentation/bundleresources/information_property_list/uirequireddevicecapabilities>
key to your app’s `Info.plist` (or update the key if it's already present) and include the array member
`iphone-ipad-minimum-performance-a12`.
get · iOS 16.0+
supportedTextRecognitionLanguages
TypeScript
static get supportedTextRecognitionLanguages(): Array<string>
Swift declaration
final class var supportedTextRecognitionLanguages: [String] { get }
The identifiers for the languages that the image analyzer recognizes.
Returns the data for providing a Live Text interaction with an image at
a URL and in the specified orientation.
- Parameter url: The URL location of an image that the analyzer processes.
- Parameter orientation: The orientation that the analyzer uses to process the
image.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
Returns the data for providing a Live Text interaction with a Core
Graphics image in the specified orientation.
- Parameter cgImage: An image that the analyzer processes.
- Parameter orientation: The orientation that the analyzer uses to process the
image.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
Returns the data for providing a Live Text interaction with a pixel
buffer image in the specified orientation.
- Parameter pixelBuffer: A Core Video pixel buffer object that the analyzer
processes.
- Parameter orientation: The orientation that the analyzer uses to process the
image.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
Returns the data for providing a Live Text interaction with a bitmap
image in the specified orientation.
- Parameter ciImage: A bitmap image or image mask that the analyzer processes.
- Parameter orientation: The orientation that the analyzer uses to process the
image.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
Returns the data for providing a Live Text interaction with an image in
the specified orientation.
- Parameter image: An image that the analyzer processes.
- Parameter orientation: The orientation that the analyzer uses to process the image.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
Returns the data for providing a Live Text interaction with an image.
- Parameter image: An image that the analyzer processes.
- Parameter configuration: A configuration that specifies the data types, and
locales for text items, to recognize.
- Returns: The data items that the analyzer finds in the image.
This function configures orientation automatically based on the given image's orientation property.
init · iOS 16.0+
init
TypeScript
static init(): ImageAnalyzer
Swift declaration
init()
Creates an image analyzer that identifies subjects, text, and machine-readable codes in
images.