An object that detects faces in images and groups them by person.
``FaceGroupAnalyzer`` is the central object in the face analysis
pipeline. It detects faces in images, stores their data
persistently in a working directory you choose, and clusters the faces
into groups called *entities*, where each entity represents a
distinct person.
The analyzer stores all face data and cluster assignments in the
directory you pass to ``FaceGroupAnalyzer/init(workingDirectory:)``.
This directory persists between app launches, so subsequent runs resume
from where the previous session ended. Call
``FaceGroupAnalyzer/purge(workingDirectory:)`` to remove all data from
the directory.
Use ``FaceGroupAnalyzer/identifyFaces(in:)`` to detect and match faces
in images without storing anything. This is useful for recognizing
people in new images against an existing gallery without modifying the
analyzer's data.
final func fetchFaces(in assetIDs: [MediaIntelligenceImageAsset.ID]) throws -> some AsyncSequence<(assetID: MediaIntelligenceImageAsset.ID, faces: Array<FaceGroupAnalyzer.Face>), any Error>
Returns the faces from the specified assets.
- Parameter assetIDs: The asset identifiers to look up.
- Returns: An async sequence of `(assetID, faces)` pairs.
final func fetchFaces(for entityIDs: [FaceGroupAnalyzer.Entity.ID]) throws -> some AsyncSequence<(entityID: FaceGroupAnalyzer.Entity.ID, faces: Array<FaceGroupAnalyzer.Face>), any Error>
Returns the faces belonging to the specified entities.
- Parameter entityIDs: The entity identifiers to look up.
- Returns: An async sequence of `(entityID, faces)` pairs.
final func fetchFaces(_ faceIDs: [FaceGroupAnalyzer.Face.ID]) throws -> some AsyncSequence<FaceGroupAnalyzer.Face, any Error>
Returns the faces with the specified identifiers.
- Parameter faceIDs: The face identifiers to look up.
- Returns: An async sequence of matching ``FaceGroupAnalyzer/Face``
values.
get · iOS 27.0+
allAssetIDs
TypeScript
get allAssetIDs(): SDKHandle
Swift declaration
final var allAssetIDs: some AsyncSequence<MediaIntelligenceImageAsset.ID, any Error> { get }
An async sequence of all asset identifiers in the analyzer.
get · iOS 27.0+
allEntities
TypeScript
get allEntities(): SDKHandle
Swift declaration
final var allEntities: some AsyncSequence<FaceGroupAnalyzer.Entity, any Error> { get }
An async sequence of all entities in the analyzer.
final func fetchAssetIDs(for entityIDs: [FaceGroupAnalyzer.Entity.ID]) throws -> some AsyncSequence<(entityID: FaceGroupAnalyzer.Entity.ID, assetIDs: Array<MediaIntelligenceImageAsset.ID>), any Error>
Returns the asset identifiers for the specified entities.
- Parameter entityIDs: The entity identifiers to look up.
- Returns: An async sequence of `(entityID, assetIDs)` pairs.
final nonisolated(nonsending) func identifyFaces(in assets: [MediaIntelligenceImageAsset]) async throws -> some AsyncSequence<(assetID: MediaIntelligenceImageAsset.ID, faces: Array<FaceGroupAnalyzer.Face>), any Error>
Detects and identifies faces without modifying the analyzer's data.
Use this method to recognize people in new images against the
existing gallery without storing any face data. Each returned face
has an ``FaceGroupAnalyzer/Face/entityID`` if the framework matched
it to a known entity, or `nil` if no match was found.
- Parameter assets: The image assets to analyze.
- Returns: An async sequence of `(assetID, faces)` pairs.
method · iOS 27.0+
deleteAllAssets
TypeScript
deleteAllAssets(): Promise<void>
Swift declaration
final nonisolated(nonsending) func deleteAllAssets() async throws
Removes all assets and their associated face data from the analyzer.
get · iOS 27.0+
workingDirectory
TypeScript
get workingDirectory(): string
Swift declaration
final let workingDirectory: URL
A directory where the analyzer stores its face data and metadata.
Creates a face group analyzer at the specified directory.
The analyzer loads any existing face data from `workingDirectory`
on initialization, so subsequent runs resume from where the
previous session ended.
- Parameter workingDirectory: The directory where the analyzer
stores its face data and metadata. The directory must already
exist.
get · iOS 27.0+
allFacesByEntityID
TypeScript
get allFacesByEntityID(): SDKHandle
Swift declaration
final var allFacesByEntityID: some AsyncSequence<(entityID: FaceGroupAnalyzer.Entity.ID, faces: Array<FaceGroupAnalyzer.Face>), any Error> { get }
An async sequence of all faces, grouped by entity.
final nonisolated(nonsending) func insertOrUpdateAssets(_ assets: [MediaIntelligenceImageAsset]) async throws -> some AsyncSequence<(assetID: MediaIntelligenceImageAsset.ID, faces: Array<FaceGroupAnalyzer.Face>), any Error>
Adds or replaces image assets in the analyzer.
For each asset, the method detects faces and extracts facial data,
then persists the results to the working directory. If an asset
with the same identifier already exists, the method replaces its
face data.
After this call, ``FaceGroupAnalyzer/state`` becomes
``FaceGroupAnalyzer/State/stale`` until you call
``FaceGroupAnalyzer/update(subprogress:)``. Faces detected in this
call have a `nil` ``FaceGroupAnalyzer/Face/entityID`` until
clustering runs.
- Parameter assets: The image assets to ingest.
- Returns: An async sequence of `(assetID, faces)` pairs — one per
asset — reporting the faces detected in each image.
get · iOS 27.0+
allAssetIDsByEntityID
TypeScript
get allAssetIDsByEntityID(): SDKHandle
Swift declaration
final var allAssetIDsByEntityID: some AsyncSequence<(entityID: FaceGroupAnalyzer.Entity.ID, assetIDs: Array<MediaIntelligenceImageAsset.ID>), any Error> { get }
An async sequence of all asset identifiers, grouped by entity.
Removes all analyzer data from the specified directory.
Call this method to permanently delete all face data, cluster
assignments, and metadata from `workingDirectory`. This operation
is irreversible.
- Parameter workingDirectory: The directory to purge.
get · iOS 27.0+
state
TypeScript
get state(): Promise<FaceGroupAnalyzer_State>
Swift declaration
nonisolated(nonsending) final var state: FaceGroupAnalyzer.State { get async }
A value describing the current processing state of the analyzer.
get · iOS 27.0+
allFaces
TypeScript
get allFaces(): SDKHandle
Swift declaration
final var allFaces: some AsyncSequence<FaceGroupAnalyzer.Face, any Error> { get }
An async sequence of all faces in the analyzer.
Skipped declarations
1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
FaceGroupAnalyzer.update(subprogress:)
The iOS SDK compiler rejected this binding: class 'OneSDKCall' requires that 'Subprogress' conform to 'Copyable'