I'm trying to obtain the intrinsic matrix for each video frame of AVCaptureSession (the same intrisic matrix as ARKit provides), however the isCameraIntrinsicMatrixDeliverySupported property of AVCaptureConnection is false in my use-case.
The documentation of the property says "This property's value is
true
only if both the connection's input device format and output class support delivery of camera intrinsics."How do I know which device formats support delivery of intrinsic matrix? What do I need to do to be able to enable the intrinsic matrix delivery?
Simple code to illustrate my problem:
import UIKit
import AVFoundation
class ViewController: UIViewController {
var sess: AVCaptureSession!
var sessOut: AVCaptureVideoDataOutput!
var prevLayer: AVCaptureVideoPreviewLayer!
override func viewDidLoad() {
super.viewDidLoad()
sess = AVCaptureSession()
let device = AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back)
let input = try! AVCaptureDeviceInput(device: device!)
sess.addInput(input)
sessOut = AVCaptureVideoDataOutput()
sess.addOutput(sessOut)
sessOut.connections.first?.videoOrientation = .landscapeRight
sessOut.connections.first?.preferredVideoStabilizationMode = .cinematic
print(sessOut.connections.first?.isCameraIntrinsicMatrixDeliverySupported) // <-- false - why?
prevLayer = AVCaptureVideoPreviewLayer(session: sess)
prevLayer.frame = self.view.frame
prevLayer.videoGravity = .resizeAspectFill
prevLayer.connection?.videoOrientation = .landscapeRight
self.view.layer.addSublayer(prevLayer)
sess.startRunning()
}
}