MCPcopy Create free account
hub / github.com/InternRobotics/EmbodiedScan / depth_to_points

Function depth_to_points

embodiedscan/structures/ops/box_np_ops.py:123–144  ·  view source on GitHub ↗

Convert depth map to points. Args: depth (np.array, shape=[H, W]): Depth map which the row of [0~`trunc_pixel`] are truncated. trunc_pixel (int): The number of truncated row. Returns: np.ndarray: Points in camera coordinates.

(depth, trunc_pixel)

Source from the content-addressed store, hash-verified

121
122@numba.jit(nopython=True)
123def depth_to_points(depth, trunc_pixel):
124 """Convert depth map to points.
125
126 Args:
127 depth (np.array, shape=[H, W]): Depth map which
128 the row of [0~`trunc_pixel`] are truncated.
129 trunc_pixel (int): The number of truncated row.
130
131 Returns:
132 np.ndarray: Points in camera coordinates.
133 """
134 num_pts = np.sum(depth[trunc_pixel:, ] > 0.1)
135 points = np.zeros((num_pts, 3), dtype=depth.dtype)
136 x = np.array([0, 0, 1], dtype=depth.dtype)
137 k = 0
138 for i in range(trunc_pixel, depth.shape[0]):
139 for j in range(depth.shape[1]):
140 if depth[i, j] > 0.1:
141 x = np.array([j, i, 1], dtype=depth.dtype)
142 points[k] = x * depth[i, j]
143 k += 1
144 return points
145
146
147def depth_to_lidar_points(depth, trunc_pixel, P2, r_rect, velo2cam):

Callers 1

depth_to_lidar_pointsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected