Back-Project a Pixel
~10 mincode completion
Implement backproject_points(pixels, depths, f) on (N, 2) pixels (x,y) and an (N,) depth vector, returning (N, 3) points (X,Y,Z).
Examples
Inverse of the (2, 4, 2) projection at f=2
- Input
- backproject_points([[2, 4]], [2], 2)
- Output
- [[2, 4, 2]]
Same pixel, twice the depth, twice the 3D offset
- Input
- backproject_points([[1, 2]], [4], 2)
- Output
- [[2, 4, 4]]
The optical-axis pixel back-projects to (0, 0, Z)
- Input
- backproject_points([[0, 0]], [5], 10)
- Output
- [[0, 0, 5]]
Hints
Hint 1
The reduction runs across each row, so pass .
Hint 2
Do not forget to multiply by z. That step is easy to skip.
Requirements
pixels: array of shape (N, 2) with columns x, ydepths: array of shape (N,)f: focal lengthReturn array of shape (N, 3) with columns X, Y, Z
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~10 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 backproject_points(pixels, depths, f):
"""
Lift pixels to 3D given per-pixel depth.
Args:
pixels: array of shape (N, 2) with columns x, y
depths: array of shape (N,)
f: focal length
Returns:
array of shape (N, 3) with columns X, Y, Z
"""
# YOUR CODE HERE
pass