pycvcam.FisheyeDistortion._polar_to_cartesian#
- FisheyeDistortion._polar_to_cartesian(polar, dx=True)[source]#
Convert polar coordinates to cartesian coordinates.
The input
polarpoints are given in the form \((r, \theta)\) with shape (n_points, 2), where \(r = \sqrt{x^2 + y^2}\) and \(\theta = \arctan2(y, x)\). The outputcartesianpoints are given in the form \((x, y)\) with shape (n_points, 2).\[\begin{split}\begin{bmatrix} x \\ y \\ \end{bmatrix} = \begin{bmatrix} r \cos(\theta) \\ r \sin(\theta) \\ \end{bmatrix}\end{split}\]The jacobian with respect to the polar points is an array with shape (n_points, 2, 2).
\[\begin{split}J = \begin{bmatrix} \frac{\partial x}{\partial r} & \frac{\partial x}{\partial \theta} \\ \frac{\partial y}{\partial r} & \frac{\partial y}{\partial \theta} \\ \end{bmatrix} = \begin{bmatrix} \cos(\theta) & -r\sin(\theta) \\ \sin(\theta) & r\cos(\theta) \\ \end{bmatrix}\end{split}\]Warning
This method is not intended to be used directly, but rather through the
pycvcam.core.Transform.transform()method. Please ensure, the shape of the inputpolaris (n_points, 2) before calling this method.- Parameters:
polar (numpy.ndarray) – The polar points to be converted. Shape (n_points, 2).
dx (bool, optional) – If True, the jacobian with respect to the polar points is computed. Default is True.
- Returns:
cartesian (numpy.ndarray) – The cartesian points. Shape (n_points, 2).
jacobian_dx (Optional[numpy.ndarray]) – The jacobian of the cartesian points with respect to the polar points. Shape (n_points, 2, 2) if dx is True, otherwise None.
- Return type: