我正在尝试AVDepthData根据以下方程估计对象的绝对深度(以米为单位):depth = baseline x focus_length / (disparity + d_offset)。我有来自 的所有参数cameraCalibrationData,但是这是否仍然适用于使用 iPhone X 在人像模式下拍摄的图像,因为两个摄像头垂直偏移?同样基于WWDC 2017 Session 507,视差图是相对的,但AVDepthData文档指出视差值在 1/m 中。那么我可以按原样将方程应用于深度数据中的值,还是需要事先进行一些额外的处理?
var depthData: AVDepthData
do {
depthData = try AVDepthData(fromDictionaryRepresentation: auxDataInfo)
} catch {
return nil
}
// Working with disparity
if depthData.depthDataType != kCVPixelFormatType_DisparityFloat32 {
depthData = depthData.converting(toDepthDataType: kCVPixelFormatType_DisparityFloat32)
}
CVPixelBufferLockBaseAddress(depthData.depthDataMap, CVPixelBufferLockFlags(rawValue: 0))
// Scale Intrinsic matrix to be in depth image pixel space
guard var intrinsicMatrix = depthData.cameraCalibrationData?.intrinsicMatrix …Run Code Online (Sandbox Code Playgroud)