isl-org / isl-org/Open3D

How to get an aligned depth map from the grid?

Open
#4,079 0 comments 0 reactions 0 assignees View on GitHub
legacy (Open3D 0.x API) viewcontrol visualization
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)
`

![001](https://user-images.githubusercontent.com/74580695/134446534-1767bcdc-a62f-4f36-aeef-8a3fae388261.png)
![002](https://user-images.githubusercontent.com/74580695/134446560-8889910b-bd19-41b9-a270-725cb9fe2a5e.png)

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
`
![005](https://user-images.githubusercontent.com/74580695/134447394-b59ca660-4b12-4de1-8f77-0133f78444b0.png)
![003](https://user-images.githubusercontent.com/74580695/134447410-3b91f641-6687-4c74-83d6-7ee776489fc3.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.