您可以使用open3d 包轻松解决此问题。使用sudo pip install -U open3d-python 安装它(不仅仅是open3d——那是另一个包)。
安装后:
from open3d import *
rgbd = create_rgbd_image_from_color_and_depth(color, depth, convert_rgb_to_intensity = False)
pcd = create_point_cloud_from_rgbd_image(rgbd, pinhole_camera_intrinsic)
# flip the orientation, so it looks upright, not upside-down
pcd.transform([[1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,1]])
draw_geometries([pcd]) # visualize the point cloud
以上代码假设您在color 中拥有彩色图像,在depth 中拥有深度图像,请查看open3d 附带的示例以获取更多信息。
如果你有自己的相机,你可以用那些替换pinhole_camera_intrinsic,但是对于测试运行,针孔相机或多或少都可以正常工作。