Hi I successfully saved the depth map to 32-bit binary file. Then I can read the file and convert it to png using python opencv. func convertDepthData(depthMap: CVPixelBuffer) -> [[Float32]] { let width = CVPixelBufferGetWidth(depthMap) let height = CVPixelBufferGetHeight(depthMap) var convertedDepthMap: [[Float32]] = Array( repeating: Array(repeating: 0, count: width), count: height ) CVPixelBufferLockBaseAddress(depthMap, CVPixelBufferLockFlags(rawValue: 2)) let floatBuffer = unsafeBitCast( CVPixelBufferGetBaseAddress(depthMap), to: UnsafeMutablePointer.self ) for row in 0 ..< height { for col in 0 ..< width { convertedDepthMap[row][col] = floatBuffer[width * row + col] } } CVPixelBufferUnlockBaseAddress(depthMap, CVPixelBufferLockFlags(rawValue: 2)) return convertedDepthMap } Then save it to app container. func saveFloat32ArrayToDocumentsDirectory(array: [[Float32]], fileName: String, folderName: String) -> URL? { let fileManager = FileManager.default let datasetDirectory = getDatasetDirectory(
Topic:
Spatial Computing
SubTopic:
ARKit
Tags: