Stereo Depth from Disparity
~8 mincode completion
Implement stereo_depth(f, B, disparity) returning Z=fB/d.
Examples
f=2, B=10, d=4 gives Z=5
- Input
- stereo_depth(2, 10, 4)
- Output
- 5
The same rig, a quarter of the disparity, is four times farther
- Input
- stereo_depth(2, 10, 1)
- Output
- 20
A long focal length and a small disparity: Z = 240
- Input
- stereo_depth(100, 0.12, 0.05)
- Output
- 240
Hints
Hint 1
Convert the input with before doing elementwise work.
Hint 2
A common slip here: multiplied by disparity instead of dividing.
Requirements
f: focal lengthB: baselinedisparity: scalar or array of x_L - x_RReturn depth, same shape as disparity
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Where this shows up
~8 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 stereo_depth(f, B, disparity):
"""
Depth from a rectified stereo pair.
Args:
f: focal length
B: baseline
disparity: scalar or array of x_L - x_R
Returns:
depth, same shape as disparity
"""
# YOUR CODE HERE
pass