I am working with a project on iOS front depth camera with swift. The media type is kCVPixelFormatType_DepthFloat16, half-point float at 640*360 dimension with 30fps according to apple documentation. I was stuck in how to further retrieve and process the value pixel by pixel.
let buffer:CVPixelBuffer = depthData.depthDataMap //depthData is AVDepthData type
CVPixelBufferLockBaseAddress(buffer, CVPixelBufferLockFlags(rawValue: 0))
let width = CVPixelBufferGetWidth(buffer)
let height = CVPixelBufferGetHeight(buffer)
for y in 0 ..< height {
for x in 0 ..< width {
let pixel = ?? //what should I do here?
}
}