单目深度估计与伪雷达点云可视化
Posted 踟蹰横渡口,彳亍上滩舟。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了单目深度估计与伪雷达点云可视化相关的知识,希望对你有一定的参考价值。
单目深度估计
项目代码下载地址:下载地址
深度图转点云:
def depth2ptc_universal(depth, intrinsics):
"""
depth: depth img ie. [384, 640]
intrinsics: []
"""
vu = np.indices(depth.shape).reshape(2, -1).T
vu[:, 0], vu[:, 1] = vu[:, 1], vu[:, 0].copy()
uv = vu
uv_depth = np.column_stack((uv.astype(float), depth.reshape(-1)))
cx, cy, fx, fy = intrinsics
n = uv_depth.shape[0]
x = ((uv_depth[:, 0]-cx)*uv_depth[:, 2])/fx + 0
y = ((uv_depth[:, 1]-cy)*uv_depth[:, 2])/fy + 0
pts_3d_rect = np.zeros((n, 3))
pts_3d_rect[:, 0] = x
pts_3d_rect[:, 1] = y
pts_3d_rect[:, 2] = uv_depth[:, 2]
return pts_3d_rect
点云可视化:
ptc = np.array(ptc).astype(np.float32)
point_cloud = o3d.geometry.PointCloud()
point_cloud.points = o3d.utility.Vector3dVector(ptc)
# point_cloud.colors = o3d.utility.Vector3dVector(img.reshape(-1, 3)[indices][:, ::-1]/255)
point_cloud.transform(
[[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
o3d.visualization.draw_geometries([point_cloud])
以上是关于单目深度估计与伪雷达点云可视化的主要内容,如果未能解决你的问题,请参考以下文章