depth-data
Overview
The most important thing while using 3D cameras is to get the depth value. This demo shows how to get the depth data from camera frame. Move the mouse in an OpenCV window and obtain the depth value of the mouse cursor position.
Expect Output

Prerequisite
Tutorial
By adding mouse callback function on OpenCV window, we can get the (x,y) coordinate when mouse move over the window.
def onMouseMove(event, x, y, flags, param):
global depthMat
if event == cv2.EVENT_MOUSEMOVE and depthMat is not None:
depth_value = depthMat[y, x]
print(f"Depth value at ({x},{y}) = {depth_value}")
After converting depthFrame to numpy format, we can retrieve the the data directly.
depth_value = depthMat[y, x]
Full code
Last updated