pycvcam.Cv2Extrinsic._compute_rays#
- Cv2Extrinsic._compute_rays(normalized_points)[source]#
Compute the 3D rays from the camera to the scene in world coordinates.
Each ray consists of:
The origin: the 3D position of the point in world coordinates.
The direction: a unit vector pointing from the camera center to the point in world coordinates.
Let:
\(\vec{X}_n\) be the 3D normalized points in camera coordinates with coordinates (x_n, y_n, 1.0).
\(\vec{O}\) be the camera center at (0, 0, 0) in camera coordinates.
\(R\) be the rotation matrix of the extrinsic transformation.
\(T\) be the translation vector of the extrinsic transformation.
Then the transformation to world coordinates is:
\[ \begin{align}\begin{aligned}\vec{X}_w = R^{-1} \cdot (\vec{X}_n - T)\\\vec{O}_w = - R^{-1} \cdot T\end{aligned}\end{align} \]The ray origin is \(\vec{X}_w\) and the ray direction is:
\[\vec{d}_w = \frac{\vec{X}_w - \vec{O}_w}{\|\vec{X}_w - \vec{O}_w\|}\]This ensures that each ray starts at the world position of the point and points outward from the camera.
- Parameters:
normalized_points (numpy.ndarray) – Input 2D normalized points in camera coordinates. Shape (n_points, 2).
- Returns:
Rays in world coordinates. Shape (n_points, 6), where the first three elements of each row are the origin (x, y, z) and the last three elements are the normalized direction (dx, dy, dz).
- Return type: