+
    åûjÞB  ã                   ó®   € R t ^ RIHtHt ^ RIt^ RIHt ^ RIH	t	H
t
HtHt ^ RIHt ^ RIHtHtHtHtHtHt ^ RIHtHt ^ RIHt RR	 R
 lltRR R lltR# )ziEstimate a camera's world-to-camera pose from 3D-2D correspondences by the direct linear transform (PnP).)ÚOptionalÚTupleN)Úqr)ÚKORNIA_CHECKÚKORNIA_CHECK_IS_TENSORÚKORNIA_CHECK_SAME_SHAPEÚKORNIA_CHECK_SHAPE)Úeye_like)Ú_at_least_float32Ú_autocast_disabledÚ_right_singular_vectorÚ_svd_work_dtypeÚ_torch_linalg_svdvalsÚ_torch_svd_cast)Úconvert_points_to_homogeneousÚ normalize_points_with_intrinsics)Útransform_pointsc          
      óÐ   € V ^8„  d   QhR\         P                  R\        R\        \         P                  ,          R\        \         P                  \         P                  3,          /# )é   ÚpointsÚepsÚweightsÚreturn)ÚtorchÚTensorÚfloatr   r   )Úformats   "Ú[C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\calibration\pnp.pyÚ__annotate__r   '   sK   € ÷ #$ñ #$Ü�L‰Lð#$Ü$ð#$Ü6>¼u¿|¹|Õ6Lð#$ä
Œ5�<‰<œŸ™Ð%Õ&ñ#$ó    c                ó  € \        V . RO4       VfD   \        P                  ! V ^RR7      pW,
          P                  R	^R7      P                  R	R7      pMjW"P	                  ^RR7      ,          pVR
,          V ,          P	                  ^RR7      pWPV,
          P                  R	^R7      ,          P	                  R	R7      pV P
                  R	,          pVR,          WA,           ,          p\        V^,           V 4      p\        P                  ! V\        P                  V P                  R7      pVRWˆ3,          VR,          ,          VRWˆ3&   VRW†3,          VR,          ) VR^ V3,          ,          ,           VRW†3&   \        Wp4      p	W—3# )aã  Normalize points.

Args:
   points : torch.Tensor containing the points to be normalized with shape ``(B, N, D)``.
   eps : Small value to avoid division by zero error.
   weights : Optional non-negative per-point weights with shape ``(B, N)`` for the mean and the scale.
      A point with weight zero does not affect the normalization.

Returns:
   Tuple containing the normalized points in the shape ``(B, N, D)`` and the transformation matrix
   in the shape ``(B, D+1, D+1)``.

T©ÚdimÚkeepdim)r"   Úp©r"   g      à?©ÚdtypeÚdeviceºNNN)ÚBÚNÚDéÿÿÿÿ©.N)r)   N)r   r   ÚmeanÚnormÚsumÚshaper	   ÚarangeÚint64r(   r   )
r   r   r   Úx_meanÚscaleÚwÚD_intÚ	transformÚidxsÚpoints_norms
   &&&       r   Ú_mean_isotropic_scale_normalizer<   '   sX  € ô  �všÔ/Ø‚Ü—’˜F¨°4Ô8ˆØ•×&Ñ&¨2°Ð&Ó3×8Ñ8¸RÐ8Ó@‰à—k‘k a°�kÓ6Õ6ˆØ�I•, Õ'×,Ñ,°¸DÐ,ÓAˆØ˜v•o×+Ñ+°°aÐ+Ó8Õ8×=Ñ=À"Ð=ÓEˆà�L‰L˜Õ€EØ�C�Z˜E�KÕ(€EÜ˜ � FÓ+€Iä�<Š<˜¤U§[¡[¸¿¹ÔG€DØ(¨¨D¨Õ7¸%À½.ÕH€Iˆa�ˆmÑØ )¨!¨T¨.Õ 9¸eÀG½n¸_ÈvÐVWÐYZÐ\`ÐV`ÕOaÕ=aÕ b€Iˆa�ˆnÑä" 9Ó5€KàÐ#Ð#r   c                óÚ   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        \         P                  ,          R\        R\         P                  /# )r   Úworld_pointsÚ
img_pointsÚ
intrinsicsr   Úsvd_epsr   )r   r   r   r   )r   s   "r   r   r   M   sm   € ÷ yHñ yHÜ—,‘,ðyHä—‘ðyHô —‘ðyHô ”e—l‘lÕ#ð	yHô
 ðyHô ‡\�\ñyHr   c           	     ó‚  a € \         P                  \         P                  \         P                  \         P                  3pRp\        S 4       \        V4       \        V4       \        \        V\        4      R\        V4      P                   R24       \        S P                  V9   RV RS P                   R24       \        VP                  V9   RV RVP                   R24       \        VP                  V9   RV RVP                   R24       S P                  p\        S 4      \        V4      uo p\        V4      p\        S . RO4       \        V. RO4       \        V. RO4       \        S R,          VR,          4       \        S P                  ^,          ^8¬  V 3R l4       Ve   \        V4       \        V4      pS P                  R
,          w  r‰R	p
R	pVeî   VP                  W‰38w  d   \!        RVP                   R24      hV^ 8g  P#                  ^RR7      p\        \%        V^8¬  P'                  4       4      R4       W3P)                  4       P+                  ^RR7      ,          pV^,          p
VP-                  V
P                  4      pV\         P.                  ! WÊP#                  ^RR7      ,          4      ,          R,          p\1        S P2                  P                  4      ;_uu_ 4        \5        S V
R7      w  rï\7        Vf   TMW¾,          4      p\         P8                  ! VR,          V8  4      '       d   \!        RV R24      h\;        V4      p\=        W4      p\5        VV
R7      w  pp\         P>                  ! V4      p\         P@                  ! V^V	,          ^3S P                  S P2                  R7      pVVR&   VVR&   VR,          VR ,          ,          VR!&   VR,          VR",          ,          VR#&   VeD   VPC                  R4      PE                  ^^^4      PG                  V^V	,          ^4      pVV,          pVPI                  4       P-                  \K        V4      4      p\M        VRR7      w  ppp\O        VVVR4      P-                  VP                  4      pVPQ                  V^^4      p\S        ^V4      pVVR$&   \         PT                  ! VV4      p\         PT                  ! VVR$,          4      p\         PV                  ! VR%,          4      p\         PX                  ! V4      p\         PZ                  ! V^ 8  VR,          V4      p VV R&,          ,          p\         P\                  ! VR',          ^^R7      p!^V!,          R&,          p"VV",          p#\_        V#R%,          4      w  p$p%\S        ^V$4      p&\         P`                  ! V&V%,          4      p'\         PT                  ! V$V'4      p(\         Pb                  ! V(V#R(,          .RR7      P-                  V4      uuR	R	R	4       #   + '       g   i     R	# ; i))a¿  Estimate a camera's world-to-camera pose from 3D-2D correspondences by the DLT (PnP).

``Rt = solve_pnp_dlt(world_points, img_points, K)`` takes ``B`` sets of :math:`N \geq 6` world points
``(B, N, 3)``, their pixels ``(B, N, 2)`` and the intrinsics ``(B, 3, 3)``, and returns the world-to-camera
extrinsics ``[R | t]`` of each set, ``(B, 3, 4)``: the Hartley-normalized, optionally weighted, linear
(Direct Linear Transform) solution of the Perspective-n-Point problem, with ``R`` made orthonormal by a QR step.
It is not robust to outliers and does not refine the pose nonlinearly. For 2D-2D correspondences of a plane,
use :func:`~kornia.geometry.homography.find_homography_dlt`; for two views with no known 3D points,
:func:`~kornia.geometry.epipolar.find_essential`.

This function cannot be used if all the 3D world points (of any element
of the batch) lie on a line or if all the 3D world points (of any element
of the batch) lie on a plane. This function attempts to check for these
conditions and throws an AssertionError if found. Do note that this check
is sensitive to the value of the svd_eps parameter.

