Skip to content
DeepForgeby svx
All problems
HardComputer Visioncv-372

Triangulation Depth

Problem

Triangulate a 3D point from two camera rays.

Normalize the direction vectors d1 and d2, then solve the closest-points problem between ray 1 (center c1) and ray 2 (center c2). Return the average of the two ray depths rounded to 4 decimal places, or 0.0 when the rays are parallel.

Hint

The 2x2 system for the two ray parameters has determinant 1 - (u1 . u2)^2.

Test cases

case 1
in: [[0,0,0],[0,0,1],[1,0,0],[-1,0,2]]
expected: 2.118
case 2
in: [[0,0,0],[0,0,1],[1,0,0],[0,0,2]]
expected: 0
case 3
in: [[0,0,0],[0,0,1],[0,0,0],[1,0,0]]
expected: 0
case 4
in: [[0,0,0],[0,0,1],[0.5,0,0],[-1,0,1]]
expected: 0.6036
Starter codePython
def triangulate_depth(c1, d1, c2, d2):
    # Your code here
    pass

4 test cases · run your code against them in the editor