0

我在 c++ 中看到了大量关于如何将 3d 点云转换为深度图的 opencv 代码,带有相机内在函数(矩阵和宽度、高度、fx、fy、cx 和 cy),但我没有看到任何关于使用 python 将点云转换为深度图的代码。我试过使用open3d,它在从深度图像转换为点云时效果很好,但是当从点云转换为深度图时,我得到一个随机缩放的热图,所以当我从深度图重新导入到open3d中的点云,深度图不正确(因为我必须从热图转换为深度图),并且深度图与rgb图像不对齐。这是我在 open3d 中将 rgb 和深度图转换为 open3d 中的点云的代码?

intrinsics = o3d.camera.PinholeCameraIntrinsic(640, 480 ,525.0, 525.0, 319.5, 239.5) 
'''
width (int) – Width of the image.

height (int) – Height of the image.

fx (float) – X-axis focal length

fy (float) – Y-axis focal length.

cx (float) – X-axis principle point.

cy (float) – Y-axis principle point.
'''
depth_raw = o3d.io.read_image("./00000.png")
color_raw = o3d.io.read_image("./color.jpg")
rgbd_image = create_rgbd_image_from_color_and_depth(
    color_raw, depth_raw)

pcd =  o3d.geometry.create_point_cloud_from_rgbd_image(rgbd_image, o3d.camera.PinholeCameraIntrinsic(intrinsics))
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]) # flips to it is right side up
o3d.visualization.draw_geometries([pcd])
np.savetxt("./pcd.txt", np.asarray(pcd.points))

有人可以帮助我用代码将点云投影到深度图、python、opencv 或任何其他库中。

4

0 回答 0