As I understand it, AVCameraCalibrationData is only available over AVCaptureDepthDataOutput. Is that correct?
AVCaptureDepthDataOutput on the other hand is only accessible with iPhone X front cam or iPhone Plus back cam, or am I mistaken?
What I am trying to do is to get the FOV of an AVCaptureVideoDataOutput SampleBuffer. Especially, it should match the selected preset (full HD, Photo etc.).
You can get AVCameraCalibrationData
only from depth data output or photo output.
However, if all you need is FOV, you need only part of the info that class offers — the camera intrinsics matrix — and you can get that by itself from AVCaptureVideoDataOutput
.
Set cameraIntrinsicMatrixDeliveryEnabled
on the AVCaptureConnection
connecting your camera device to the capture session. (Note you should check cameraIntrinsicMatrixDeliverySupported
first; not all capture formats support intrinsics.)
When the video output vends sample buffers, check each sample buffer's attachments for the kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix
key. As noted in CMSampleBuffer.h
(someone should file a radar about getting this info into the online documentation), the value for that attachment is a CFData
encoding a matrix_float3x3
, and the (0,0) and (1,1) elements of that matrix are the horizontal and vertical focal length in pixels.