pysdic.PerspectiveExtrinsic._apply#
- PerspectiveExtrinsic._apply(world_points, *, dx=False, dp=False)[source]#
Compute the transformation from 3D world points to 2D normalized points.
The transformation consists of a change of reference frame followed by the perspective division:
\[\begin{split}\vec{X}_c = R \cdot \vec{X}_w + T, \qquad \vec{x}_n = \frac{1}{Z_c} \begin{bmatrix} X_c \\ Y_c \end{bmatrix}\end{split}\]Lets \(D\) be the Jacobian of the perspective division with respect to the camera points:
\[\begin{split}D = \frac{\partial \vec{x}_n}{\partial \vec{X}_c} = \frac{1}{Z_c} \begin{bmatrix} 1 & 0 & -x_n \\ 0 & 1 & -y_n \end{bmatrix}\end{split}\]The Jacobian with respect to the world points is:
\[\frac{\partial \vec{x}_n}{\partial \vec{X}_w} = D R\]The Jacobian with respect to the parameters \((\vec{r}, T)\) is:
\[\frac{\partial \vec{x}_n}{\partial r_k} = D \frac{\partial R}{\partial r_k} \vec{X}_w, \qquad \frac{\partial \vec{x}_n}{\partial T} = D\]where \(\frac{\partial R}{\partial r_k}\) is given by
cv2.Rodrigues.- Parameters:
world_points (numpy.ndarray) – Input 3D points in world coordinates. Shape
(n_points, 3).dx (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the input 3D points.dp (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the extrinsic parameters.
- Returns:
normalized_points (numpy.ndarray) – The normalized points in camera coordinates. Shape
(n_points, 2).jacobian_dx (Optional[numpy.ndarray]) – Jacobian of normalized points with respect to world points. Shape
(n_points, 2, 3)ifdx=True, otherwiseNone.jacobian_dp (Optional[numpy.ndarray]) – Jacobian of normalized points with respect to extrinsic parameters. Shape
(n_points, 2, 6)ifdp=True, otherwiseNone.
- Raises:
ValueError – If at least one point is behind the camera or too close to the camera plane (\(Z_c \leq 10^{-6}\)).
- Return type: