AVCaptureDepthDataOutput

AVCaptureDepthDataOutput

本文介绍了如何在 iOS 上获取相机校准数据?又名 AVCameraCalibrationData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,AVCameraCalibrationData 只能通过 AVCaptureDepthDataOutput 获得.对吗?

As I understand it, AVCameraCalibrationData is only available over AVCaptureDepthDataOutput. Is that correct?

另一方面,AVCaptureDepthDataOutput 只能通过 iPhone X 前摄像头或 iPhone Plus 后摄像头访问,还是我弄错了?

AVCaptureDepthDataOutput on the other hand is only accessible with iPhone X front cam or iPhone Plus back cam, or am I mistaken?

我想要做的是获取 AVCaptureVideoDataOutput SampleBuffer 的 FOV.特别是,它应该匹配所选的预设(全高清、照片等).

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

推荐答案

您只能从深度数据输出或照片输出中获取AVCameraCalibrationData.

You can get AVCameraCalibrationData only from depth data output or photo output.

但是,如果您只需要 FOV,则您只需要该类提供的部分信息 — 相机内在矩阵 — 您可以从 AVCaptureVideoDataOutput 中自行获取.

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.

  1. 设置 cameraIntrinsicMatrixDeliveryEnabled 在将您的相机设备连接到捕获会话的 AVCaptureConnection 上.(请注意,您应该先检查 cameraIntrinsicMatrixDeliverySupported; 并非所有捕获格式都支持内在函数.)

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

当视频输出提供样本缓冲区时,检查每个样本缓冲区的附件是否有 kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix 键.如 CMSampleBuffer.h 中所述(有人应该提交雷达关于获取此信息在线文档),该附件的值是编码 matrix_float3x3CFData,该矩阵的 (0,0) 和 (1,1) 元素是以像素为单位的水平和垂直焦距.

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.

这篇关于如何在 iOS 上获取相机校准数据?又名 AVCameraCalibrationData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:29