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.Camera
— TypeCamera(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 withoriginal_focal
.
NerfUtils.set_resolution!
— Functionset_resolution!(c::Camera; width::Int, height::Int)
Change resolution of the camera. Preserves original focal length aspect, scaling it instead.
NerfUtils.shift!
— Functionshift!(c::Camera, relative)
Shift camera position by a relative
value.
NerfUtils.rotate!
— Functionrotate!(c::Camera, rotation)
Apply rotation to the camera.
Camera intrinsics
CameraIntrinsics
is used to project from pixel space to camera space.
NerfUtils.CameraIntrinsics
— TypeCamera 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, thennothing
.focal::SVector{2, Float32}
: Focal length in(fx, fy)
format.principal::SVector{2, Float32}
: Principal point in(cx, cy)
format. Normalized by theresolution
(in[0, 1]
range)resolution::SVector{2, UInt32}
: Resolution in(width, height)
format.
CameraKeyframe
To smoothly transform camera from one position to another, use NerfUtils.CameraKeyframe
. Used in Video Mode in NerfGUI.jl.
NerfUtils.CameraKeyframe
— TypeCamera pose described by a quaternion q
and position t
.
NerfUtils.spline
— Functionspline(
t::Float32,
k0::CameraKeyframe, k1::CameraKeyframe,
k2::CameraKeyframe, k3::CameraKeyframe)
Cubic B-spline between 4 CameraKeyframe
s. Vary t
from [0, 1]
to compute positions along a spline from k0
to k3
.