Camera Models#

Everything starts with the cameras. Given a set of images, we need a way to project their pixels into 3D space. This is accomplished by computing the camera ray for each pixel given information about the type of camera and the location of the camera. This guide describes the camera models implemented in nerfstudio.

Each image should have an associated pose which consists of two properties, intrinsic and extrinsic parameters.

Intrinsics

All of the parameters internal to the camera such as lense or sensor properties.

Extrinsics

All of the parameters external to the camera such as the location and rotation relative to the world frame.

Perspective Camera Model#

The simplest and most used camera model. Most standard cameras can be sufficiently approximated using the pinhole camera model.

Intrinsic

Description

cx

Number of pixels in the x dimension

cy

Number of pixels in the y dimension

fx

Focal length in the x dimension

fy

Focal length in the y dimension

# COLLAPSED
from nerfstudio.cameras.cameras import Cameras, CameraType
from nerfstudio.utils import plotly_utils as vis

cx = 20.0
cy = 10.0
fx = 20.0
fy = 20.0

c2w = torch.eye(4)[None, :3, :]

camera = Cameras(fx=fx, fy=fy, cx=cx, cy=cy, camera_to_worlds=c2w, camera_type=CameraType.PERSPECTIVE)
fig = vis.vis_camera_rays(camera)
fig.show()

Fisheye Camera Model#

The spacing of rays on a fisheye camera is more even on the edges of the image (most noticeable in wide angle images). This makes them desirable for NeRF reconstructions.

# COLLAPSED
from nerfstudio.cameras.cameras import Cameras, CameraType
from nerfstudio.utils import plotly_utils as vis

cx = 10.0
cy = 10.0
fx = 10.0
fy = 10.0

c2w = torch.eye(4)[None, :3, :]

camera = Cameras(fx=fx, fy=fy, cx=cx, cy=cy, camera_to_worlds=c2w, camera_type=CameraType.FISHEYE)
fig = vis.vis_camera_rays(camera)
fig.show()

Equirectangular/Spherical Camera Model#

Rays are produced at all angles around the camera.

# COLLAPSED
from nerfstudio.cameras.cameras import Cameras, CameraType
from nerfstudio.utils import plotly_utils as vis

cx = 20.0  # = width/2
cy = 10.0  # = height/2
fx = 20.0  # = height = width/2
fy = 20.0  # = height = width/2

c2w = torch.eye(4)[None, :3, :]

camera = Cameras(fx=fx, fy=fy, cx=cx, cy=cy, camera_to_worlds=c2w, camera_type=CameraType.EQUIRECTANGULAR)
fig = vis.vis_camera_rays(camera)
fig.show()

Distortion Parameters#

Unless you are using a pinhole camera (you probably aren’t), modeling the distortion caused by the lenses may be beneficial. We represent the distortion with 6 parameters, \([k_1, k_2, k_3, k_4]\) for radial distortion and \([p_1, p_2]\) for tangential distortion.