Another bad condition occurs when the camera and the points lie on a
twisted cubic. However, this function does not check for this condition.

Convention:
    - the returned ``(B, 3, 4)`` matrix is the **world-to-camera** ``[R | t]``: it maps a world point
      into the camera frame (``X_cam = X_world + (1, 0, 0)`` gives ``t = (+1, 0, 0)``), not a
      camera-to-world pose.
    - ``intrinsics`` is the ``(B, 3, 3)`` ``K``, or a ``(1, 3, 3)`` ``K`` shared by the batch; the
      ``(B, 4, 4)`` matrix that a :class:`~kornia.geometry.camera.pinhole.PinholeCamera` stores is rejected.
    - ``weights`` scales the two rows each point contributes to the homogeneous linear system, and the
      normalization and the degeneracy check use the same weighting. A uniform ``weights`` leaves the answer
      unchanged up to rounding, and a zero weight is the same as removing the point.
    - fewer than 6 points or 6 nonzero ``weights``, or a ``world_points``, ``img_points`` or ``intrinsics``
      in a dtype other than float16/bfloat16/float32/float64, raise :class:`~kornia.core.exceptions.BaseError`
      naming the argument; a degenerate ``world_points`` raises :class:`AssertionError` from the check above.
    - float16 and bfloat16 inputs are solved in float32 and the pose is returned in the dtype of
      ``world_points``.
    - a caller's autocast region does not change the result: float32 inputs are solved in float32.

Args:
    world_points : A torch.Tensor with shape ``(B, N, 3)`` representing
      the points in the world space.
    img_points : A torch.Tensor with shape ``(B, N, 2)`` representing
      the points in the image space.
    intrinsics : A torch.Tensor with shape ``(B, 3, 3)`` representing
      the intrinsic matrices.
    weights : A torch.Tensor with shape ``(B, N)`` representing the
        weights for each point. If None, all points are considered to be equally important.
    svd_eps : A small float value to avoid numerical precision issues.

Returns:
    A torch.Tensor with shape ``(B, 3, 4)`` representing the estimated world to
    camera transformation matrices (also known as the extrinsic matrices).

See Also:
    - :func:`~kornia.geometry.homography.find_homography_dlt`: the DLT for 2D-2D correspondences, a homography
      rather than a pose.
    - :func:`~kornia.geometry.epipolar.find_essential`: the relative pose of two views from 2D-2D
      correspondences, without 3D points.
    - :func:`~kornia.geometry.epipolar.projection_from_KRt`: the ``(B, 3, 4)`` projection matrix
      ``K [R | t]`` of the result.
    - :class:`~kornia.geometry.camera.pinhole.PinholeCamera`: a camera model that takes the result, padded to
      ``(B, 4, 4)``, as its extrinsics.

Example:
    >>> world_points = torch.tensor([[
    ...     [ 5. , -5. ,  0. ], [ 0. ,  0. ,  1.5],
    ...     [ 2.5,  3. ,  6. ], [ 9. , -2. ,  3. ],
    ...     [-4. ,  5. ,  2. ], [-5. ,  5. ,  1. ],
    ... ]], dtype=torch.float64)
    >>>
    >>> img_points = torch.tensor([[
    ...     [1409.1504, -800.936 ], [ 407.0207, -182.1229],
    ...     [ 392.7021,  177.9428], [1016.838 ,   -2.9416],
    ...     [ -63.1116,  142.9204], [-219.3874,   99.666 ],
    ... ]], dtype=torch.float64)
    >>>
    >>> intrinsics = torch.tensor([[
    ...     [ 500.,    0.,  250.],
    ...     [   0.,  500.,  250.],
    ...     [   0.,    0.,    1.],
    ... ]], dtype=torch.float64)
    >>>
    >>> print(world_points.shape, img_points.shape, intrinsics.shape)
    torch.Size([1, 6, 3]) torch.Size([1, 6, 2]) torch.Size([1, 3, 3])
    >>>
    >>> pred_world_to_cam = kornia.geometry.solve_pnp_dlt(world_points, img_points, intrinsics)
    >>>
    >>> print(pred_world_to_cam.shape)
    torch.Size([1, 3, 4])
    >>>
    >>> pred_world_to_cam
    tensor([[[ 0.9392, -0.3432, -0.0130,  1.6734],
             [ 0.3390,  0.9324, -0.1254, -4.3634],
             [ 0.0552,  0.1134,  0.9920,  3.7785]]], dtype=torch.float64)

z%float16, bfloat16, float32 or float64zsvd_eps must be a float, got Ú.zworld_points must be z, got zimg_points must be zintrinsics must be c                  ó2   <€ R S P                   ^,           R2# )z;world_points must hold at least 6 points (N >= 6), got N = rC   )r2   )r>   s   €r   Ú<lambda>Úsolve_pnp_dlt.<locals>.<lambda>Í   s   ø€ ÐMÈl×N`ÑN`ÐabÕNcÐMdÐdeÑfr   N:Nr   Nz&Weights should have shape (B, N). Got Tr!   zhweights must hold at least 6 nonzero entries in every batch element, as world_points must hold 6 points.)r   zQThe last singular value of one/more of the elements of the batch is smaller than z£. This function cannot be used if all world_points (of any element of the batch) lie on a line or if all world_points (of any element of the batch) lie on a plane.r&   F)Úfull_matrices)Úinputr$   r"   r%   )r*   r+   Ú3)r*   r+   Ú2)r*   rI   rI   )r)   r)   é    r.   r-   )r)   r-   )r)   ºrK   Nr   :rK   é   N)r)   ºé   Nr   :rM   é   N).:rK   rO   N)r)   rL   ºrP   é   N).:rO   r   N)r)   rN   rQ   )r)   ºNé   Nr)   )r)   rS   rS   )r)   NN)r)   rS   rK   )r)   rS   :rT   rM   N)2r   Úfloat16Úbfloat16Úfloat32Úfloat64r   r   Ú
isinstancer   ÚtypeÚ__name__r'   r
   r   r   r2   ÚAssertionErrorr1   ÚboolÚallÚabsÚamaxÚtoÚsqrtr   r(   r<   r   Úanyr   r   ÚinverseÚzerosÚ	unsqueezeÚrepeatÚviewÚdetachr   r   r   Úreshaper	   ÚbmmÚdetÚ	ones_likeÚwherer0   Ú	linalg_qrÚsignÚcat))r>   r?   r@   r   rA   Úaccepted_dtypesÚacceptedr'   r*   r+   Úpoint_weightsÚcheck_scaleÚnum_usedÚrel_weightsÚworld_points_normÚworld_transform_normÚsÚworld_points_norm_hÚimg_points_invÚimg_points_normÚimg_transform_normÚinv_img_transform_normÚsystemÚweights_expandedÚworkÚ_ÚvÚsolutionÚsolution_4x4Úintermediaterl   Úones_tensorÚsign_fixÚnorm_colÚ
