NVlabs / eg3d

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why multiple `1.414` in `FOV_to_intrinsic`?

LeoXing1996 opened this issue · comments

The formulation of calculating focal from FOV is

focal = 1. / np.tan(0.5 * fov * np.pi/180.)

However, in FOV_to_intrinsic, 1.414 is multiplied at last.

eg3d/eg3d/camera_utils.py

Lines 140 to 149 in 4930760

def FOV_to_intrinsics(fov_degrees, device='cpu'):
"""
Creates a 3x3 camera intrinsics matrix from the camera field of view, specified in degrees.
Note the intrinsics are returned as normalized by image size, rather than in pixel units.
Assumes principal point is at image center.
"""
focal_length = float(1 / (math.tan(fov_degrees * 3.14159 / 360) * 1.414))
intrinsics = torch.tensor([[focal_length, 0, 0.5], [0, focal_length, 0.5], [0, 0, 1]], device=device)
return intrinsics

Can anyone explain this? Thanks a lot.

commented

I'm wondering about this as well. 1.414 is approximately sqrt(2), which is the diagonal of a unit square. Perhaps they are normalizing by the diagonal here? But their doc (https://github.com/NVlabs/eg3d/blob/main/docs/training_guide.md ) says the intrinsics are normalized by the height and the width instead of the diagonal, so this might be a bug?