Usage of Touch Gesture to acquire DepthData of a specific point using LiDAR

Hello!

The Aim of my project is as specified in the title and the code I am currently trying to modify uses CVPixelBufferGetBaseAddress to acquire the DepthData using LiDAR.

For some context, I made use of the available "Capturing depth using the LiDAR camera" Documentation using AVFoundation and edited code after referring a few Q&A on Developer Forums.

I have a few doubts and would be grateful if I could get insights or a push in the right direction.

  1. Regarding the LiDAR DepthData: Where is the Origin(0,0) and In what order is it saved? (Basically, how do the row and column correspond to the real world scenario)
  2. How do I add a touch gesture to fill in the values of X&Y for "distanceAtXYPoint" so that I can acquire the Depth data on user touch input rather than in real-time.

The function for reference :

//new function to show the depth data value in meters
func depthDataOutput(syncedDepthData: AVCaptureSynchronizedDepthData) {
    let depthData = syncedDepthData.depthData.converting(toDepthDataType: kCVPixelFormatType_DepthFloat16)
    let depthMapWidth = CVPixelBufferGetWidthOfPlane(depthData.depthDataMap, 0)
    let depthMapHeight = CVPixelBufferGetHeightOfPlane(depthData.depthDataMap, 0)
    CVPixelBufferLockBaseAddress(depthData.depthDataMap, .readOnly)
    if let rowData = CVPixelBufferGetBaseAddress(depthData.depthDataMap)?.assumingMemoryBound(to: Float16.self) {
        //need to find a way to get the specific depthpoint (using row data) on touch gesture.
        //currently use the depth point when row&column = 0
        let depthPoint = rowData[0]
        for y in 0...depthMapHeight-1 {
            var distancesLine = [Float16]()
            for x in 0...depthMapWidth-1 {
                let distanceAtXYPoint = rowData[y * depthMapWidth + x]
            }
        }
        print("⭐️Depth value of (0,0) point in meters: \(depthPoint)")
    }
    CVPixelBufferUnlockBaseAddress(depthData.depthDataMap, .readOnly)
}

The current real-time console log output is as shown below

Also a slight concern is that the current output at (0,0) shows a value greater than 1m at times even when the real distance is probably a few cm.

Any experience and countermeasures on this also would be greatly helpful.

Thanks in advance.