Use get_data() to get the numpy array
image_ocv = image.get_data()
depth_map_np = depth_map.get_data()
# Convert the image to a format that Mediapipe can use
image = cv2.cvtColor(image_ocv, cv2.COLOR_BGR2RGB)
# Use the Mediapipe hand tracking module to detect the hand landmarks
results = hands.process(image)
keypoints_f=[]
keypoints_depth=[]
# Draw the hand landmarks on the image
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_landmarks:
mp_drawing.draw_landmarks(image, hand_landmarks, mp_hands.HAND_CONNECTIONS)
for landmark in hand_landmarks.landmark:
x, y = int(landmark.x * image.shape[1]), int(landmark.y * image.shape[0])
kpts=[x,y]
keypoints_f.append(kpts)
cv2.circle(image, (x, y), 5, (0, 255, 0), -1)
depth_value = depth_map_np[y][x]
print("Depth at ({},{}): {} meters".format(x, y, depth_value))
above shown is the code. I am using it to get the z-axis of hand coordinates got from mediapipe. I am getting the output as shown below:
Depth at (1609,804): [ 3.0693591e-01 1.2300891e-01 5.0059068e-01 -2.3553920e+38] meters
I need to understand what this value means and how I can get the exact z-axis for each hand landmark coordinate.