pysdic.WorldPlanePerspectiveExtrinsic._invert#
- WorldPlanePerspectiveExtrinsic._invert(normalized_points, *, dx=False, dp=False)[source]#
Compute the inverse transformation from 2D normalized points to 2D world points of the plane \(Z_w = 0\) (intersection of the camera rays with the plane).
With the homography \(H = [\vec{r}_1, \vec{r}_2, T]\) and \(\vec{m} = (x_n, y_n, 1)^T\):
\[\begin{split}\vec{u} = H^{-1} \vec{m} = \frac{1}{Z_c} \begin{bmatrix} \vec{x}_w \\ 1 \end{bmatrix}, \qquad \vec{x}_w = \frac{1}{u_3} \begin{bmatrix} u_1 \\ u_2 \end{bmatrix}\end{split}\]The intersection is in front of the camera if and only if \(u_3 = 1 / Z_c > 0\). Lets \(D_w\) be the Jacobian of the division:
\[\begin{split}D_w = \frac{\partial \vec{x}_w}{\partial \vec{u}} = \frac{1}{u_3} \begin{bmatrix} 1 & 0 & -x_w \\ 0 & 1 & -y_w \end{bmatrix}\end{split}\]The Jacobian with respect to the normalized points is:
\[\frac{\partial \vec{x}_w}{\partial \vec{x}_n} = D_w H^{-1}_{:, :2}\]The Jacobian with respect to the parameters \(p\) uses \(\frac{\partial H^{-1}}{\partial p} = - H^{-1} \frac{\partial H}{\partial p} H^{-1}\):
\[\begin{split}\frac{\partial \vec{x}_w}{\partial p} = - D_w H^{-1} \frac{\partial H}{\partial p} \vec{u} \quad \text{with} \quad \frac{\partial H}{\partial r_k} \vec{u} = \frac{\partial A}{\partial r_k} \begin{bmatrix} u_1 \\ u_2 \end{bmatrix}, \qquad \frac{\partial H}{\partial T} \vec{u} = u_3 I_3\end{split}\]- Parameters:
normalized_points (numpy.ndarray) – Input 2D normalized points in camera coordinates. Shape
(n_points, 2).dx (bool, optional (default:
False)) – If True, compute the Jacobian with respect to normalized points.dp (bool, optional (default:
False)) – If True, compute the Jacobian with respect to extrinsic parameters.
- Returns:
world_points (numpy.ndarray) – 2D points of the world plane. Shape
(n_points, 2).jacobian_dx (Optional[numpy.ndarray]) – Jacobian of world points with respect to normalized points. Shape
(n_points, 2, 2)ifdx=True, otherwiseNone.jacobian_dp (Optional[numpy.ndarray]) – Jacobian of world points with respect to extrinsic parameters. Shape
(n_points, 2, 6)ifdp=True, otherwiseNone.
- Raises:
ValueError – If the camera center lies in the plane \(Z_w = 0\) (singular homography), or if the ray of at least one point does not hit the plane in front of the camera (ray parallel to the plane or intersection behind the camera).
- Return type: