+
    åûjÉ1  ã                   óh   € R t ^ RIHt ^ RIt^ RIHu Ht ^ RIH	t	 ^ RI
Ht R	R R lltR
R R lltR# )zbAdd OpenCV's Brown-Conrady lens distortion to pixel coordinates, and build its sensor-tilt matrix.)ÚOptionalN)ÚKORNIA_CHECK_SHAPE©Ú_at_least_float32c                ó„   € V ^8„  d   QhR\         P                  R\         P                  R\        R\         P                  /# )é   ÚtauxÚtauyÚreturn_inverseÚreturn)ÚtorchÚTensorÚbool)Úformats   "Ú_C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\calibration\distort.pyÚ__annotate__r      s=   € ÷ Zñ Zœ%Ÿ,™,ð Z¬e¯l©lð ZÌDð ZÔ]b×]iÑ]iñ Zó    c           	     ó  € V P                   VP                   8w  d'   \        RV P                    RVP                    R24      hV P                  4       ^ 8”  d;   V P                   R,          ^8X  d#   V P                  R4      p VP                  R4      p\        P
                  ! V 4      p\        P                  ! V 4      p\        P
                  ! V4      p\        P                  ! V4      p\        P                  ! V4      p\        P                  ! V4      p\        P                  ! \        P                  ! W‡V.R4      \        P                  ! WsV.R4      \        P                  ! Wt) V.R4      .R4      p	\        P                  ! \        P                  ! WWV) .R4      \        P                  ! WxV.R4      \        P                  ! WgV.R4      .R4      p
W©,          pV'       d¥   ^VR,          ,          p\        P                  ! \        P                  ! WÇVR,          V,          .R4      \        P                  ! W|VR,          V,          .R4      \        P                  ! WwV.R4      .R4      pVP                  RR4      V,          # \        P                  ! \        P                  ! VR,          W{R,          ) .R4      \        P                  ! W{R,          VR,          ) .R4      \        P                  ! WwV.R4      .R4      pWë,          # )	aò  Build the 3x3 sensor-tilt matrix of OpenCV's distortion model, or its inverse.

``T = tilt_projection(taux, tauy)`` takes the tilt angles in radians, the last two of the 14 coefficients of
OpenCV's distortion vector, and returns the projective ``(*, 3, 3)`` matrix that
:func:`~kornia.geometry.calibration.distort_points` applies to the distorted normalized point ``(x, y, 1)``
before dividing by the third component; ``return_inverse=True`` returns its inverse, which
:func:`~kornia.geometry.calibration.undistort_points` applies first. Those two functions call it themselves:
call it directly only to inspect or reuse the tilt step.

Convention:
    - the rotation is ``R = Ry(tauy) @ Rx(taux)`` and ``Pz`` is built from the third column of ``R``;
      ``return_inverse=False`` returns ``Pz @ R`` (OpenCV's tilt projection) and ``return_inverse=True`` its
      inverse, the branch :func:`~kornia.geometry.calibration.undistort_points` applies. Zero angles give
      ``eye(3)``.
    - scalar angles return ``(3, 3)``; otherwise a trailing singleton angle axis, if present, is
      consumed and the remaining dimensions are the batch shape.

Args:
    taux: Rotation angle in radians around the :math:`x`-axis with any shape, matching the other angle.
    tauy: Rotation angle in radians around the :math:`y`-axis with any shape, matching the other angle.
    return_inverse: False to obtain the tilt projection matrix. True for the inverse matrix.

Returns:
    torch.Tensor: Tilt projection matrix, or the inverse tilt projection matrix when ``return_inverse`` is
    True, with shape ``(3, 3)`` for scalar angles or ``(*, 3, 3)`` for non-scalar angles, where a
    trailing singleton angle-component axis is omitted from :math:`*`.

Raises:
    ValueError: if ``taux`` and ``tauy`` differ in shape.

See Also:
    - :func:`~kornia.geometry.calibration.distort_points`: applies this matrix when given 14 coefficients.
    - :func:`~kornia.geometry.calibration.undistort_points`: applies its inverse when given 14 coefficients.

zShape of taux z
 and tauy z do not match.éÿÿÿÿéþÿÿÿ).r   r   ).é    r   ).é   r   )ÚshapeÚ
ValueErrorÚdimÚsqueezer   ÚcosÚsinÚ
zeros_likeÚ	ones_likeÚstackÚ	transpose)r   r	   r
   ÚcTxÚsTxÚcTyÚsTyÚzeroÚoneÚRxÚRyÚRÚinvR22ÚinvPzÚPzs   &&&            r   Útilt_projectionr.      sl  € ðH ‡z�z�T—Z‘ZÔÜ˜>¨$¯*©*¨°ZÀÇ
Á
¸|È>ÐZÓ[Ð[à‡x�xƒz�A„~˜$Ÿ*™* R�.¨AÔ-Ø�|‰|˜BÓˆØ�|‰|˜BÓˆä
�)Š)�D‹/€CÜ
�)Š)�D‹/€CÜ
�)Š)�D‹/€CÜ
�)Š)�D‹/€CÜ×Ò˜CÓ €DÜ
�/Š/˜#Ó
€Cä	�Šä�KŠK˜ DÐ)¨2Ó.Ü�KŠK˜ CÐ(¨"Ó-Ü�KŠK˜˜t SÐ)¨2Ó.ð	
ð
 	ó
€Bô 
�Šä�KŠK˜ S DÐ)¨2Ó.Ü�KŠK˜ DÐ)¨2Ó.Ü�KŠK˜ CÐ(¨"Ó-ð	
ð
 	ó
€Bð 	�€AçØ�Q�y•\Õ!ˆÜ—’ä—’˜V¨1¨Y­<¸&Õ+@ÐAÀ2ÓFÜ—’˜T¨1¨Y­<¸&Õ+@ÐAÀ2ÓFÜ—’˜T¨Ð-¨rÓ2ðð
 ó
ˆð �{‰{˜2˜rÓ" UÕ*Ð*ä	�Šä�KŠK˜˜9� t°	­l¨]Ð;¸RÓ@Ü�KŠK˜ �|¨a°	­l¨]Ð;¸RÓ@Ü�KŠK˜ SÐ)¨2Ó.ð	
ð
 	ó
€Bð �6€Mr   c          
      óÎ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        \         P                  ,          R\         P                  /# )r   ÚpointsÚKÚdistÚnew_Kr   )r   r   r   )r   s   "r   r   r   {   s[   € ÷ VVñ VVÜ�L‰LðVVÜ"Ÿ\™\ðVVÜ16·±ðVVÜFNÌuÏ|É|ÕF\ðVVä
‡\�\ñVVr   c                óD	  € \        V . RO4       VP                  RR R	8w  d   \        RVP                   R24      hVf   TpM-VP                  RR R	8w  d   \        RVP                   R24      hVP                  R
,          R9  d    \        RVP                  R
,           24      h\        P                  ! \        P                  ! V P
                  VP
                  4      \        P                  ! VP
                  VP
                  4      4      pR WW23 4       w  rr2VP                  R
,          ^8H  pVP                  R
,          ^8  d2   \        P                  ! V^ ^VP                  R
,          ,
          .4      pVR,          pVR,          pVR,          pVR,          p	V R,          V,
          V,          p
V R,          V,
          V	,          pWª,          W»,          ,           pWÌ,          pWÜ,          p^VR,          V,          ,           VR,          V,          ,           VR,          V,          ,           ^VR,          V,          ,           VR,          V,          ,           VR,          V,          ,           ,          pW¯,          ^VR,          ,          V
,          V,          ,           VR,          V^V
,          V
,          ,           ,          ,           VR,          V,          ,           VR,          V,          ,           pW¿,          VR,          V^V,          V,          ,           ,          ,           ^VR,          ,          V
,          V,          ,           VR,          V,          ,           VR,          V,          ,           pV'       dŽ   \        VR,          VR,          4      p\        P                  ! VV\        P                  ! V4      .R
4      VP                  RR
4      ,          pVR,          VR ,          ,          pVR,          VR ,          ,          pVR,          pVR,          pVR,          pVR,          pVV,          V,           p
VV,          V,           p\        P                  ! W«.R
4      pV\        P                  \        P                  39   d   VP                  V4      # T# )!aÂ  Distort pixel coordinates with OpenCV's Brown-Conrady model of 4 to 14 coefficients.

``distorted = distort_points(points, K, dist)`` takes ideal pinhole pixels ``(*, N, 2)``, the intrinsics
``(*, 3, 3)`` and OpenCV's coefficient vector ``(*, n)``, ``n`` one of 4, 5, 8, 12 or 14, and returns the pixels
``(*, N, 2)`` where a lens with that distortion images the same rays: the values ``cv2.projectPoints`` gives for
the points' rays. To remove distortion from measured pixels, use
:func:`~kornia.geometry.calibration.undistort_points`; from a whole image,
:func:`~kornia.geometry.calibration.undistort_image`.

Radial :math:`(k_1, k_2, k_3, k_4, k_5, k_6)`,
tangential :math:`(p_1, p_2)`, thin prism :math:`(s_1, s_2, s_3, s_4)`, and tilt :math:`(\tau_x, \tau_y)`
distortion models are considered in this function.

Convention:
    - ``points`` are **pixel** coordinates in ``(u, v)`` order and so is the result (integer pixel centres;
      see :class:`~kornia.geometry.camera.pinhole.PinholeCamera`).
      :func:`~kornia.geometry.camera.distort_points_affine` and
      :func:`~kornia.geometry.camera.distort_points_kannala_brandt` take a point on the normalized
      :math:`z = 1` plane and a flat parameter vector instead.
    - ``dist`` is OpenCV's coefficient vector in the order listed under ``Args``. The lengths 4, 5, 8, 12
      and 14 are accepted, zero-padded to 14 internally; any other length raises :class:`ValueError`.
    - ``new_K`` maps the incoming pixel onto the normalized plane and ``K`` maps the distorted point back
      to pixels; ``new_K`` defaults to ``K``. :func:`~kornia.geometry.calibration.undistort_points` is the
      inverse map, with the two intrinsics in the mirrored roles.
    - matching leading dimensions of ``points``, ``K`` and ``dist`` are preserved, and the leading dimensions
      ``*`` of the three broadcast by torch's rules: ``(N, 2)`` points with ``(B, 3, 3)`` cameras give
      ``(B, N, 2)``.
    - the skew entry ``K[0, 1]`` is ignored, as in
      :func:`~kornia.geometry.conversions.normalize_points_with_intrinsics`.
    - ``points`` must be ``(*, N, 2)``: a trailing size other than 2, or a single ``(2,)`` point, raises
      :class:`~kornia.core.exceptions.ShapeError`.
    - float16 and bfloat16 inputs are distorted in float32 and the result is returned in their dtype.

Args:
    points: Input image points with shape ``(*, N, 2)``.
    K: Intrinsic camera matrix with shape ``(*, 3, 3)``.
    dist: Distortion coefficients
        :math:`(k_1,k_2,p_1,p_2[,k_3[,k_4,k_5,k_6[,s_1,s_2,s_3,s_4[,\tau_x,\tau_y]]]])`. This is
        a vector with 4, 5, 8, 12 or 14 elements with shape ``(*, n)``.
    new_K: Intrinsic camera matrix used to map the incoming ``points`` from pixels onto the normalized
        :math:`z = 1` plane -- the opposite of what the argument order suggests, since ``K`` is the one
        that maps the distorted normalized point back to pixels. By default it is the same as ``K``, in
        which case both steps use the same camera; a different matrix rescales and shifts the **input**,
        not the result. Shape: ``(*, 3, 3)``. Default: None.

Returns:
    Distorted 2D points with shape ``(*, N, 2)``.

See Also:
    - :func:`~kornia.geometry.calibration.undistort_points`: the inverse, by fixed-point iteration, with ``K``
      and ``new_K`` in mirrored roles.
    - :func:`~kornia.geometry.calibration.undistort_image`: removes the distortion from an image by sampling
      it at the positions this function returns.
    - :func:`~kornia.geometry.calibration.tilt_projection`: the sensor-tilt matrix of the last two
      coefficients.
    - :func:`~kornia.geometry.camera.distort_points_kannala_brandt`: the fisheye model, from normalized points
      and a flat 8-vector.
    - :func:`~kornia.geometry.camera.distort_points_affine`: the intrinsics alone, from normalized points and a
      flat ``[fx, fy, cx, cy]``.
    - :class:`~kornia.sensors.camera.distortion_model.BrownConradyTransform`: the same distortion from
      normalized ``Vector2`` points, with the coefficients in a 12-value parameter vector.

Example:
    >>> points = torch.rand(1, 1, 2)
    >>> K = torch.eye(3)[None]
    >>> dist_coeff = torch.rand(1, 4)
    >>> points_dist = distort_points(points, K, dist_coeff)

NzK matrix shape is invalid. Got Ú.z#new_K matrix shape is invalid. Got z/Invalid number of distortion coefficients. Got c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5i©Nr   )Ú.0Úts   & r   Ú	<genexpr>Ú!distort_points.<locals>.<genexpr>Ô   s   é € ÐUÑ<T°qÔ/°×2Ð2Ó<Tùs   ‚)Ú*ÚNÚ2r   )é   r?   r   )é   é   é   é   é   ).ºr   r   Nr   ).ºr   r   Nr   ).rE   r   ).rF   r   ).r   ).r   ).rE   ).rF   ).:r@   rA   N).:rA   é   N).:rG   é   N).:rH   rB   N).:r   r?   N).:r?   r@   N).:rB   é	   N).:rI   é
   N).:rJ   é   N).:rK   rC   N).:rC   é   N).:rL   rD   N).r   )r   r   r   r   Úpromote_typesÚdtypeÚFÚpadr.   r    r   r!   Úfloat16Úbfloat16Úto)r0   r1   r2   r3   Ú	out_dtypeÚhas_tiltÚnew_cxÚnew_cyÚnew_fxÚnew_fyÚxÚyÚr2Úr4Úr6Úrad_polyÚxdÚydÚtiltÚpoints_untiltÚcxÚcyÚfxÚfyÚouts   &&&&                     r   Údistort_pointsri   {   sÖ  € ôP �všÔ/à‡w�wˆrˆs€|�vÔÜÐ:¸1¿7¹7¸)À1ÐEÓFÐFà‚}Ø‰Ø	�‰�R�SÐ	˜VÔ	#ÜÐ>¸u¿{¹{¸mÈ1ÐMÓNÐNà‡z�z�"…~Ð.Ô.ÜÐJÈ4Ï:É:ÐVXÍ>ÐJZÐ[Ó\Ð\ô ×#Ò#Ü×Ò˜FŸL™L¨!¯'©'Ó2´E×4GÒ4GÈÏ
