iOS Developer Library

Developer

AVFoundation Framework Reference AVCaptureStillImageOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVCaptureStillImageOutput

Inheritance


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 4.0 and later.

AVCaptureStillImageOutput is a concrete sub class of AVCaptureOutput that you use to capture a high-quality still image with accompanying metadata.

In iOS 8.0 and later support for still image bracketed capture has been added. A "still image bracket" is a batch of images taken as quickly as possible in succession, optionally with different settings from picture to picture.

In a bracketed capture, AVCaptureDevice instance’s flashMode property is ignored (flash is forced off), as is the automaticallyEnablesStillImageStabilizationWhenAvailable property (stabilization is forced off).

  • Initiates a still image capture and returns immediately.

    Declaration

    Swift

    func captureStillImageAsynchronouslyFromConnection(_ connection: AVCaptureConnection!, completionHandler handler: ((CMSampleBuffer!, NSError!) -> Void)!)

    Objective-C

    - (void)captureStillImageAsynchronouslyFromConnection:(AVCaptureConnection *)connection completionHandler:(void (^)(CMSampleBufferRef imageDataSampleBuffer, NSError *error))handler

    Parameters

    connection

    The connection from which to capture the image.

    handler

    A block to invoke after the image has been captured. The block parameters are as follows:

    imageDataSampleBuffer

    The data that was captured.

    The buffer attachments may contain metadata appropriate to the image data format. For example, a buffer containing JPEG data may carry a kCGImagePropertyExifDictionary as an attachment. See ImageIO/CGImageProperties.h for a list of keys and value types.

    error

    If the request could not be completed, an NSError object that describes the problem; otherwise nil.

    Discussion

    This method returns immediately after it is invoked, later calling the provided completion handler block when image data is ready. If the request could not be completed, the error parameter will contain an NSError object describing the failure.

    You should not assume that the completion handler will be called on a specific thread.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Indicates whether a still image is being captured. (read-only)

    Declaration

    Swift

    var capturingStillImage: Bool { get }

    Objective-C

    @property(readonly, getter=isCapturingStillImage) BOOL capturingStillImage

    Discussion

    The value of this property is YEStrue when a still image is being captured, and NOfalse when no still image capture is underway.

    This property supports key-value observing.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 5.0 and later.

  • Indicates whether still image stabilization is in use for the current capture. (read-only)

    Declaration

    Swift

    var stillImageStabilizationActive: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isStillImageStabilizationActive) BOOL stillImageStabilizationActive

    Discussion

    The property returns YEStrue if video stabilization is currently in use; otherwise NOfalse.

    This property supports key-value observing.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • A Boolean value that indicates whether still image stabilization should be automatically enabled.

    Declaration

    Swift

    var automaticallyEnablesStillImageStabilizationWhenAvailable: Bool

    Objective-C

    @property(nonatomic) BOOL automaticallyEnablesStillImageStabilizationWhenAvailable

    Discussion

    If stillImageStabilizationSupported returns YEStrue, image stabilization may be applied to reduce blur commonly found in low light photos. When stabilization is enabled, still image captures incur additional latency.

    The default value is YEStrue when supported by the input device; otherwise NOfalse.

    Setting this property throws an exception (NSInvalidArgumentException) if stillImageStabilizationSupported returns NOfalse.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • A Boolean value that indicates whether the still image currently being captured supports still image stabilization. (read-only)

    Declaration

    Swift

    var stillImageStabilizationSupported: Bool { get }

    Objective-C

    @property(nonatomic, readonly, getter=isStillImageStabilizationSupported) BOOL stillImageStabilizationSupported

    Discussion

    The automaticallyEnablesStillImageStabilizationWhenAvailable property can only be set if this property returns YEStrue.

    The value may change as the session's sessionPreset or the input device's activeFormat changes.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later.

  • Returns an NSData representation of a still image data and metadata attachments in a JPEG sample buffer.

    Declaration

    Swift

    class func jpegStillImageNSDataRepresentation(_ jpegSampleBuffer: CMSampleBuffer!) -> NSData!

    Objective-C

    + (NSData *)jpegStillImageNSDataRepresentation:(CMSampleBufferRef)jpegSampleBuffer

    Parameters

    jpegSampleBuffer

    The sample buffer carrying JPEG image data, optionally with Exif metadata sample buffer attachments.

    This method throws an NSInvalidArgumentException if jpegSampleBuffer is NULL or not in the JPEG format.

    Return Value

    An NSData representation of jpegSampleBuffer.

    Discussion

    This method merges the image data and Exif metadata sample buffer attachments without re-compressing the image.

    The returned NSData object is suitable for writing to disk.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.