AVCaptureMetadataOutput Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AVFoundation.framework
Availability
Available in iOS 6.0 and later.
Declared in
AVCaptureOutput.h

Overview

An AVCaptureMetadataOutput object intercepts metadata objects emitted by its associated capture connection and forwards them to a delegate object for processing. You can use instances of this class to process specific types of metadata included with the input data. You use this class the way you do other output objects, typically by adding it as an output to an AVCaptureSession object.

Tasks

Accessing the Delegate and Callback Queue

Accessing the Metadata Items

Properties

availableMetadataObjectTypes

An array of strings identifying the types of metadata objects that can be captured. (read-only)

@property(nonatomic, readonly) NSArray *availableMetadataObjectTypes
Discussion

Each string in the array corresponds to a possible value in the type property of the AVMetadataObject objects reported by the receiver. The available types are dependent on the capabilities of the AVCaptureInputPort to which the receiver’s connection is attached.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVCaptureOutput.h

metadataObjectsCallbackQueue

The dispatch queue on which to execute the delegate’s methods. (read-only)

@property(nonatomic, readonly) dispatch_queue_t metadataObjectsCallbackQueue
Discussion

To set the dispatch queue, you must use the setMetadataObjectsDelegate:queue: method.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVCaptureOutput.h

metadataObjectsDelegate

The delegate of the capture metadata output object. (read-only)

@property(nonatomic, readonly) id<AVCaptureMetadataOutputObjectsDelegate> metadataObjectsDelegate
Discussion

The delegate object must conform to the AVCaptureMetadataOutputObjectsDelegate protocol. The object in this property is used to process all metadata objects captured from the capture metadata output object’s connection.

To set the delegate object, you must use the setMetadataObjectsDelegate:queue: method.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVCaptureOutput.h

metadataObjectTypes

An array of strings identifying the types of metadata objects to process.

@property(nonatomic, copy) NSArray *metadataObjectTypes
Discussion

This property is used to filter the metadata objects reported by the receiver. Only metadata objects whose type matches one of the strings in this property are forwarded to the delegate’s captureOutput:didOutputMetadataObjects:fromConnection: method for processing.

When assigning a new array to this property, each of the type strings must be present in the array returned by the availableMetadataObjectTypes property; otherwise, the receiver raises anNSException.

The default is an empty NSArray object, and as a result, no metadata objects are forwarded to the delegate’s captureOutput:didOutputMetadataObjects:fromConnection: method. The same result can be achieved by setting the property to nil. This default behavior maximizes both performance and battery life.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVCaptureOutput.h

rectOfInterest

A rectangle of interest for limiting the search area for visual metadata.

@property(nonatomic) CGRect rectOfInterest
Discussion

The value of this property is a CGRect value that determines the object’s rectangle of interest for each frame of video.

The rectangle's origin is top left and is relative to the coordinate space of the device providing the metadata.

Specifying a rectangle of interest may improve detection performance for certain types of metadata. Metadata objects whose bounds do not intersect with the rectOfInterest will not be returned.

The default value of this property is a rectangle of (0.0, 0.0, 1.0, 1.0).

Availability
  • Available in iOS 7.0 and later.
Declared In
AVCaptureOutput.h

Instance Methods

setMetadataObjectsDelegate:queue:

Sets the delegate and dispatch queue to use handle callbacks.

- (void)setMetadataObjectsDelegate:(id<AVCaptureMetadataOutputObjectsDelegate>)objectsDelegate queue:(dispatch_queue_t)objectsCallbackQueue
Parameters
objectsDelegate

The delegate object to notify when new metadata objects become available. This object must conform to the AVCaptureMetadataOutputObjectsDelegate protocol.

objectsCallbackQueue

The dispatch queue on which to execute the delegate’s methods. This queue must be a serial queue to ensure that metadata objects are delivered in the order in which they were received. If the objectsDelegate parameter is nil, you may specify nil for this parameter too; otherwise, you must specify a valid dispatch queue.

Discussion

When new metadata objects are captured from the receiver’s connection, they are vended to the delegate object. All delegate methods are executed on the dispatch queue specified in the objectsCallbackQueue parameter. To ensure that metadata objects are processed in a timely manner and not dropped, you should specify a dispatch queue dedicated to processing the objects or that is otherwise not busy.

Availability
  • Available in iOS 6.0 and later.
Declared In
AVCaptureOutput.h