How to get an aligned depth map from the grid?
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
My ultimate goal is to get a depth map aligned with the color map from the grid. Among them, the internal and external parameters of the camera are known. When I calculate directly, the position is correct, but when I use open3d to get the depth map, I cannot get the depth map at the correct position. What do I need to do?
In addition, I would like to ask, why setting the line of "init_param.extrinsic = np.diag((1, -1, -1, 1)) @ extrin" does not work, but must transform the grid "mesh.transform(extrin)"?
This is the result obtained through open3d:
`
def draw_geometries(mesh, width, height, intrin, extrin):
pose = np.diag((1, -1, -1, 1)) @ extrin
mesh.transform(pose)
vis = o3d.visualization.Visualizer()
vis.create_window(width= width, height=height)
vis.add_geometry(mesh)
vis.get_render_option().mesh_show_back_face = True
ctr = vis.get_view_control()
init_param = ctr.convert_to_pinhole_camera_parameters()
init_param.intrinsic = o3d.camera.PinholeCameraIntrinsic(
width= width, height=height, fx=intrin[0, 0], fy=intrin[1, 1], cx=intrin[0, 2], cy=intrin[1, 2]
)
# init_param.extrinsic = pose
ctr.convert_from_pinhole_camera_parameters(init_param)
ctr.set_zoom(1.0)
vis.run()
depth = vis.capture_depth_float_buffer()
vis.destroy_window()
return np.asarray(depth)
`


This is the result of direct calculation:
`
def project_points3d_to_2d(points3d, intrin, extrin):
points3d = np.array(points3d)
P = np.hstack((points3d, np.ones((points3d.shape[0], 1)))).T
points3d_ = intrin @ extrin @ P
#points3d_ = points3d_ / points3d_[2]
points2d = points3d_[:2, :] / points3d_[2]
points2d = points2d.T
return points2d
`


Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.