代码比较合理
import cv2
import numpy as np
import open3d as o3d
# 读取深度图像
depth_path = '/media/kj/2B9747BF3C0EC4D0/Project/RTG-SLAM-Test/data/Ours100ai/hotel/depth/0000.png'
depth_image = cv2.imread(depth_path, cv2.IMREAD_UNCHANGED)
print(f"深度图最小值: {depth_image.min()}")
print(f"深度图最大值: {depth_image.max()}")
depth_image_float = depth_image.astype(np.float32)
depth_o3d = o3d.geometry.Image(depth_image_float)
w = depth_image.shape[1]
h = depth_image.shape[0]
fx = 605.3711
fy = 605.2457
cx = 335.3086
cy = 366.51
intrinsic = o3d.camera.PinholeCameraIntrinsic(w, h, fx, fy, cx, cy)
point_cloud = o3d.geometry.PointCloud.create_from_depth_image(
depth_o3d, intrinsic
)
o3d.visualization.draw_geometries([point_cloud])