As I understand it, AVCameraCalibrationData is only available over AVCaptureDepthDataOutput. Is that correct?
AVCaptureDepthDataOutput on the other hand is only acce
Here is a more complete/updated code example in swift 5 that is put together from previous answers. This gets you the camera intrinsics matrix for an iphone.
based on:
// session setup
captureSession = AVCaptureSession()
let captureVideoDataOutput = AVCaptureVideoDataOutput()
captureSession?.addOutput(captureVideoDataOutput)
// enable the flag
if #available(iOS 11.0, *) {
captureVideoDataOutput.connection(with: .video)?.isCameraIntrinsicMatrixDeliveryEnabled = true
} else {
// ...
}
// `isCameraIntrinsicMatrixDeliveryEnabled` should be set before this
captureSession?.startRunning()
and now inside AVCaptureVideoDataOutputSampleBufferDelegate.captureOutput(...)
if #available(iOS 11.0, *) {
if let camData = CMGetAttachment(sampleBuffer, key:kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, attachmentModeOut:nil) as? Data {
let matrix: matrix_float3x3 = camData.withUnsafeBytes { $0.pointee }
print(matrix)
// > simd_float3x3(columns: (SIMD3(1599.8231, 0.0, 0.0), SIMD3(0.0, 1599.8231, 0.0), SIMD3(539.5, 959.5, 1.0)))
}
} else {
// ...
}