pysdic.WorldPlanePerspectiveExtrinsic._apply#
- WorldPlanePerspectiveExtrinsic._apply(world_points, *, dx=False, dp=False)[source]#
Compute the transformation from 2D world points of the plane \(Z_w = 0\) to 2D normalized points.
\[\begin{split}\vec{X}_c = A \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 A\]The Jacobian with respect to the parameters \((\vec{r}, T)\) is:
\[\frac{\partial \vec{x}_n}{\partial r_k} = D \frac{\partial A}{\partial r_k} \vec{x}_w, \qquad \frac{\partial \vec{x}_n}{\partial T} = D\]where \(\frac{\partial A}{\partial r_k}\) are the first two columns of \(\frac{\partial R}{\partial r_k}\) given by
cv2.Rodrigues.- Parameters:
world_points (numpy.ndarray) – Input 2D points of the world plane. Shape
(n_points, 2).dx (bool, optional (default:
False)) – If True, compute the Jacobian with respect to the input world 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, 2)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: