Capture several photos at once, varying parameters like exposure duration or light sensitivity.
Bracketing is a well-known photographic technique in which a sequence of shots is rapidly taken of the same scene, usually varying only in a single parameter such as aperture or shutter speed (exposure length). Experienced photographers use this technique to help them choose the best photos after shooting, or to apply offline post-processing that fuses multiple images together to create extended dynamic range or other special effects.
In iOS, you can use
AVCapture to automatically capture a bracket of photos for each
capture call. Once you've built a single-exposure camera in your app (see Capturing Still and Live Photos), follow these steps to add multi-image bracket support.
Choose Bracket Settings
You specify a multi-exposure bracket by providing an array of bracket settings obejcts. iOS offers two types of automatic bracketing:
AVCaptureto create a bracket that varies exposure-compensation values relative to automatic exposure.
Auto Exposure Bracketed Still Image Settings
AVCaptureto create a bracket with custom exposure durations and ISO sensitivity values for each photo in the bracket.
Manual Exposure Bracketed Still Image Settings
To define a bracket, create an array of one of these types, with values that describe the settings variations you want to capture. For example, the code below defines a bracket that captures three images at three different exposure values.
Create Photo Settings and Shoot
Instead of the
AVCapture object you create when shooting a single photo, to shoot a bracketed capture you'll need an
AVCapture object. This object combines the general settings that apply to all photos in the bracket with your bracket settings that specify how each photo differs from the rest of the bracket.
As with single-image capture, you create a photo settings object by choosing the image codec and file format for the resulting photos, but you also provide the bracket settings you've chosen.
Handle Bracketed Capture Results
The photo output calls your delegate's
capture method at least once for each exposure in the bracket, and possibly additional times depending on your capture settings. For example, if you request RAW+HEIF capture in a three-exposure bracket, the photo output calls your delegate's
did method six times (2 formats × 3 exposures), providing six
To keep track of multiple results, compare the
photo from each photo to the
expected of your resolved settings. When those numbers are equal, you've received all results from the capture.