Instance Method

metadataOutputRectConverted(fromLayerRect:)

Converts a rectangle in the preview layer’s coordinate system to one in the coordinate system used for metadata outputs.

Declaration

func metadataOutputRectConverted(fromLayerRect rectInLayerCoordinates: CGRect) -> CGRect

Parameters

rectInLayerCoordinates

A rectangle in the AVCaptureVideoPreviewLayer object’s coordinate system.

Return Value

A rectangle in the AVCaptureMetadataOutput coordinate system.

Discussion

The rectangle of interest for an AVCaptureMetadataOutput object is in a coordinate system extending from (0,0) in the top-left to (1,1) in the bottom-right, relative to the device’s natural orientation. A capture output object uses a pixel coordinate space which may be zoomed, rotated, or mirrored. Use this convenience method to quickly convert between coordinate spaces.

See Also

Converting Between Coordinate Systems

func captureDevicePointConverted(fromLayerPoint: CGPoint) -> CGPoint

Converts a point from layer coordinates to the coordinate space of the capture device.

func layerPointConverted(fromCaptureDevicePoint: CGPoint) -> CGPoint

Converts a point from the coordinate space of the capture device to the coordinate space of the layer.

func layerRectConverted(fromMetadataOutputRect: CGRect) -> CGRect

Converts a rectangle in the coordinate system used for metadata outputs to one in the preview layer’s coordinate system.

func transformedMetadataObject(for: AVMetadataObject) -> AVMetadataObject?

Converts a metadata object’s visual properties to layer coordinates.