Class

AVCapturePhotoBracketSettings

A specification of the features and settings to use for a photo capture request that captures multiple images with varied settings.

Declaration

class AVCapturePhotoBracketSettings : AVCapturePhotoSettings

Overview

To take a bracketed capture, you create and configure an AVCapturePhotoBracketSettings object, using AVCaptureBracketedStillImageSettings objects to describe the individual captures in the bracket, and then pass it to the AVCapturePhotoOutput capturePhoto(with:delegate:) method.

To request a bracketed capture, follow these steps:

  1. Create an array of AVCaptureBracketedStillImageSettings objects describing the number of images to capture in the bracket and the variations on capture settings between them.

  2. Create a bracketed photo settings object with the init(format:rawPixelFormatType:bracketedSettings:) initializer, passing the array of bracketed still image settings, along with the processed format (such as JPEG) or RAW format to capture images in.

  3. Configure other settings to share across all images in the bracket, such as the isLensStabilizationEnabled property and certain inherited properties.

  4. Initiate capture by passing the bracketed photo settings object to your photo output’s capturePhoto(with:delegate:) method, along with a delegate object to receive messages about the progress and results of the capture.

  5. The photo output calls your delegate’s photoOutput(_:didFinishProcessingPhoto:previewPhoto:resolvedSettings:bracketSettings:error:) or photoOutput(_:didFinishProcessingRawPhoto:previewPhoto:resolvedSettings:bracketSettings:error:) methods many times corresponding to the number of captures in the bracket. Each call provides the AVCaptureBracketedStillImageSettings object indicating which capture in the bracket the captured image corresponds to.

Listing 1 illustrates capturing a bracket of three RAW images with varying exposure value settings.

Listing 1

Capturing a Multi-Exposure Bracket

func captureRAWAutoExposureBracket() {
    guard myCapturePhotoOutput.maxBracketedCapturePhotoCount >= 3 else { return }
    
    // Specify a 3-shot bracket, where exposure compensation varies between each shot.
    let makeSettings = AVCaptureAutoExposureBracketedStillImageSettings.autoExposureSettingsWithExposureTargetBias
    let bracketedStillImageSettings = [-2, 0, 2].map { makeSettings(Float($0))! }
    let rawFormat = myCapturePhotoOutput.availableRawPhotoCVPixelFormatTypes.first!.unsignedIntValue as OSType
    
    let settings = AVCapturePhotoBracketSettings(format: nil, rawPixelFormatType: rawFormat, bracketedSettings: bracketedStillImageSettings)
    settings.lensStabilizationEnabled = myCapturePhotoOutput.lensStabilizationDuringBracketedCaptureSupported
    
    myCapturePhotoOutput.capturePhotoWithSettings(settings, delegate: self)
    // Three RAW photos will be delivered.
}

Topics

Creating a Bracket Settings Object

Working with Bracketed Settings

var bracketedSettings: [AVCaptureBracketedStillImageSettings]

An array describing the number of and settings for images to produce in a bracketed capture.

var isLensStabilizationEnabled: Bool

A Boolean value that specifies whether to stabilize the lens for the duration of the bracketed capture.

Bracketed Settings Types

class AVCaptureAutoExposureBracketedStillImageSettings

A configuration for defining bracketed photo captures in terms of bias relative to automatic exposure.

class AVCaptureManualExposureBracketedStillImageSettings

A configuration for defining bracketed photo captures in terms of specific exposure and ISO values.

class AVCaptureBracketedStillImageSettings

The abstract superclass for bracketed photo capture settings.

Relationships

Conforms To

See Also

Capturing a Photo

class AVCapturePhotoSettings

A specification of the features and settings to use for a single photo capture request.

class AVCaptureResolvedPhotoSettings

A description of the features and settings in use for an in-progress or complete photo capture request.