In modern computer graphics and computer vision, it's essential to convert points from a global (world) coordinate system into a camera's local coordinate system. This is accomplished by a combination of translation and rotation, conveniently packaged into a single homogeneous transformation matrix. In this post, we'll derive that matrix step by step and show how it acts on a point.

image.png

1. The Problem Statement

Let:

$P_{\text{global}} = \begin{pmatrix}x\\y\\z\end{pmatrix}$be the coordinates of a point in the world frame.

The camera's optical center have global coordinates $C = \begin{pmatrix}x_c\\y_c\\z_c\end{pmatrix}$

The camera's orientation be given by an orthonormal basis of three unit vectors (in world coordinates):

$$ \mathbf u = \begin{pmatrix}u_x\\u_y\\u_z\end{pmatrix},\quad\mathbf v = \begin{pmatrix}v_x\\v_y\\v_z\end{pmatrix},\quad\mathbf w = \begin{pmatrix}w_x\\w_y\\w_z\end{pmatrix} $$

We want one matrix M such that the homogeneous product produces the point’s coordinates in the camera’s local frame.

$M \;\begin{pmatrix} P_{\text{global}} \\ 1 \end{pmatrix} = \begin{pmatrix} P_{\text{camera}} \\ 1 \end{pmatrix}$