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)
| 121 | |
| 122 | @numba.jit(nopython=True) |
| 123 | def 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 | |
| 147 | def depth_to_lidar_points(depth, trunc_pixel, P2, r_rect, velo2cam): |
no outgoing calls
no test coverage detected