mul_factorÚtempÚorthoÚrightÚmaskÚcol_sign_fixÚrot_mats)   f&&&&                                    r   Úsolve_pnp_dltr’   M   sŒ  ø€ ôZ —}‘}¤e§n¡n´e·m±mÄUÇ]Á]ÐS€OØ6€HÜ˜<Ô(Ü˜:Ô&Ü˜:Ô&Ü”˜G¤UÓ+Ð/LÌTÐRYË]×McÑMcÐLdÐdeÐ-fÔgÜ�×#Ñ# Ñ6Ð:OÐPXÈzÐY_Ð`l×`rÑ`rÐ_sÐstÐ8uÔvÜ�×!Ñ! _Ñ4Ð8KÈHÈ:ÐU[Ð\f×\lÑ\lÐ[mÐmnÐ6oÔpÜ�×!Ñ! _Ñ4Ð8KÈHÈ:ÐU[Ð\f×\lÑ\lÐ[mÐmnÐ6oÔpà×Ñ€EÜ0°Ó>Ô@QÐR\Ó@]Ð€L�*Ü" :Ó.€JÜ�|¢_Ô5Ü�z¢?Ô3Ü�z¢?Ô3Ü˜L¨Õ1°:¸gÕ3FÔGÜØ×Ñ˜1Õ Ñ"Üfôð ÒÜ˜wÔ'Ü# GÓ,ˆà×Ñ˜bÕ!�D€Að €MØ€KØÒØ�=‰=˜Q˜FÔ"Ü Ð#IÈ'Ï-É-ÈÐXYÐ!ZÓ[Ð[Ø˜q‘L×%Ñ%¨!°TÐ%Ó:ˆÜÜ�(˜a‘-×$Ñ$Ó&Ó'Øvô	
ð §¡£× 2Ñ 2°qÀ$Ð 2Ó GÕGˆØ# Q�ˆð —;‘;˜}×2Ñ2Ó3ˆØ"¤U§Z¢Z°×;LÑ;LÐQRÐ\`Ð;LÓ;aÕ0aÓ%bÕbÐdmÕnˆô 
˜L×/Ñ/×4Ñ4×	5Õ	5ä2QÐR^ÐhuÔ2vÑ/Ðô
 "°{Ò7JÑ"3ÐP[ÕPoÓpˆÜ�9Š9�Q�u•X Ñ'×(Ò(Ü ðØ�yð !8ð8óð ô <Ð<MÓNÐô :¸*ÓQˆÜ.MÈnÐfsÔ.tÑ+ˆÐ+Ü!&§¢Ð/AÓ!BÐô —’˜a  Q¥¨˜^°<×3EÑ3EÈl×NaÑNaÔbˆØ2ˆˆ|ÑØ2ˆˆ|ÑØ 3°rÕ :¸_ÈXÕ=VÕ Vˆˆ}ÑØ 3°rÕ :¸_ÈXÕ=VÕ Vˆˆ}Ñð ÒØ&×0Ñ0°Ó4×;Ñ;¸A¸qÀ!ÓD×IÑIÈ!ÈQÐQRÍUÐTUÓVÐà%¨Õ.ˆFð �}‰}‹×!Ñ!¤/°&Ó"9Ó:ˆÜ! $°eÔ<‰ˆˆ1ˆaÜ)¨&°!°Q¸Ó;×>Ñ>¸v¿|¹|ÓLˆð ×#Ñ# A q¨!Ó,ˆô    8Ó,ˆØ!)ˆ�XÑô —y’y Ð/CÓDˆÜ—9’9Ð3°\À(Õ5KÓLˆô �iŠi˜ Õ+Ó,ˆÜ—o’o cÓ*ˆÜ—;’;˜s Q™w¨°bÕ(8¸+ÓFˆØ˜h }Õ5Õ5ˆô —:’: H¨XÕ$6¸!ÀÔCˆØ˜(•l MÕ2ˆ
Ø˜*Õ$ˆô !  i¥Ó1‰ˆˆuô ˜˜5Ó!ˆÜ—z’z $¨¥,Ó/ˆÜ—)’)˜E <Ó0ˆô �yŠy˜' 4¨
Õ#3Ð4¸"Ô=×@Ñ@ÀÓG÷u 
6×	5×	5Ó	5ús   Ë3L/X-Ø-X>	)g:Œ0âŽyE>N)Ng-Cëâ6?)Ú__doc__Útypingr   r   r   Útorch.linalgr   ro   Úkornia.core.checkr   r   r   r   Úkornia.core.opsr	   Úkornia.core.utilsr
   r   r   r   r   r   Úkornia.geometry.conversionsr   r   Úkornia.geometry.linalgr   r<   r’   © r   r   Ú<module>rœ      sD   ðñ$ pç "ã Ý (ç oÓ oÝ $÷÷ ÷ hÝ 3÷#$÷LyHñ yHr   