Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-395

Pinhole FOV Projection

Problem

Project a camera-space point with a pinhole model given the horizontal field of view.

The focal length in pixels is f = (width / 2) / tan(fov_deg / 2) and the principal point is the image center. Return [f * X / Z + width / 2, f * Y / Z + height / 2] rounded to 4 decimal places.

Hint

At 90 degrees the half-width equals the focal length in pixels.

Test cases

case 1
in: [[0,0,2],90,640,480]
expected: [320,240]
case 2
in: [[1,0,2],90,640,480]
expected: [480,240]
case 3
in: [[0,0,1],60,100,100]
expected: [50,50]
case 4
in: [[0,1,1],90,200,100]
expected: [100,150]
Starter codePython
def pinhole_fov_project(point, fov_deg, width, height):
    # Your code here
    pass

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