
    3j                        S r SSKrSSKJr  S\R                  S\R                  S\R                  4S jrS\R                  S\R                  S\R                  4S	 jrS\R                  S\R                  S\R                  4S
 jrg)z1nn.Module containing the affine distortion model.    N)KORNIA_CHECK_SHAPE#projected_points_in_camera_z1_planeparamsreturnc                     [        U SS/5        [        USS/5        U S   nU S   nUS   US   pTUS   US   pvXB-  U-   nXS-  U-   n	[        R                  " X/SS	9$ )
a'  Distort one or more points from the canonical z=1 plane into the camera frame.

.. math::
    \begin{bmatrix} u \\ v \end{bmatrix} =
    \begin{bmatrix} f_x & 0 \\ 0 & f_y \end{bmatrix}
    \begin{bmatrix} x \\ y \end{bmatrix} +
    \begin{bmatrix} c_x \\ c_y \end{bmatrix}

Args:
    projected_points_in_camera_z1_plane: torch.Tensor representing the points to distort with shape (..., 2).
    params: torch.Tensor representing the parameters of the affine distortion model with shape (..., 4).

Returns:
    torch.Tensor representing the distorted points with shape (..., 2).

Example:
    >>> points = torch.tensor([319.5, 239.5])  # center of a 640x480 image
    >>> params = torch.tensor([600., 600., 319.5, 239.5])
    >>> distort_points_affine(points, params)
    tensor([192019.5000, 143939.5000])

*24.r   .   .   .   dimr   torchstack)
r   r   xyfxfycxcyuvs
             b/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/geometry/camera/distortion_affine.pydistort_points_affiner!      s|    . :S#JGvSz*+F3A+F3AF^VF^F^VF^
A
A;;v2&&    distorted_points_in_camerac                     [        U SS/5        [        USS/5        U S   nU S   nUS   US   pTUS   US   pvX&-
  U-  nX7-
  U-  n	[        R                  " X/SS	9$ )
a  Undistort one or more points from the camera frame into the canonical z=1 plane.

.. math::
    \begin{bmatrix} x \\ y \end{bmatrix} =
    \begin{bmatrix} u \\ v \end{bmatrix} -
    \begin{bmatrix} c_x \\ c_y \end{bmatrix}
    \begin{bmatrix} f_x & 0 \\ 0 & f_y \end{bmatrix}^{-1}

Args:
    distorted_points_in_camera: torch.Tensor representing the points to undistort with shape (..., 2).
    params: torch.Tensor representing the parameters of the affine distortion model with shape (..., 4).

Returns:
    torch.Tensor representing the undistorted points with shape (..., 2).

Example:
    >>> points = torch.tensor([319.5, 239.5])  # center of a 640x480 image
    >>> params = torch.tensor([600., 600., 319.5, 239.5])
    >>> undistort_points_affine(points, params)
    tensor([0., 0.])

r   r	   r
   r   r   r   r   r   r   r   )
r#   r   r   r   r   r   r   r   r   r   s
             r    undistort_points_affiner%   @   s|    . 1C:>vSz*"6*A"6*AF^VF^F^VF^	
2A	
2A;;v2&&r"   c                     [        U SS/5        [        USS/5        US   US   p2[        R                  " U5      n[        R                  " [        R                  " X$/SS9[        R                  " XC/SS9/SS9$ )	a
  Compute the derivative of the x distortion with respect to the x coordinate.

.. math::
    \frac{\partial u}{\partial x} =
    \begin{bmatrix} f_x & 0 \\ 0 & f_y \end{bmatrix}

Args:
    projected_points_in_camera_z1_plane: torch.Tensor representing the points to distort with shape (..., 2).
    params: torch.Tensor representing the parameters of the affine distortion model with shape (..., 4).

Returns:
    torch.Tensor representing the derivative of the x distortion with respect to the x coordinate
    with shape (..., 2).

Example:
    >>> points = torch.tensor([319.5, 239.5])  # center of a 640x480 image
    >>> params = torch.tensor([600., 600., 319.5, 239.5])
    >>> dx_distort_points_affine(points, params)
    tensor([[600.,   0.],
            [  0., 600.]])

r   r	   r
   r   r   r   r   )r   r   
zeros_liker   )r   r   r   r   zeross        r    dx_distort_points_affiner*   f   sr    . :S#JGvSz*F^VF^R E;;RKR8%++ukWY:Z[acddr"   )__doc__r   kornia.core.checkr   Tensorr!   r%   r*    r"   r    <module>r/      s   $ 8  0#'u|| #'UZUaUa #'fkfrfr #'L#' #'ell #'_d_k_k #'Le%,, eX]XdXd einiuiu er"   