pycvcam.ZernikeDistortion._transform#
- ZernikeDistortion._transform(normalized_points, *, dx=False, dp=False)[source]#
Compute the transformation from the
normalized_pointsto thedistorted_points.Lets consider
normalized_pointsin the camera normalized coordinate system \(\vec{x}_n = (x_n, y_n)\), the correspondingdistorted_pointsin the camera normalized coordinate system are given \(\vec{x}_d\) can be obtained by :\[x_{d} = x_{n} + \sum_{n=0}^{N_{zer}} \sum_{m=-n}^{n} C^{x}_{n,m} Z_{nm}(\rho, \theta)\]\[y_{d} = y_{n} + \sum_{n=0}^{N_{zer}} \sum_{m=-n}^{n} C^{y}_{n,m} Z_{nm}(\rho, \theta)\]The jacobians with respect to the distortion parameters is an array with shape (n_points, 2, n_params), where the last dimension represents the parameters in the order of the class attributes (Cx[0,0], Cy[0,0], Cx[1,-1], Cy[1,-1], Cx[1,1], Cy[1,1], …). The jacobian with respect to the normalized points is an array with shape (n_points, 2, 2).
The derivative of the distorted points with respect to the normalized points is given by:
\[\frac{\partial x_{d}}{\partial x_{n}} = 1 + \sum_{n=0}^{N_{zer}} \sum_{m=-n}^{n} C^{x}_{n,m} \frac{\partial Z_{nm}}{\partial x_{n}}\]\[\frac{\partial x_{d}}{\partial y_{n}} = \sum_{n=0}^{N_{zer}} \sum_{m=-n}^{n} C^{x}_{n,m} \frac{\partial Z_{nm}}{\partial y_{n}}\]Where:
\[\frac{\partial Z_{nm}}{\partial x_{n}} = \frac{\partial Z_{nm}}{\partial \rho} \cdot \frac{\partial \rho}{\partial x_{n}} + \frac{\partial Z_{nm}}{\partial \theta} \cdot \frac{\partial \theta}{\partial x_{n}}\]\[\frac{\partial Z_{nm}}{\partial y_{n}} = \frac{\partial Z_{nm}}{\partial \rho} \cdot \frac{\partial \rho}{\partial y_{n}} + \frac{\partial Z_{nm}}{\partial \theta} \cdot \frac{\partial \theta}{\partial y_{n}}\]See also
Package
pyzernike(Artezaru/pyzernike) for the implementation of the Zernike polynomials and their derivatives.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 inputnormalized_pointsis (n_points, 2) before calling this method.- Parameters:
normalized_points (numpy.ndarray) – The normalized points in camera normalized coordinates to be transformed. Shape (n_points, 2).
dx (bool, optional) – If True, the jacobian with respect to the normalized points is computed. Default is False
dp (bool, optional) – If True, the jacobian with respect to the distortion parameters is computed. Default is False
opencv (bool, optional) – If True, the distortion transformation is achieved using the OpenCV function
projectPoints. If False, the distortion transformation is achieved using the internal method. Default is False.
- Returns:
distorted_points (numpy.ndarray) – The distorted points in camera normalized coordinates. Shape (n_points, 2).
jacobian_dx (Optional[numpy.ndarray]) – The jacobian of the distorted points with respect to the normalized points. Shape (n_points, 2, 2) if dx is True, otherwise None.
jacobian_dp (Optional[numpy.ndarray]) – The jacobian of the distorted points with respect to the distortion parameters. Shape (n_points, 2, n_params) if dp is True, otherwise None.
- Return type: