How can i get the real 3D(x,y,z) from depth? it looks not the real point which need to compute

image

import cv2
import numpy as np

定义合并图像的文件路径

combined_image_path = r"C:\Users\2544020\Documents\ZED\DepthViewer_SbS_30277357_1080_26-07-2024-19-46-05.png"
depth_image_path = r"C:\Users\2544020\Documents\ZED\depth_PNG_30277357_1080_26-07-2024-19-46-09.png"

读取合并图像

combined_image = cv2.imread(combined_image_path, cv2.IMREAD_COLOR)
if combined_image is None:
print(“无法读取合并图像。请检查文件路径。”)
else:
# 获取合并图像的高度和宽度
height, width, channels = combined_image.shape

# 假设左右图像是水平拼接的,因此每个图像的宽度为总宽度的一半
half_width = width // 2

# 裁剪左图像
left_image = combined_image[:, :half_width]

# 裁剪右图像
right_image = combined_image[:, half_width:]

# 显示裁剪后的图像以验证
cv2.imshow("Left Image", left_image)
cv2.imshow("Right Image", right_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 保存裁剪后的图像(可选)
cv2.imwrite("left_image.png", left_image)
cv2.imwrite("right_image.png", right_image)

# 读取深度图像(假设深度图像保存为单通道 16 位图像)
depth_image = cv2.imread(depth_image_path, cv2.IMREAD_UNCHANGED)
if depth_image is None:
    print("无法读取深度图像。请检查文件路径。")
print(depth_image[100:200])
cv2.imshow("Depth Image", depth_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

Hi @Hua2544,

Please follow this FAQ post in order to transform the depth image into XYZ coordinates: