iOS Developer Library

Developer

AVFoundation Framework Reference AVCaptureMetadataOutput Class Reference

Options
Deployment Target:

On This Page
Language:

AVCaptureMetadataOutput

Inherits From


Conforms To


Import Statement


Swift

import AVFoundation

Objective-C

@import AVFoundation;

Availability


Available in iOS 6.0 and later

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.

  • Sets the delegate and dispatch queue to use handle callbacks.

    Declaration

    Swift

    func setMetadataObjectsDelegate(_ objectsDelegate: AVCaptureMetadataOutputObjectsDelegate!, queue objectsCallbackQueue: dispatch_queue_t!)

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

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

    Declaration

    Swift

    var metadataObjectsDelegate: AVCaptureMetadataOutputObjectsDelegate! { get }

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

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

    Declaration

    Swift

    var metadataObjectsCallbackQueue: dispatch_queue_t! { get }

    Objective-C

    @property(nonatomic, readonly) dispatch_queue_t metadataObjectsCallbackQueue

    Discussion

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

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

    Declaration

    Swift

    var availableMetadataObjectTypes: [AnyObject]! { get }

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

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

    Declaration

    Swift

    var metadataObjectTypes: [AnyObject]!

    Objective-C

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

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 6.0 and later

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

    Declaration

    Swift

    var rectOfInterest: CGRect

    Objective-C

    @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).

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 7.0 and later