如何在open3d中计算物体的高度

2024-09-28 20:52:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我想计算椅子相对于地面的高度,但我对这个问题没有任何指导

import open3d as o3d
import matplotlib.pyplot as plt

if __name__ == "__main__":
   print("Read Redwood dataset")
   color_raw = o3d.io.read_image("../../TestData/RGBD/color/00000.jpg")
   depth_raw = o3d.io.read_image("../../TestData/RGBD/depth/00000.png")
   rgbd_image = o3d.geometry.create_rgbd_image_from_color_and_depth(
   color_raw, depth_raw)
   print(rgbd_image)

plt.subplot(1, 2, 1)
plt.title('Redwood grayscale image')
plt.imshow(rgbd_image.color)
plt.subplot(1, 2, 2)
plt.title('Redwood depth image')
plt.imshow(rgbd_image.depth)
plt.show()

pcd = o3d.geometry.create_point_cloud_from_rgbd_image(
    rgbd_image,
    o3d.camera.PinholeCameraIntrinsic(
        o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault))
# Flip it, otherwise the pointcloud will be upside down
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
o3d.visualization.draw_geometries([pcd])

Tags: ioimageimportreadrawaspltcolor