AVCaptureStillImageOutput Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in OS X v10.7 and later.
Companion guide
Declared in
AVCaptureOutput.h
Related sample code

Overview

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

Tasks

Capturing an Image

Image Configuration

Image Format Conversion

Properties

availableImageDataCodecTypes

The supported image codec formats that can be specified in outputSettings. (read-only)

@property(nonatomic, readonly) NSArray *availableImageDataCodecTypes
Discussion

The value of this property is an array of NSString objects that you can use as values for the AVVideoCodecKey in the outputSettings property.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

availableImageDataCVPixelFormatTypes

The supported image pixel formats that can be specified in outputSettings. (read-only)

@property(nonatomic, readonly) NSArray *availableImageDataCVPixelFormatTypes
Discussion

The value of this property is an array of NSNumber objects that you can use as values for the kCVPixelBufferPixelFormatTypeKey in the outputSettings property.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

outputSettings

The compression settings for the output.

@property(nonatomic, copy) NSDictionary *outputSettings
Discussion

You specify the compression settings using keys from AVVideoSettings.h, or a dictionary of pixel buffer attributes using keys from CVPixelBuffer.h.

Currently the only supported keys are AVVideoCodecKey and kCVPixelBufferPixelFormatTypeKey. The recommended values are kCMVideoCodecType_JPEG, kCVPixelFormatType_420YpCbCr8BiPlanarFullRange and kCVPixelFormatType_32BGRA.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

Class Methods

jpegStillImageNSDataRepresentation:

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

+ (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.

Availability
  • Available in OS X v10.7 and later.
Declared In
AVCaptureOutput.h

Instance Methods

captureStillImageAsynchronouslyFromConnection:completionHandler:

Initiates a still image capture and returns immediately.

- (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.

Availability
  • Available in OS X v10.7 and later.
Related Sample Code
Declared In
AVCaptureOutput.h

Did this document help you? Yes It's good, but... Not helpful...