Depth Map to a Point Cloud
~12 mincode completion
Implement depth_to_points(depth, f) on a 2D depth map and return an (H, W, 3) point cloud.
Examples
2x2 depth [[2, 4], [2, 4]] at f=2
- Input
- depth_to_points([[2, 4], [2, 4]], 2)
- Output
- [[[0, 0, 2], [2, 0, 4]], [[0, 1, 2], [2, 2, 4]]]
A 1x1 depth map at the origin is just (0, 0, Z)
- Input
- depth_to_points([[4]], 2)
- Output
- [[[0, 0, 4]]]
Hints
Hint 1
Convert the input with before doing elementwise work.
Hint 2
Double check the order of row and column when assigning x and y.
Requirements
depth: 2D array of shape (H, W)f: focal lengthReturn array of shape (H, W, 3) with channels X, Y, Z
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Where this shows up
~12 min
••••••••••••••••
8 employers weight this skill
4 autonomy companies, 1 defense company, 1 health and bio company, 1 enterprise vendor, 1 AI product company. Top match scores 93.
Python
import numpy as np
def depth_to_points(depth, f):
"""
Back-project every pixel of a depth map.
Args:
depth: 2D array of shape (H, W)
f: focal length
Returns:
array of shape (H, W, 3) with channels X, Y, Z
"""
# YOUR CODE HERE
pass