Hi,
I'm working with same sample Capturing Depth Using the LiDAR Camera.
Long distance is ok, but when its < 1 meter, data is not accurate. What is the recommendation to measure distance from 0.2 meter to 1 meter.
Here is code:
let depthData = syncedDepthData.depthData.converting(toDepthDataType: kCVPixelFormatType_DepthFloat16)
let depthMapWidth = CVPixelBufferGetWidthOfPlane(depthData.depthDataMap, 0)
let depthMapHeight = CVPixelBufferGetHeightOfPlane(depthData.depthDataMap, 0)
let centerX = depthMapWidth / 2
let centerY = depthMapHeight / 2
print("Depth value at the center (x,y): \(centerX) \(centerY)")
CVPixelBufferLockBaseAddress(depthData.depthDataMap, .readOnly)
if let rowData = CVPixelBufferGetBaseAddress(depthData.depthDataMap)?.assumingMemoryBound(to: Float16.self) {
let depthPoint = rowData[centerY * depthMapWidth + centerX]
let depthPoint1 = rowData[centerY * depthMapWidth + centerX + 10]
let depthPoint2 = rowData[centerY * depthMapWidth + centerX + 100]
print("Depth value at the center in meters: \(depthPoint) \(depthPoint1) \(depthPoint2) meters")
}
CVPixelBufferUnlockBaseAddress(depthData.depthDataMap, .readOnly)