Module: tfg.rendering.camera.perspective

This module implements perspective camera functionalities.

The perspective camera model, also referred to as pinhole camera model, is defined using a focal length \((f_x, f_y)\) and a principal point \((c_x, c_y)\). The perspective camera model can be written as a calibration matrix

\[ \mathbf{C} = \begin{bmatrix} f_x & 0 & c_x \\ 0 & f_y & c_y \\ 0 & 0 & 1 \\ \end{bmatrix}, \]

also referred to as the intrinsic parameter matrix. The camera focal length \((f_x, f_y)\), defined in pixels, is the physical focal length divided by the physical size of a camera pixel. The physical focal length is the distance between the camera center and the image plane. The principal point is the intersection of the camera axis with the image plane. The camera axis is the line perpendicular to the image plane starting at the optical center.

More details about perspective cameras can be found on this page.

Functions

intrinsics_from_matrix(...): Extracts intrinsic parameters from a calibration matrix.

matrix_from_intrinsics(...): Builds calibration matrix from intrinsic parameters.

parameters_from_right_handed(...): Recovers the parameters used to contruct a right handed projection matrix.

project(...): Projects a 3d point onto the 2d camera plane.

random_patches(...): Sample patches at different scales and from an image.

random_rays(...): Sample rays at random pixel location from a perspective camera.

ray(...): Computes the 3d ray for a 2d point (the z component of the ray is 1).

right_handed(...): Generates the matrix for a right handed perspective projection.

unproject(...): Unprojects a 2d point in 3d.