Rendering

Camera

Camera is used to cast rays according to its intrinsic and extrinsic parameters. When resizing its resolution it preserves original aspect ratio of focal length since that's the value the model was trained on.

NerfUtils.CameraType
Camera(projection, intrinsics::CameraIntrinsics)

Camera maintains original focal length, since the model was trained on a specific value of it, thus we want to preserve the original aspect.

Arguments:

  • projection::MMatrix{3, 4, Float32}: Camera-to-world projection.
  • intrinsics::CameraIntrinsics: Camera intrinsics.
  • original_focal::SVector{2, Float32}: Original focal length. Used during camera resizing to preserve original focal length aspect ratio.
  • original_resolution::SVector{2, UInt32}: Original resolution. Used during camera resizing to compute scale value to multiply with original_focal.
source
NerfUtils.set_resolution!Function
set_resolution!(c::Camera; width::Int, height::Int)

Change resolution of the camera. Preserves original focal length aspect, scaling it instead.

source

Camera intrinsics

CameraIntrinsics is used to project from pixel space to camera space.

NerfUtils.CameraIntrinsicsType

Camera intrinsics for projecting from pixel to camera space.

Projection is done as follows: ((x, y) .- principal) ./ focal. Followed by undistortion if any.

Arguments:

  • distortion::Maybe{SVector{4, Float32}}: If no distortion, then nothing.
  • focal::SVector{2, Float32}: Focal length in (fx, fy) format.
  • principal::SVector{2, Float32}: Principal point in (cx, cy) format. Normalized by the resolution (in [0, 1] range)
  • resolution::SVector{2, UInt32}: Resolution in (width, height) format.
source

CameraKeyframe

To smoothly transform camera from one position to another, use NerfUtils.CameraKeyframe. Used in Video Mode in NerfGUI.jl.

NerfUtils.splineFunction
spline(
    t::Float32,
    k0::CameraKeyframe, k1::CameraKeyframe,
    k2::CameraKeyframe, k3::CameraKeyframe)

Cubic B-spline between 4 CameraKeyframes. Vary t from [0, 1] to compute positions along a spline from k0 to k3.

source