É
ÐTY×T_ÑT_Ó4`ó€Iñ V¸VÈÑ<TÓUÑ€Fˆuà�z‰z˜"�~ Ñ#€Hà‡z�z�"…~˜ÔÜ�uŠu�T˜A˜r D§J¡J¨r¥NÕ2Ð3Ó4ˆð ! Õ-€FØ  Õ-€FØ  Õ-€FØ  Õ-€Fð ˜f•~¨Õ.°&Õ8€AØ˜f•~¨Õ.°&Õ8€Að 
��•�€BØ	�€BØ	�€Bà�D˜•N RÕ'Õ'¨$¨x­.¸2Õ*=Õ=ÀÀXÅÐQSÕ@SÕSØ	ˆD��N˜RÕÕ $ x¥.°2Õ"5Õ5¸¸X½ÈÕ8KÕKõ€Hð 	
�Ø
ˆd�8�nÕ
˜qÕ
  1Õ
$õ	%à
ˆx�.˜B  Q¥¨¥�NÕ
+õ	,ð ˆx�.˜2Õ
õ	ð ˆy�/˜BÕ
õ		ð ð 	
�Ø
ˆx�.˜B  Q¥¨¥�NÕ
+õ	,à
ˆd�8�nÕ
˜qÕ
  1Õ
$õ	%ð ˆzÕ
˜RÕ
õ	 ð ˆzÕ
˜RÕ
õ		 ð ÷ Ü˜t JÕ/°°jÕ1AÓBˆô Ÿš R¨¬U¯_ª_¸RÓ-@Ð$AÀ2ÓFÈÏÉÐXZÐ\^ÓI_Õ_ˆØ˜6Õ" ]°6Õ%:Õ:ˆØ˜6Õ" ]°6Õ%:Õ:ˆð ˜•~€BØ˜•~€BØ˜•~€BØ˜•~€Bà
ˆR��"�€AØ
ˆR��"�€Aä
�+Š+�q�f˜bÓ
!€Cà )¬e¯m©m¼U¿^¹^Ð-LÔ Lˆ3�6‰6�)ÓÐUÐRUÐUr   )Fr7   )Ú__doc__Útypingr   r   Útorch.nn.functionalÚnnÚ
functionalrO   Úkornia.core.checkr   Úkornia.core.utilsr   r.   ri   © r   r   Ú<module>rr      s2   ðñ$ iå ã ß Ð å 0Ý /÷Z÷zVVñ VVr   