如何实时获取每帧iPhone的相机镜头中心到成像平面的距离?

how to get the distance between iPhone's camera lens center and imaging plane in real time for each frame?

我正在使用 AVFoundation 框架在连续 AF 模式下获取每一帧。因此根据某些自动对焦算法,镜头和成像平面之间的距离是动态的。由于某些原因,我必须计算距离。是否可以通过使用 AVFoundation API?

来获取距离

Pre-iOS 11,我认为这样的事情不存在。但是,如果您只需要定位 iOS 11 及以上,您可以查看 AVDepthData class.

官方文档here.

请注意,如 rckoenes 所述,这仅适用于兼容设备(带双摄像头)。