如何在iOS上获取相机校准数据?又名AVCameraCalibrationData [英] How can I get Camera Calibration Data on iOS? aka 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
.
-
在
cameraIntrinsicMatrixDeliveryEnabled
>将相机设备连接到捕获会话. (请注意,您应该首先检查cameraIntrinsicMatrixDeliverySupported
;并非所有捕获格式支持内在函数.)
Set
cameraIntrinsicMatrixDeliveryEnabled
on theAVCaptureConnection
connecting your camera device to the capture session. (Note you should checkcameraIntrinsicMatrixDeliverySupported
first; not all capture formats support intrinsics.)
当视频输出出售示例缓冲区时,请检查每个示例缓冲区的附件中的kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix
键.如CMSampleBuffer.h
中所述(有人应提交雷达关于将此信息纳入在线文档),该值对于该附件,是一个CFData
编码为matrix_float3x3
,并且该矩阵的(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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!