Open3D——RGBD图转化为点云(pcd)并显示

1. 用Open3D分别读取RGB图片和深度图片

      彩色图:    

      深度图:

2. 把Open3D中的RGBD图片转化pcd格式并储存

3. 显示点云

      

直接看代码:

# Open3D: www.open3d.org
# The MIT License (MIT)
# See license file or visit www.open3d.org for details

# examples/Python/Basic/rgbd_redwood.py

import open3d as o3d
import matplotlib.pyplot as plt

if __name__ == "__main__":
    print("Read Redwood dataset")
    color_raw = o3d.io.read_image("color.jpg")
    depth_raw = o3d.io.read_image("depth.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('grayscale image')
    plt.imshow(rgbd_image.color)
    plt.subplot(1, 2, 2)
    plt.title('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.io.write_point_cloud("test.pcd", pcd)
    o3d.visualization.draw_geometries([pcd])

end!

猜你喜欢

转载自blog.csdn.net/Guo_Python/article/details/106406871