pycvcam.Cv2Extrinsic._compute_rays#

Cv2Extrinsic._compute_rays(normalized_points)[source]#

Computes the rays from the camera to the scene for the the extrinsic model in the world coordinate system.

The ray structure is as follows:

  • The first 3 elements are the origin of the ray in the world coordinate system (the normalized points with z=1 and a change of coordinate system).

  • The last 3 elements are the direction of the ray in the world coordinate system, which is obtained by the vector from the origin to the normalized point in the world coordinate system.

Lets \(\vec{X}_n\) the 3D normalized points, with coordinates \((x_n, y_n, 1.0)\) in the camera coordinate system. Lets \(\vec{O}\) the camera position with coordinates \((0, 0, 0)\) in the camera coordinate system.

The points in the world coordinate system are computed as follows:

\[\begin{split}\begin{align*} \vec{X}_w &= R^{-1} \cdot (\vec{X}_n - T) \\ \vec{O}_w &= - R^{-1} \cdot T \end{align*}\end{split}\]

The origin of the ray in the world coordinate system is the normalized points \(\vec{X}_w\) in world coordinates and the direction of the ray is the normalized vector from the origin to the point \((\vec{X}_w - \vec{O}_w)/\|\vec{X}_w - \vec{O}_w\|\) in world coordinates.

Parameters:

normalized_points (numpy.ndarray) – The normalized points in the camera coordinate system. Shape (n_points, 2).

Returns:

The rays in the world coordinate system. Shape (n_points, 6).

Return type:

numpy.ndarray